radius property

num get radius

Returns the radius of the graph, which is the minimum eccentricity among all vertices in the graph.

Returns 0 if the graph has 0 or 1 vertex. Returns double.infinity if the graph is disconnected.

Implementation

num get radius {
  if (_pairs.length <= 1) return 0;
  var minEcc = double.infinity;
  for (final vertex in _pairs.keys) {
    final ecc = eccentricity(vertex);
    if (ecc < minEcc) minEcc = ecc.toDouble();
  }
  return minEcc;
}