diff Graph.py @ 22:84e183b40c63

Added exercises 1 and 2 from chapter 4.
author Brian Neal <bgneal@gmail.com>
date Mon, 31 Dec 2012 18:58:21 -0600
parents 1defe6fcf9d3
children 10db8c3a6b83
line wrap: on
line diff
--- a/Graph.py	Sat Dec 29 22:16:11 2012 -0600
+++ b/Graph.py	Mon Dec 31 18:58:21 2012 -0600
@@ -219,7 +219,7 @@
                 visit_func(v)
 
             # Add the adjacent neigbors to the node to the queue
-            queue.extend(self.out_vertices(v))
+            queue.extend(c for c in self.out_vertices(v) if c not in visited)
 
         return visited