How to find maximum eccentricity of a vertex of non-directed graph?
4 ビュー (過去 30 日間)
古いコメントを表示
Anjani Chaudhary
2018 年 10 月 2 日
コメント済み: Walter Roberson
2020 年 10 月 7 日
How to find maximum eccentricity of a vertex of non-directed graph?
7 件のコメント
Bruno Luong
2018 年 10 月 2 日
編集済み: Bruno Luong
2018 年 10 月 2 日
Did you check out FEX for shortest path algorithms? There are a bunch of them. Not sure if you need Floyd–Warshall algorithm or loop on Dijkstra for the all edges containing the considered vertex.
採用された回答
Walter Roberson
2018 年 10 月 3 日
%need a graph
s = [1 1 2 3 3 4 4 6 6 7 8 7 5];
t = [2 3 4 4 5 5 6 1 8 1 3 2 8];
G = digraph(s,t);
%now process it
allnodes = unique(G.Edges.EndNodes);
numnodes = length(allnodes);
eccentricities = zeros(1, numnodes);
for N = 1 : numnodes
thisnode = allnodes(N);
[~, D] = shortestpathtree(G,thisnode);
eccentricities(N) = max(D);
end
graph_diameter = max(eccentricities);
7 件のコメント
Walter Roberson
2020 年 10 月 7 日
s = [1 1 2 3 3 4 4 6 6 7 8 7 5];
t = [2 3 4 4 5 5 6 1 8 1 3 2 8];
G = digraph(s,t);
plot(G)
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Graph and Network Algorithms についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!