Skip to content Skip to sidebar Skip to footer

How Can I Make Curved Edges Between Two Nodes In A Digraph?

I am trying to add curved arrows between two nodes in a DiGraph by using NetworkX library. The documentation for the function nx.draw_networkx_edges mentions the argument connectio

Solution 1:

I had a similar issue a while back (I wanted to compare two states of the same network). I couldn't work out a solution using networkx so I made my own, the code for which can be found here.

enter image description here

You will have to convert your edge list into a square adjacency matrix, where the absence of a connection is denoted by a NaN, and non-NaN entries are interpreted as edge weights and mapped to edge colors. You can then call the module using

network_line_graph.draw(adjacency_matrix, node_order=None, arc_above=True) 

Note that if you don't specify the node order explicitly, the node order is optimised using recursive minimum flow cuts to place strongly connected subnetworks/nodes together (ideally you would minimize total arc length but that gets computationally expensive very quickly).

The API is pretty similar to networkx but if you do have any problems, please raise an issue on the github.

Post a Comment for "How Can I Make Curved Edges Between Two Nodes In A Digraph?"