Search code examples
pythongraphviz

delete/modify an edge in graphviz


is there any way to delete an existing edge in a graph? For example, when I draw an edge using

self.g.edge('a', 'b')

where self.g is my digraph, then I do

self.g.edge('a', 'b', _attributes={'arrowhead': 'dot'})

it draws another edge from a->b so now there are 2 edges instead of 1

basically what I'm trying to do is modify the existing edge

it works for nodes, but not edges


Solution

  • I don't think you can delete or modify anything with this library, but you can avoid multiple edges by initializing the graph with Digraph(strict=True) or similar.

    The reason it seems to work for nodes is that Graphviz itself replaces an existing node if a new one with the same name is added later.