Skip to content

Commit a4dd1bf

Browse files
author
soycode
committedJul 27, 2018
Add recursive debug
1 parent 1285aa6 commit a4dd1bf

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed
 

‎graph_dfs_debug/README.md

+5
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ this part didn't really work.
1919
5. My editor sure is complaining a lot about something called "lint."
2020
6. I keep losing track of my variables, I guess I should name them better?
2121

22+
I also tried to do it with recursion instead of a stack, in `graph_rec`, but I
23+
got even more stuck. It was running forever so I tried adding a thing to keep
24+
track of vertices, and now I just get an error message. Please try to fix this
25+
too if you can, or at least give me some pointers on what I should be doing.
26+
2227
I'm still trying to learn this stuff, so please don't just fix the code for me.
2328
Let me know in the `Answers.md` file where my bugs are and what you did to fix
2429
them, so I can have an easier time watching out for them next time. Oh and don't

‎graph_dfs_debug/graph.py

+7
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,13 @@ def dfs(self, start, target=None):
3636

3737
return x
3838

39+
def graph_rec(self, start, target=None):
40+
x = set()
41+
x.append(start)
42+
for v in self.vertices[start]:
43+
graph_rec(v)
44+
return x
45+
3946
def find_components(self):
4047
visited = set()
4148
current_component = 0

0 commit comments

Comments
 (0)
Please sign in to comment.