Class GraphMeasurer<V,​E>

  • Type Parameters:
    V - the graph vertex type
    E - the graph edge type

    public class GraphMeasurer<V,​E>
    extends Object
    Algorithm class which computes a number of distance related metrics. A summary of various distance metrics can be found here.
    Author:
    Joris Kinable, Alexandru Valeanu
    • Constructor Detail

      • GraphMeasurer

        public GraphMeasurer​(Graph<V,​E> graph)
        Constructs a new instance of GraphMeasurer. FloydWarshallShortestPaths is used as the default shortest path algorithm.
        Parameters:
        graph - input graph
      • GraphMeasurer

        public GraphMeasurer​(Graph<V,​E> graph,
                             ShortestPathAlgorithm<V,​E> shortestPathAlgorithm)
        Constructs a new instance of GraphMeasurer.
        Parameters:
        graph - input graph
        shortestPathAlgorithm - shortest path algorithm used to compute shortest paths between all pairs of vertices. Recommended algorithms are: JohnsonShortestPaths (Runtime complexity: $O(|V||E| + |V|^2 log|V|)$) or FloydWarshallShortestPaths (Runtime complexity: $O(|V|^3)$.
    • Method Detail

      • getDiameter

        public double getDiameter()
        Compute the diameter of the graph. The diameter of a graph is defined as $\max_{v\in V}\epsilon(v)$, where $\epsilon(v)$ is the eccentricity of vertex $v$. In other words, this method computes the 'longest shortest path'. Two special cases exist. If the graph has no vertices, the diameter is 0. If the graph is disconnected, the diameter is Double.POSITIVE_INFINITY.
        Returns:
        the diameter of the graph.
      • getRadius

        public double getRadius()
        Compute the radius of the graph. The radius of a graph is defined as $\min_{v\in V}\epsilon(v)$, where $\epsilon(v)$ is the eccentricity of vertex $v$. Two special cases exist. If the graph has no vertices, the radius is 0. If the graph is disconnected, the diameter is Double.POSITIVE_INFINITY.
        Returns:
        the diameter of the graph.
      • getVertexEccentricityMap

        public Map<V,​Double> getVertexEccentricityMap()
        Compute the eccentricity of each vertex in the graph. The eccentricity of a vertex $u$ is defined as $\max_{v}d(u,v)$, where $d(u,v)$ is the shortest path between vertices $u$ and $v$. If the graph is disconnected, the eccentricity of each vertex is Double.POSITIVE_INFINITY. The runtime complexity of this method is $O(n^2+L)$, where $L$ is the runtime complexity of the shortest path algorithm provided during construction of this class.
        Returns:
        a map containing the eccentricity of each vertex.
      • getGraphCenter

        public Set<V> getGraphCenter()
        Compute the graph center. The center of a graph is the set of vertices of graph eccentricity equal to the graph radius.
        Returns:
        the graph center
      • getGraphPeriphery

        public Set<V> getGraphPeriphery()
        Compute the graph periphery. The periphery of a graph is the set of vertices of graph eccentricity equal to the graph diameter.
        Returns:
        the graph periphery
      • getGraphPseudoPeriphery

        public Set<V> getGraphPseudoPeriphery()
        Compute the graph pseudo-periphery. The pseudo-periphery of a graph is the set of all pseudo-peripheral vertices. A pseudo-peripheral vertex $v$ has the property that for any vertex $u$, if $v$ is as far away from $u$ as possible, then $u$ is as far away from $v$ as possible. Formally, a vertex $u$ is pseudo-peripheral, if for each vertex $v$ with $d(u,v)=\epsilon(u)$ holds $\epsilon(u)=\epsilon(v)$, where $\epsilon(u)$ is the eccentricity of vertex $u$.
        Returns:
        the graph pseudo-periphery