<?xml version="1.0"?><st-source><!-- Name: CS411GraphsDbIdentifier: nilDbTrace: nilDevelopmentPrerequisites: #(#(#any 'SUnitToo(ls)' ''))PackageName: CS411GraphsParcel: #('CS411Graphs')ParcelName: CS411GraphsPrerequisiteParcels: #(#('SUnitToo(ls)' ''))PrintStringCache: nilDate: 10:05:18 am October 24, 2008 --><time-stamp>From VisualWorks® NonCommercial, 7.6 of March 3, 2008 on October 24, 2008 at 10:05:18 am</time-stamp><do-it>(Dialog confirm: 'You are filing-in a Parcel source file!\\While this is possible it will not have\the same effect as loading the parcel.\None of the Parcel''s prerequisites will\be loaded and none of its load actions\will be performed.\\Are you sure you want to file-in?' withCRs) ifFalse: [self error: 'Parcel file-in abandoned.  Choose terminate or close.']</do-it><class><name>GraphTest</name><environment>Smalltalk</environment><super>SUnit.TestCase</super><private>false</private><indexed-type>none</indexed-type><inst-vars></inst-vars><class-inst-vars></class-inst-vars><imports></imports><category>CS411</category><attributes><package>CS411Graphs</package></attributes></class><class><name>SimpleGraphReader</name><environment>Smalltalk</environment><super>Core.Object</super><private>false</private><indexed-type>none</indexed-type><inst-vars>stream graphSpecies </inst-vars><class-inst-vars></class-inst-vars><imports></imports><category>CS411</category><attributes><package>CS411Graphs</package></attributes></class><comment><class-id>SimpleGraphReader</class-id><body>This class reads Graphs from a formatted ReadStream.  The format of the stream is quite rigid.  Each graph in the stream is enclosed with lines of the form:	graph &lt;graph name&gt;	...body goes here...	endwhere &lt;graph name&gt; is replaced by the name of the graph without the angle brackets (for example, graph Network).  The body of the graph can contain either node or edge statements of the form	node &lt;node name&gt;	edge &lt;node name&gt; &lt;node name&gt;Nodes must be defined in the file _before_ they can be used in an edge.  When nextGraph is sent to a SimpleGraphReader it skips anything up to a "graph" statement.  That way if there is an error processing one graph in a stream, you can continue with the next graph.See the test class method category for some examples.Instance Variables:	stream			&lt;ReadStream&gt; 	the read stream	graphSpecies	&lt;Class&gt;			The species of the graph to be created</body></comment><class><name>PrePostVisitor</name><environment>Smalltalk</environment><super>Core.Object</super><private>false</private><indexed-type>none</indexed-type><inst-vars></inst-vars><class-inst-vars></class-inst-vars><imports></imports><category>CS411</category><attributes><package>CS411Graphs</package></attributes></class><comment><class-id>PrePostVisitor</class-id><body>An abstract class demonstrating the interface required of all graph traveral visitors.This class implements the visiting methods as "no-ops".  Concrete subclasses wouldimplement preVisit: and/or postVisit: to perform some operation upon visiting a node.Instance Variables:</body></comment><class><name>CollectingVisitor</name><environment>Smalltalk</environment><super>PrePostVisitor</super><private>false</private><indexed-type>none</indexed-type><inst-vars>nodes </inst-vars><class-inst-vars></class-inst-vars><imports></imports><category>CS411</category><attributes><package>CS411Graphs</package></attributes></class><class><name>GraphElement</name><environment>Smalltalk</environment><super>Core.Object</super><private>false</private><indexed-type>none</indexed-type><inst-vars>value graph </inst-vars><class-inst-vars></class-inst-vars><imports></imports><category>CS411</category><attributes><package>CS411Graphs</package></attributes></class><comment><class-id>GraphElement</class-id><body>A container for an arbitrary object (should use ValueModel but it is really intended for GUI applications).Instance Variables:	value	&lt;Object&gt;	the contents of this holder</body></comment><class><name>Vertex</name><environment>Smalltalk</environment><super>GraphElement</super><private>false</private><indexed-type>none</indexed-type><inst-vars>incidentEdges </inst-vars><class-inst-vars></class-inst-vars><imports></imports><category>CS411</category><attributes><package>CS411Graphs</package></attributes></class><comment><class-id>Vertex</class-id><body>A vertex intended for use in a graph which is represented using an adjacency list structure.Instance Variables:	incidentEdges	&lt;SequenceableCollection&gt;	collection of edges incident on this vertex</body></comment><class><name>Edge</name><environment>Smalltalk</environment><super>GraphElement</super><private>false</private><indexed-type>none</indexed-type><inst-vars>vertex1 vertex2 </inst-vars><class-inst-vars></class-inst-vars><imports></imports><category>CS411</category><attributes><package>CS411Graphs</package></attributes></class><comment><class-id>Edge</class-id><body>An undirected edge intended for Graphs implemented using the adjacency list structure.Instance Variables:	vertex1	&lt;Vertex&gt;	one endpoint of this edge	vertex2	&lt;Vertex&gt;	another endpoint of this edge</body></comment><class><name>Graph</name><environment>Smalltalk</environment><super>Core.Object</super><private>false</private><indexed-type>none</indexed-type><inst-vars>vertices edges </inst-vars><class-inst-vars></class-inst-vars><imports></imports><category>CS411</category><attributes><package>CS411Graphs</package></attributes></class><comment><class-id>Graph</class-id><body>An abstract class supporting a protocol for undirected graphs (although subclasses might include directed graphs).Instance Variables:	vertices	&lt;SequenceableCollection&gt;	the vertices in the graph	edges	&lt;SequenceableCollection&gt;	the edges in the graph</body></comment><methods><class-id>GraphTest</class-id> <category>sample graphs</category><body package="CS411Graphs" selector="aCompleteGraph">aCompleteGraph	"Used by various tests"	| g v |	g := self graphSpecies new.	v := OrderedCollection new.	v add: (g insertVertexContaining: 'A').	v add: (g insertVertexContaining: 'B').	v add: (g insertVertexContaining: 'C').	g 		insertEdgeConnecting: (v at: 1)		and: (v at: 2)		containing: '1'.	g 		insertEdgeConnecting: (v at: 1)		and: (v at: 3)		containing: '2'.	g 		insertEdgeConnecting: (v at: 2)		and: (v at: 3)		containing: '4'.	^g</body><body package="CS411Graphs" selector="aCompleteGraphWithLoops">aCompleteGraphWithLoops	"Used by various tests"	| g v |	g := self graphSpecies new.	v := OrderedCollection new.	v add: (g insertVertexContaining: 'A').	v add: (g insertVertexContaining: 'B').	v add: (g insertVertexContaining: 'C').	g 		insertEdgeConnecting: (v at: 1)		and: (v at: 2)		containing: '1'.	g 		insertEdgeConnecting: (v at: 1)		and: (v at: 3)		containing: '2'.	g 		insertEdgeConnecting: (v at: 2)		and: (v at: 3)		containing: '4'.	g 		insertEdgeConnecting: (v at: 2)		and: (v at: 2)		containing: '5'.	g 		insertEdgeConnecting: (v at: 3)		and: (v at: 3)		containing: '6'.	^g</body><body package="CS411Graphs" selector="aDisconnectedGraph">aDisconnectedGraph	"Used by various tests"	| g v |	g := self graphSpecies new.	v := OrderedCollection new.	v add: (g insertVertexContaining: 'A').	v add: (g insertVertexContaining: 'B').	v add: (g insertVertexContaining: 'C').	v add: (g insertVertexContaining: 'D').	v add: (g insertVertexContaining: 'E').	g 		insertEdgeConnecting: (v at: 1)		and: (v at: 2)		containing: '1'.	g 		insertEdgeConnecting: (v at: 2)		and: (v at: 1)		containing: '2'.	g 		insertEdgeConnecting: (v at: 2)		and: (v at: 3)		containing: '3'.	g 		insertEdgeConnecting: (v at: 4)		and: (v at: 5)		containing: '4'.	^g</body><body package="CS411Graphs" selector="aGraphWithLoops">aGraphWithLoops	"Used by various tests"	| g v |	g := self graphSpecies new.	v := OrderedCollection new.	v add: (g insertVertexContaining: 'A').	v add: (g insertVertexContaining: 'B').	v add: (g insertVertexContaining: 'C').	v add: (g insertVertexContaining: 'D').	v add: (g insertVertexContaining: 'E').	g 		insertEdgeConnecting: (v at: 1)		and: (v at: 2)		containing: '1'.	g 		insertEdgeConnecting: (v at: 1)		and: (v at: 3)		containing: '2'.	g 		insertEdgeConnecting: (v at: 2)		and: (v at: 2)		containing: '3'.	g 		insertEdgeConnecting: (v at: 4)		and: (v at: 5)		containing: '4'.	g 		insertEdgeConnecting: (v at: 5)		and: (v at: 1)		containing: '5'.	g 		insertEdgeConnecting: (v at: 3)		and: (v at: 5)		containing: '6'.	g 		insertEdgeConnecting: (v at: 2)		and: (v at: 2)		containing: '7'.	^g</body><body package="CS411Graphs" selector="aGraphWithParallelEdges">aGraphWithParallelEdges	"Used by various tests"	| g v |	g := self graphSpecies new.	v := OrderedCollection new.	v add: (g insertVertexContaining: 'A').	v add: (g insertVertexContaining: 'B').	v add: (g insertVertexContaining: 'C').	v add: (g insertVertexContaining: 'D').	v add: (g insertVertexContaining: 'E').	g 		insertEdgeConnecting: (v at: 1)		and: (v at: 2)		containing: '1'.	g 		insertEdgeConnecting: (v at: 2)		and: (v at: 1)		containing: '2'.	g 		insertEdgeConnecting: (v at: 2)		and: (v at: 3)		containing: '3'.	g 		insertEdgeConnecting: (v at: 4)		and: (v at: 5)		containing: '4'.	g 		insertEdgeConnecting: (v at: 3)		and: (v at: 5)		containing: '5'.	^g</body><body package="CS411Graphs" selector="anAlmostCompleteGraphWithLoops">anAlmostCompleteGraphWithLoops	"Used by various tests"	| g v |	g := self graphSpecies new.	v := OrderedCollection new.	v add: (g insertVertexContaining: 'A').	v add: (g insertVertexContaining: 'B').	v add: (g insertVertexContaining: 'C').	v add: (g insertVertexContaining: 'D').	g 		insertEdgeConnecting: (v at: 1)		and: (v at: 2)		containing: '1'.	g 		insertEdgeConnecting: (v at: 1)		and: (v at: 3)		containing: '2'.	g		insertEdgeConnecting: (v at: 1)		and: (v at: 1)		containing: '3'.	g 		insertEdgeConnecting: (v at: 2)		and: (v at: 3)		containing: '4'.	g 		insertEdgeConnecting: (v at: 2)		and: (v at: 4)		containing: '5'.	g 		insertEdgeConnecting: (v at: 3)		and: (v at: 4)		containing: '6'.	^g</body><body package="CS411Graphs" selector="aSimpleGraph">aSimpleGraph	"Used by various tests"	| g v |	g := self graphSpecies new.	v := OrderedCollection new.	v add: (g insertVertexContaining: 'A').	v add: (g insertVertexContaining: 'B').	v add: (g insertVertexContaining: 'C').	v add: (g insertVertexContaining: 'D').	v add: (g insertVertexContaining: 'E').	g 		insertEdgeConnecting: (v at: 1)		and: (v at: 2)		containing: '1'.	g 		insertEdgeConnecting: (v at: 1)		and: (v at: 3)		containing: '2'.	g 		insertEdgeConnecting: (v at: 4)		and: (v at: 5)		containing: '4'.	g 		insertEdgeConnecting: (v at: 5)		and: (v at: 1)		containing: '5'.	g 		insertEdgeConnecting: (v at: 3)		and: (v at: 5)		containing: '6'.	^g</body></methods><methods><class-id>GraphTest</class-id> <category>tests</category><body package="CS411Graphs" selector="test0">test0	"To pass this test you have defined the class ALGraph"	self assert: #{ALGraph} binding notNil</body><body package="CS411Graphs" selector="test1">test1	"To pass this test you must have correctly implemented 	insertVertexContaining:, insertEdgeConnecting:and:containing:"	| g v1 v2 e1 e2 |	g := self graphSpecies new.	v1 := g insertVertexContaining: 'A'.	v2 := g insertVertexContaining: 'B'.	e1 := g 				insertEdgeConnecting: v1				and: v2				containing: '1'.	e2 := g 				insertEdgeConnecting: v1				and: v1				containing: '2'.	self assert: g edges size = 2.	self assert: g vertices size = 2.	self assert: (g vertices contains: [:v | v == v1]).	self assert: (g vertices contains: [:v | v == v2]).	self assert: (g edges contains: [:e | e == e1]).	self assert: (g edges contains: [:e | e == e2]).	self assert: v1 graph = g &amp; (v2 graph = g).	self assert: e1 graph = g &amp; (e2 graph = g).	self 		assert: (v1 incidentEdges includes: e1) &amp; (v1 incidentEdges includes: e2).	self assert: (v2 incidentEdges includes: e1)</body><body package="CS411Graphs" selector="test2">test2	"To pass this test you must have correctly implemented 	endVertices:, adjacentVertices:"	| g v1 v2 e1 e2 |	g := self graphSpecies new.	v1 := g insertVertexContaining: 'A'.	v2 := g insertVertexContaining: 'B'.	e1 := g 				insertEdgeConnecting: v1				and: v2				containing: '1'.	e2 := g 				insertEdgeConnecting: v1				and: v1				containing: '2'.	self assert: g edges size = 2.	self assert: g vertices size = 2.	self assert: ((g endVertices: e1) includes: v1).	self assert: ((g endVertices: e1) includes: v2).	self assert: (g edgeContaining: '1') == e1.	self assert: (g edgeContaining: '2') == e2.	self assert: ((g adjacentVertices: v1) includes: v2).	self assert: ((g adjacentVertices: v1) includes: v1).	self assert: (g vertexContaining: 'A') == v1.	self assert: (g vertexContaining: 'B') == v2.	self assert: (g isVertex: v1 adjacentTo: v1).	self assert: (g isVertex: v1 adjacentTo: v2).	self assert: (g isVertex: v2 adjacentTo: v1).	self deny: (g isVertex: v2 adjacentTo: v2)</body><body package="CS411Graphs" selector="test3">test3	"To pass this test you must have correctly implemented 	degree:, removeEdge:, removeVertex:, vertexOppositeTo:on:"	| g v e |	g := self graphSpecies new.	v := OrderedCollection new.	v add: (g insertVertexContaining: 'A').	v add: (g insertVertexContaining: 'B').	v add: (g insertVertexContaining: 'C').	v add: (g insertVertexContaining: 'D').	v add: (g insertVertexContaining: 'E').	e := OrderedCollection new.	e add: (g 				insertEdgeConnecting: (v at: 1)				and: (v at: 2)				containing: '1').	e add: (g 				insertEdgeConnecting: (v at: 1)				and: (v at: 3)				containing: '2').	e add: (g 				insertEdgeConnecting: (v at: 2)				and: (v at: 2)				containing: '3').	e add: (g 				insertEdgeConnecting: (v at: 4)				and: (v at: 5)				containing: '4').	e add: (g 				insertEdgeConnecting: (v at: 5)				and: (v at: 1)				containing: '5').	e add: (g 				insertEdgeConnecting: (v at: 3)				and: (v at: 5)				containing: '6').	e add: (g 				insertEdgeConnecting: (v at: 2)				and: (v at: 2)				containing: '7').	self assert: (g degree: (v at: 5)) = 3.	self assert: (g degree: (v at: 1)) = 3.	self assert: (g degree: (v at: 2)) = 5.	self assert: (g vertexOppositeTo: (v at: 2) on: (e at: 7)) == (v at: 2).	"vertex two has a loop"	self assert: (g removeEdge: (g edgeContaining: '7')) == (e at: 7).	self assert: (g degree: (v at: 2)) = 3.	"re-insert the loop"	e at: 7		put: (g 				insertEdgeConnecting: (v at: 2)				and: (v at: 2)				containing: '7').	self assert: g edges size = 7.	self assert: g vertices size = 5.	self assert: (g removeVertex: (g vertexContaining: 'E')) == (v at: 5).	self assert: (g vertices includes: (v at: 5)) not.	self deny: ((g edges includes: (e at: 4)) | (g edges includes: (e at: 5)) | (g edges includes: (e at: 6))) .	self assert: (g removeVertex: (g vertexContaining: 'C')) == (v at: 3).	"remove a different vertex"	self assert: (g vertices includes: (v at: 3)) not.	self 		assert: (g edges 				contains: [:edge | (edge == (e at: 6) | edge) == (e at: 2)]) not.	"Remove a vertex with a self loop"	self assert: (g removeVertex: (g vertexContaining: 'B')) == (v at: 2).	self assert: g edges size = 0.</body><body package="CS411Graphs" selector="test4">test4	"To pass this test you must have correctly implemented isSimple and isComplete"	| g |	g := self aGraphWithLoops.	self deny: g isSimple.	g := self aGraphWithParallelEdges.	self deny: g isSimple.	g := self aSimpleGraph.	self assert: g isSimple.	g := self aCompleteGraph.	self assert: g isComplete.	g := self aSimpleGraph.	self deny: g isComplete.	g := self aCompleteGraphWithLoops.	self assert: g isComplete.	g := self anAlmostCompleteGraphWithLoops.	self deny: g isComplete</body><body package="CS411Graphs" selector="test5">test5	"To pass this test you must have correctly implemented 	depthFirstTraveralFrom:visitor:"	| visitor g |	visitor := CollectingVisitor new.	g := self aDisconnectedGraph.	g depthFirstTraversalFrom: (g vertexContaining: 'E') visitor: visitor.	self assert: visitor nodes size = 2.	self assert: (visitor nodes includes: (g vertexContaining: 'E')).	self assert: (visitor nodes includes: (g vertexContaining: 'D')).	visitor := CollectingVisitor new.	g depthFirstTraversalFrom: (g vertexContaining: 'B') visitor: visitor.	self assert: visitor nodes size = 3.	self assert: (visitor nodes includes: (g vertexContaining: 'A')).	self assert: (visitor nodes includes: (g vertexContaining: 'B')).	self assert: (visitor nodes includes: (g vertexContaining: 'C')).	" now check ordering "	g := self aSimpleGraph.	visitor := CollectingVisitor new.	g depthFirstTraversalFrom: (g vertexContaining: 'B') visitor: visitor.	self assert: (visitor nodes indexOf: (g vertexContaining: 'D')) 				&lt; (visitor nodes indexOf: (g vertexContaining: 'E')).	self assert: (visitor nodes indexOf: (g vertexContaining: 'E')) 				&lt; (visitor nodes indexOf: (g vertexContaining: 'A')).	self assert: (visitor nodes indexOf: (g vertexContaining: 'C')) 				&lt; (visitor nodes indexOf: (g vertexContaining: 'A')).	self assert: (visitor nodes indexOf: (g vertexContaining: 'A')) 				&lt; (visitor nodes indexOf: (g vertexContaining: 'B'))</body><body package="CS411Graphs" selector="test6">test6	"To pass this test you must have correctly implemented isConnected"	| g |	g := self aGraphWithLoops.	self assert: g isConnected.	g := self aGraphWithParallelEdges.	self assert: g isConnected.	g := self aCompleteGraph.	self assert: g isConnected.	g := self aSimpleGraph.	self assert: g isConnected.	g := self aDisconnectedGraph.	self assert: g isConnected not</body></methods><methods><class-id>GraphTest</class-id> <category>accessing</category><body package="CS411Graphs" selector="graphSpecies">graphSpecies	"modify this method to return your class"	^#{ALGraph} binding value</body></methods><methods><class-id>SimpleGraphReader</class-id> <category>private</category><body package="CS411Graphs" selector="graphSpecies:">graphSpecies: aGraphSubclass	graphSpecies := aGraphSubclass</body><body package="CS411Graphs" selector="on:">on: aReadStream	stream := aReadStream.	^self</body><body package="CS411Graphs" selector="processEdgeLine:inGraph:">processEdgeLine: line inGraph: aGraph	| v1 v2 space |	space := line findString: ' ' startingAt: 6.	v1 := aGraph vertexContaining: (line copyFrom: 6 to: space-1).	v2 := aGraph vertexContaining: (line copyFrom: space+1 to: line size).	aGraph insertEdgeConnecting: v1 and: v2 containing: nil.</body><body package="CS411Graphs" selector="processNodeLine:inGraph:">processNodeLine: line inGraph: aGraph	| name |	name := line copyFrom: 6 to: line size.	aGraph insertVertexContaining: name.</body></methods><methods><class-id>SimpleGraphReader</class-id> <category>reading</category><body package="CS411Graphs" selector="nextGraph">nextGraph	|  result line |	stream throughAll: 'graph '.	result := graphSpecies new.	Transcript show: 'reading ' , (stream upTo: Character cr); cr.   "ignore the name for now since Graphs don't support naming"	line := stream upTo: Character cr.	[('end*' match: line) or: [stream atEnd]] whileFalse: [		('node *' match: line) ifTrue: [self processNodeLine: line inGraph: result].		('edge *' match: line) ifTrue: [self processEdgeLine: line inGraph: result].		line := stream upTo: Character cr.	].	^result</body></methods><methods><class-id>SimpleGraphReader class</class-id> <category>instance creation</category><body package="CS411Graphs" selector="on:withGraphSpecies:">on: aReadStream withGraphSpecies: aGraphSubclass 	| instance |	instance := super new on: aReadStream.	instance graphSpecies: aGraphSubclass.	^instance</body></methods><methods><class-id>SimpleGraphReader class</class-id> <category>test</category><body package="CS411Graphs" selector="test1">test1	| graphDef  rs reader |	"self test1"	graphDef := 'graph Graph1node Hellonode Goodbyenode farewelledge Hello Goodbyeedge Goodbye farewellend'.	rs := ReadStream on: graphDef.	reader := self on: rs withGraphSpecies: ALGraph.	reader nextGraph inspect.</body></methods><methods><class-id>PrePostVisitor</class-id> <category>visiting</category><body package="CS411Graphs" selector="postVisit:">postVisit: aVertex	^self</body><body package="CS411Graphs" selector="preVisit:">preVisit: aVertex	^self</body></methods><methods><class-id>CollectingVisitor</class-id> <category>initialize-release</category><body package="CS411Graphs" selector="initialize">initialize	nodes := OrderedCollection new.</body></methods><methods><class-id>CollectingVisitor</class-id> <category>visiting</category><body package="CS411Graphs" selector="postVisit:">postVisit: aVertex	nodes add: aVertex</body></methods><methods><class-id>CollectingVisitor</class-id> <category>accessing</category><body package="CS411Graphs" selector="nodes">nodes	^nodes</body></methods><methods><class-id>CollectingVisitor class</class-id> <category>instance creation</category><body package="CS411Graphs" selector="new">new	^super new initialize</body></methods><methods><class-id>GraphElement</class-id> <category>accessing</category><body package="CS411Graphs" selector="graph">graph	^graph</body><body package="CS411Graphs" selector="graph:">graph: aGraph	graph := aGraph</body><body package="CS411Graphs" selector="value">value	^value</body><body package="CS411Graphs" selector="value:">value: aValue	value := aValue</body></methods><methods><class-id>GraphElement</class-id> <category>printing</category><body package="CS411Graphs" selector="printOn:">printOn: aStream	super printOn: aStream.	aStream nextPut: $(.	aStream nextPutAll: (self value printString).	aStream nextPut: $).</body></methods><methods><class-id>Vertex</class-id> <category>accessing</category><body package="CS411Graphs" selector="incidentEdges">incidentEdges	^incidentEdges</body></methods><methods><class-id>Vertex</class-id> <category>initialize-release</category><body package="CS411Graphs" selector="initialize">initialize	incidentEdges := OrderedCollection new.	^self</body></methods><methods><class-id>Vertex</class-id> <category>edges</category><body package="CS411Graphs" selector="addEdge:">addEdge: anEdge	incidentEdges add: anEdge</body><body package="CS411Graphs" selector="removeEdge:">removeEdge: anEdge	"Remove anEdge from our incident edges and return it"	^incidentEdges remove: anEdge</body></methods><methods><class-id>Vertex class</class-id> <category>instance creation</category><body package="CS411Graphs" selector="new">new	^super new initialize</body></methods><methods><class-id>Edge</class-id> <category>accessing</category><body package="CS411Graphs" selector="mateFor:">mateFor: aVertex 	"Answer the vertex opposite to aVertex on this edge"	^aVertex = vertex1		ifTrue: [vertex2]		ifFalse: [vertex1]</body><body package="CS411Graphs" selector="vertex1">vertex1	^vertex1</body><body package="CS411Graphs" selector="vertex2">vertex2	^vertex2</body></methods><methods><class-id>Edge</class-id> <category>private</category><body package="CS411Graphs" selector="with:and:">with: v1 and: v2	vertex1 := v1.	vertex2 := v2.	vertex1 addEdge: self.	vertex2 addEdge: self.	^self</body></methods><methods><class-id>Edge</class-id> <category>testing</category><body package="CS411Graphs" selector="isParallelTo:">isParallelTo: other 	^self vertex1 == other vertex1 &amp; self vertex2 == other vertex2 or: [self vertex1 == other vertex2 &amp; self vertex2 == other vertex1]</body></methods><methods><class-id>Edge class</class-id> <category>instance creation</category><body package="CS411Graphs" selector="newWith:and:">newWith: vertex1 and: vertex2	| instance |	instance := self new.	instance with: vertex1 and: vertex2.	^instance</body></methods><methods><class-id>Graph</class-id> <category>initialize-release</category><body package="CS411Graphs" selector="initialize">initialize	edges := OrderedCollection new.	vertices := OrderedCollection new.	^self</body></methods><methods><class-id>Graph</class-id> <category>adding/removing</category><body package="CS411Graphs" selector="insertEdgeConnecting:and:containing:">insertEdgeConnecting: vertex1 and: vertex2 containing: object 	"insert the specified edge and return it"	self subclassResponsibility</body><body package="CS411Graphs" selector="insertVertexContaining:">insertVertexContaining: anObject 	"Insert the specified vertex and return it"	self subclassResponsibility</body><body package="CS411Graphs" selector="removeEdge:">removeEdge: anEdge 	"remove anEdge from the graph and answer the removed edge"	self subclassResponsibility</body><body package="CS411Graphs" selector="removeVertex:">removeVertex: aVertex 	"remove aVertex from the graph and answer aVertex"	self subclassResponsibility</body></methods><methods><class-id>Graph</class-id> <category>vertex properties</category><body package="CS411Graphs" selector="adjacentVertices:">adjacentVertices: aVertex 	"Answer a SequenceableCollection (of some kind) which contains all 	vertices adjacent to the one supplied"	self subclassResponsibility</body><body package="CS411Graphs" selector="degree:">degree: aVertex	self subclassResponsibility</body><body package="CS411Graphs" selector="incidentEdges:">incidentEdges: aVertex 	"Answer a SequenceableCollection (of some kind) containing all edges 	incident on aVertex"	self subclassResponsibility</body><body package="CS411Graphs" selector="isVertex:adjacentTo:">isVertex: vertex1 adjacentTo: vertex2 	"Answer true if vertex1 is adjacent to vertex2, false otherwise"	^(self adjacentVertices: vertex1) includes: vertex2</body><body package="CS411Graphs" selector="vertexContaining:">vertexContaining: anObject	^self vertices detect: [ :vertex | vertex value = anObject ]</body><body package="CS411Graphs" selector="vertexOppositeTo:on:">vertexOppositeTo: aVertex on: anEdge 	"Answer the vertext opposite to aVertex on anEdge"	self subclassResponsibility</body></methods><methods><class-id>Graph</class-id> <category>accessing</category><body package="CS411Graphs" selector="edges">edges	"Do not modify the collection returned by this method!"	^edges</body><body package="CS411Graphs" selector="vertices">vertices	"Do not modify the collection returned by this method!"	^vertices</body></methods><methods><class-id>Graph</class-id> <category>traversals</category><body package="CS411Graphs" selector="depthFirstTraversalFrom:visitor:">depthFirstTraversalFrom: aVertex visitor: aPrePostVisitor 	"Traverse our edges/nodes, starting at aVertex, in depth-first 	order. Before visiting the nodes connected to a node send preVisit: to 	aPrePostVisitor and after visiting all nodes connected to a node 	send postVisit: to aPrePostVisitor. A given node will never be 	pre-visited or post-visited more than once. Answer self."	self subclassResponsibility</body></methods><methods><class-id>Graph</class-id> <category>graph properties</category><body package="CS411Graphs" selector="isComplete">isComplete	"A graph is complete if every node is adjacent to every other node (except, possibly, itself)"	self subclassResponsibility</body><body package="CS411Graphs" selector="isConnected">isConnected	"A graph is connected if there is a path from any node to any other 	node. Hint: A graph is connected if and only if a traversal starting 	from an arbitrary node will visit every node. Complete your depth 	first traversal method first. Then, in this method, create an instance 	of CollectingVisitor, pass it to your traversal method and when the 	traversal returns check to make sure that every node was visited 	(the visitor will collect nodes once and only once so you only have to 	check the size)."	self subclassResponsibility</body><body package="CS411Graphs" selector="isSimple">isSimple	"A graph is simple if:		it contains no self loops (edge which starts and ends on the same vertex)		it contains to parallel edges (two edges which start at the same place and end at the same place)"	self subclassResponsibility</body></methods><methods><class-id>Graph</class-id> <category>edge properties</category><body package="CS411Graphs" selector="edgeContaining:">edgeContaining: anObject	^self edges detect: [ :edge | edge value = anObject ].</body><body package="CS411Graphs" selector="endVertices:">endVertices: anEdge 	"Answer a SequenceableCollection (of some kind) which contains the 	two end vertices of the supplied edge"	self subclassResponsibility</body></methods><methods><class-id>Graph class</class-id> <category>instance creation</category><body package="CS411Graphs" selector="new">new	^super new initialize</body></methods><do-it>"Imported Classes:"</do-it><do-it>self error: 'Attempting to file-in parcel imports.  Choose terminate or close'</do-it><class><name>Object</name><environment>Core</environment><super></super><private>false</private><indexed-type>none</indexed-type><inst-vars></inst-vars><class-inst-vars></class-inst-vars><imports></imports><category>Kernel-Objects</category><attributes><package>Kernel-Objects</package></attributes></class><class><name>TestCase</name><environment>SUnit</environment><super>Core.Object</super><private>false</private><indexed-type>none</indexed-type><inst-vars>testSelector </inst-vars><class-inst-vars></class-inst-vars><imports></imports><category>SUnit</category><attributes><package>SUnitToo</package></attributes></class></st-source>