Minimum spanning tree visualisation

6 ビュー (過去 30 日間)
Ewelina Adamczuk
Ewelina Adamczuk 2018 年 8 月 8 日
編集済み: Abhiram 2025 年 2 月 18 日
Guy, any idea how can I draw minimum spanning tree, assuming that I have an adjastency matrix, in which size of the "dots" is given by e.g. relative size of the market and color is differentiated by the country of origin? Thank you!

回答 (1 件)

Abhiram
Abhiram 2025 年 2 月 18 日
編集済み: Abhiram 2025 年 2 月 18 日
To visualize a minimum spanning tree from an adjacency matrix, where node sizes are determined by a relative size and node colors are differentiated by categories you can follow these steps:
  • Create graph object using the adjacency matrix.
  • Use the ‘minspantree’ function to calculate the MST from the graph.
  • Visualize the MST using ‘plot’ function, with custom node sizes and colors as shown in the code given below.
marketSizes = [10, 20, 15, 25, 30]; % Example market sizes
countries = [1, 2, 1, 2, 3]; % Example country codes
% Generate colors
colors = lines(max(countries));
nodeColors = colors(countries, :);
figure;
plot(MST, 'MarkerSize', marketSizes, 'NodeColor', nodeColors, 'Layout', 'force');
For more guidance, refer to the MATLAB Documentation for ‘graph’ and ‘minspantree’ functions:
>> web(fullfile(docroot, 'matlab/ref/graph.html'))
>> web(fullfile(docroot, 'matlab/ref/graph.minspantree.html'))

カテゴリ

Help Center および File ExchangeNetworks についてさらに検索

製品


リリース

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by