HACKER Q&A
📣 darklight85

Need for visual representation of Python graph code for easier debugging


Need for visual representation of Python graph code for easier debugging


  👤 darklight85 Accepted Answer ✓
I have been doing interview prep. Was finding debugging graph based questions more difficult than usual questions. So I wrote a small piece of code (right now valid only for some cases) which helps visualize your graph algorithm in jupyter notebooks. For example you could write a code like this. [Generator is the class I have written]

def dfs(root): global g g.take_snapshot(locals()) if root.left: dfs(root.left) if root.right: dfs(root.right)

g=Generator() g.register(root_node_var=None,pointer_var="root",root_node=root) dfs(root) g.render_bt_graph()

Would something like this be useful for interview prep?