data-structures · intermediate · ~15 min
Reuse a shortest-path result.
int dijkstra_eccentricity(const int *w,int n,int src);
Return the greatest shortest-path distance from src to any reachable vertex (0 if none reachable beyond src).
w n×n positive weights, 0=no edge.
Max finite shortest distance from src.
—
#include <stddef.h>
/* Max shortest-path distance from src to any reachable node (0 if none reachable beyond src). Weighted directed graph (0 = no edge). */
int dijkstra_eccentricity(const int *w,int n,int src){ (void)w;(void)n;(void)src; return 0; }
Letting the ∞ of unreachable vertices count as the maximum.
Isolated src → 0.
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.