Question

I have drawn a binary search tree using pydot with these commands

graph = pydot.Dot(graph_type='graph')
visit(n5, BFS)
graph.write_png('example1_graph.png')

Where function view traverses the tree and calls a simple routine to draw the edges:

def draw(parent_name, child_name):
    # color for lines = red
    edge = pydot.Edge(parent_name, child_name, color="#ff0000")
    graph.add_edge(edge) 

But the lines connecting the nodes are simple straight lines. Is there a way to change the simple lines into directed arrows?

Was it helpful?

Solution

To connect nodes with arrows, use a directed graph type. Change the first line of the code, and the lines connecting nodes will be arrows instead of lines.

graph = pydot.Dot(graph_type='digraph')
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top