Class BFSSinglePairShortestPath

java.lang.Object
org.graph4j.GraphAlgorithm
org.graph4j.shortestpath.BFSSinglePairShortestPath
All Implemented Interfaces:
SinglePairShortestPath

public class BFSSinglePairShortestPath extends GraphAlgorithm implements SinglePairShortestPath
Determines the path with the fewest edges connecting two vertices. For unweighted graphs, breadth-first search can be used to find the shortest path between two vertices.
Author:
Cristian Frăsinaru
  • Constructor Details

    • BFSSinglePairShortestPath

      public BFSSinglePairShortestPath(Graph graph, int source, int target)
      Creates an algorithm to find the path with the fewest edges between two specified vertices. If the input graph has weights on its edges, they are ignored.
      Parameters:
      graph - the input graph.
      source - the source vertex number.
      target - the target vertex number.
    • BFSSinglePairShortestPath

      public BFSSinglePairShortestPath(Graph graph, int source, int target, int[] forbiddenVertices)
      Creates an algorithm to find the path with the fewest edges between two specified vertices, not passing through some forbidden vertices.
      Parameters:
      graph - the input graph.
      source - the source vertex number.
      target - the target vertex number.
      forbiddenVertices - vertices that are not allowed in the path; can be null if there are no forbidden vertices.
  • Method Details