Weighted Relative Graph on 2D Coordinate System

416 views Asked by At

Given a graph of nodes and weighted edges between these nodes, such that the placement of each node is relative to other nodes in the graph, what is a good library (python preferred) to visualize these nodes with the weighted edges enforced? Lastly, how can I translate this relative graph onto a coordinate system relative to anything such that each node has a (x,y) coordinate?

Example:

Nodes: [A,B,C]
Edges: [(A,B,3), (A,C,4), (B,C,5)]

where 3, 4, and 5 are the weights of their respective edges.

This should draw a right 3,4,5 triangle. Then plot each node on a 2D coordinate system with some (x,y) coordinate for A, B, and C.

1

There are 1 answers

0
Gene On BEST ANSWER

You can probably coax GraphViz to do what you want. There is a len attribute for edges - desired length - which you can set with the edge weight.

Of course you realize that almost every graph is impossible to lay out so that edges have the length of their weights. You have to be very lucky to find one.