Plotting an undirected graph with weights

I have a set of 50 nodes with x and y coordinates and have a 50x50 matrix with the travel demands between each node pair. For each pair it holds that the demand is the same in both directions. I am trying to figure out how to plot the nodes with edges between each pair, where the color gives an indication on the weight of the edge (based on the value of travel demand). Does anybody know of a good way to plot this?

 Risposta accettata

Steven Lord
Steven Lord il 14 Nov 2018
Modificato: Steven Lord il 14 Nov 2018
Use the graph and network algorithms functionality included in MATLAB. Call graph to build your graph object then call plot on the graph object to visualize it. See the "Custom Graph Node Coordinates" and "Edge Line Width Proportional to Edge Weight" examples on the plot documentation page for more information on how to control the locations of the nodes in the plot and how to customize properties on a per-edge basis.
[Edited to add] If you want to keep your coordinates as part of the graph object rather than as separate arrays that could be accidentally clear-ed, store them as part of the Nodes table in the graph object as shown on this documentation page.

Più risposte (0)

Prodotti

Release

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by