Types of Question related to 2 Nodes of a Graph
Existence of a Path Is there a path from node A A A to node B B B ? 1971. Find if Path Exists in Graph Does a path satisfying certain constraints (e.g., through specific nodes or avoiding certain nodes/edges) exist? Distance Between Two Nodes Shortest distance : Using algorithms like Dijkstra, Bellman-Ford, or BFS (for unweighted graphs). 787. Cheapest Flights Within K Stops Exact distance or range : Finding if a specific distance exists. Number of Paths Between Two Nodes Simple paths : Count paths where no node is revisited. All paths : Count paths (with possible revisits). K-length paths : Paths of exactly or at most k k k edges Shortest Path Between Two Nodes Weight-based shortest path : Using weights on edges. Fewest edges : Finding paths with the smallest number of edges. Maximum Flow or Minimum Cut Between Two Nodes Maximum flow problems deal with finding the maximum "amount" of a resource that can flow between two nodes in a capacitated graph. Connectivity Qu...