How to find maximum eccentricity of a vertex of non-directed graph?
5 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Anjani Chaudhary
il 2 Ott 2018
Commentato: Walter Roberson
il 7 Ott 2020
How to find maximum eccentricity of a vertex of non-directed graph?
7 Commenti
Bruno Luong
il 2 Ott 2018
Modificato: Bruno Luong
il 2 Ott 2018
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.
Risposta accettata
Walter Roberson
il 3 Ott 2018
%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 Commenti
Walter Roberson
il 7 Ott 2020
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)
Più risposte (0)
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!