Interface FloydWarshallUtil.AllPairsResult<V>

Type Parameters:
V - the vertex type | 顶点类型
Enclosing class:
FloydWarshallUtil

public static interface FloydWarshallUtil.AllPairsResult<V>
All-pairs shortest path result. 全源最短路径结果。
Since:
JDK 25, opencode-base-graph V1.0.3
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    double
    distance(V from, V to)
    Get the shortest distance between two vertices.
    Get the full distance matrix as a nested map.
    boolean
    Check if a negative cycle exists in the graph.
    path(V from, V to)
    Get the shortest path between two vertices.
  • Method Details

    • distance

      double distance(V from, V to)
      Get the shortest distance between two vertices. 获取两顶点间的最短距离。
      Parameters:
      from - the source vertex | 源顶点
      to - the target vertex | 目标顶点
      Returns:
      shortest distance, or Double.POSITIVE_INFINITY if no path | 最短距离,无路径时返回Double.POSITIVE_INFINITY
    • path

      List<V> path(V from, V to)
      Get the shortest path between two vertices. 获取两顶点间的最短路径。
      Parameters:
      from - the source vertex | 源顶点
      to - the target vertex | 目标顶点
      Returns:
      list of vertices in the shortest path, or empty list if no path | 最短路径的顶点列表,无路径时返回空列表
    • hasNegativeCycle

      boolean hasNegativeCycle()
      Check if a negative cycle exists in the graph. 检查图中是否存在负环。
      Returns:
      true if a negative cycle exists | 如果存在负环返回true
    • distanceMatrix

      Map<V, Map<V,Double>> distanceMatrix()
      Get the full distance matrix as a nested map. 获取完整的距离矩阵(嵌套映射形式)。
      Returns:
      distance matrix | 距离矩阵