Commits

David Jones  committed 88df317

got it running. had a typo.

  • Participants
  • Parent commits 66cb6a7

Comments (0)

Files changed (1)

 
 class KosarajuStrongComponents(object):
     def __init__(self):
+        self.depth = ""
         pass
 
     def calculate(self, graph):
 
         self.id = [-1] * graph.number_vertices
         reversed = reverse(graph)
-        for v in graph.vertices:
+        for v in reversed.vertices:
             if self.id[v] == -1:
-                self.dfs(graph, v)
+                self.dfs(reversed, v)
         
         self.reverse_postorder = self.postorder
         self.id = [-1] * graph.number_vertices
 
     def dfs(self, graph, w):
         self.id[w] = self.component_count
+        depth = self.depth
+        print depth, "dfs", w
+        self.depth += " "
         for t in graph.get_edge_iterator(w):
             if (self.id[t] == -1):
                 self.dfs(graph, t)
-            self.postorder[t] = self.count
+        self.postorder[self.count] = w
         self.count += 1
+        self.depth = depth
         
 
 if __name__ == "__main__":