Reputation: 69
I have as an assigment to implement bfs and dfs graph traversal with visualization. To do that, I'm using NetworkX in Python. What I want to know is how to color a node at runtime? For example, when I am at a specific node in bfs/dfs, to set it's color to red or something. I know how to color different nodes of a graph, but not at runtime. I thinked that a possibility is to draw again and again the graph, but I'm sure that this is time consuming. Any sugestions?
Thanks in advance!
Upvotes: 0
Views: 184
Reputation: 640
NetworkX draws static graphs but you can mark visited and unvisited edges with different colour and thickness to see the walk process.
edgeSeq = [list of visited nodes]
nx.draw(G, pos, edge_color='gray',width=.2)
nx.draw(G, pos, edgelist = edgeSeq, edge_color='blue', width=2)
You may try Cambridge Intelligence trial to work with the time bar features.
Upvotes: 1