OrderedCollection variableSubclass: #Graph instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'Collections-Graphs'! Graph comment: '================================================= Copyright (c) 1992 by Justin O. Graver. All rights reserved (with exceptions). For complete information evaluate "Object tgenCopyright." ================================================= I am an abstract class of graphs.'! "-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "! Graph class instanceVariableNames: ''! !Graph class methodsFor: 'instance creation'! preferredNodeClass ^self subclassResponsibility! withNodesLabeled: aCollection | newGraph | aCollection size ~= aCollection asSet size ifTrue: [self notify: 'warning: duplicate node names specifed for graph']. newGraph := self new: aCollection size. aCollection do: [:nodeName | newGraph add: (self preferredNodeClass label: nodeName)]. ^newGraph! ! Graph variableSubclass: #DirectedGraph instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'Collections-Graphs'! DirectedGraph comment: '================================================= Copyright (c) 1992 by Justin O. Graver. All rights reserved (with exceptions). For complete information evaluate "Object tgenCopyright." ================================================= This class represents a directed graph.'! !DirectedGraph methodsFor: 'enumerating'! nodesDo: aBlock self do: aBlock! ! !DirectedGraph methodsFor: 'modifying'! addEdgeFrom: node1 to: node2 node2 addPredecessor: node1! ! DirectedGraph variableSubclass: #LabeledDigraph instanceVariableNames: '' classVariableNames: '' poolDictionaries: '' category: 'Collections-Graphs'! LabeledDigraph comment: '================================================= Copyright (c) 1992 by Justin O. Graver. All rights reserved (with exceptions). For complete information evaluate "Object tgenCopyright." ================================================= This class represents a directed graph whose edges are labeled.'! !LabeledDigraph methodsFor: 'modifying'! addEdgeFromNodeLabeled: label1 toNodeLabeled: label2 | node1 node2 | label1 ~= label2 ifTrue: ["self edges are implicit and not represented" node1 := self detect: [:node | node label = label1]. node2 := self detect: [:node | node label = label2]. self addEdgeFrom: node1 to: node2]! ! "-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "! LabeledDigraph class instanceVariableNames: ''! !LabeledDigraph class methodsFor: 'instance creation'! preferredNodeClass ^NodeLabeledDigraphNode! !