AFAIK, networkx and igraph do not have a layout functions that infers node positions based on a given set of edge lengths.
However, netgraph, which is a python library for making better network visualisations, does implement the desired functionality in the geometric node layout. In the example below, I am using an edge list to represent the network, but netgraph also accepts networkx, igraph, and graph-tool Graph objects.
#!/usr/bin/env python
import matplotlib.pyplot as plt
from netgraph import Graph # pip install netgraph OR conda install -c conda-forge netgraph
# right triangle
edge_length = {
(0, 1) : 0.3,
(1, 2) : 0.4,
(2, 0) : 0.5,
}
edges = list(edge_length.keys())
fig, ax = plt.subplots()
Graph(edges, edge_labels=edge_length, node_layout= geometric ,
node_layout_kwargs=dict(edge_length=edge_length), ax=ax)
ax.set_aspect( equal )
plt.show()
If you only want the node positions but you don t want to use netgraph for plotting, you can compute the node positions using the get_geometric_layout
function:
from netgraph import get_geometric_layout
pos = get_geometric_layout(edges, edge_length)
However, netgraph uses a non-linear optimisation to infer the node positions from the edge lengths. This computation scales with the square of the number of nodes. For networks that can reasonably represented as link diagrams (i.e. up to a few hundred nodes) the computation time is reasonably short (<2 seconds) but I have never tried running the procedure on 80k nodes and I suspect it would take days to finish.