コード例 #1
0
  /**
   * @param endVertex end vertex.
   * @return list of <code>Edge</code>, or null if no path exists between the start vertex and the
   *     end vertex.
   */
  public List<E> getPathEdgeList(V endVertex) {
    assertGetPath(endVertex);

    lazyCalculate();

    BellmanFordPathElement<V, E> pathElement = this.iter.getPathElement(endVertex);

    if (pathElement == null) {
      return null;
    }

    return pathElement.createEdgeListPath();
  }
コード例 #2
0
  /**
   * @param endVertex end vertex.
   * @return the cost of the shortest path between the start vertex and the end vertex.
   */
  public double getCost(V endVertex) {
    assertGetPath(endVertex);

    lazyCalculate();

    BellmanFordPathElement<V, E> pathElement = this.iter.getPathElement(endVertex);

    if (pathElement == null) {
      return Double.POSITIVE_INFINITY;
    }

    return pathElement.getCost();
  }