# Tag Archives: Shortest Path

## Sum of all pair shortest paths in a Tree

Given a weighted undirected graph T consisting of nodes valued [0, N – 1] and an array Edges[] of type {u, v, w} that denotes… Read More »

## Print all possible shortest chains to reach a target word

Given two strings start and target(both of the same length) and a list of strings str[], the task is to print all possible smallest sequences… Read More »

## Minimum Cost Maximum Flow from a Graph using Bellman Ford Algorithm

Given a source node S, a sink node T, two matrices Cap[ ][ ] and Cost[ ][ ] representing a graph, where Cap[i][j] is the… Read More »

## Single source shortest path between two cities

Given a graph of N Nodes and E edges in form of {U, V, W} such that there exists an edge between U and V… Read More »

## Minimum Cost Path in a directed graph via given set of intermediate nodes

Given a weighted, directed graph G, an array V[] consisting of vertices, the task is to find the Minimum Cost Path passing through all the… Read More »

## Print negative weight cycle in a Directed Graph

Given a weighted directed graph consisting of V vertices and E edges. The task is to print the cyclic path whose sum of weight is… Read More »

## Minimum cost path in a Matrix by moving only on value difference of X

Given a matrix mat[][] and an integer X, the task is to find the minimum number of operations required to reach  from . In each… Read More »

## D’Esopo-Pape Algorithm : Single Source Shortest Path

Given a graph and a source vertex src in a weighted undirected graph, find the shortest paths from src to all vertices in the given… Read More »

## Check if given path between two nodes of a graph represents a shortest paths

Given an unweighted directed graph and Q queries consisting of sequences of traversal between two nodes of the graph, the task is to find out… Read More »

## Number of shortest paths to reach every cell from bottom-left cell in the grid

Given two number N and M. The task is to find the number of shortest paths to reach the cell(i, j) in the grid of… Read More »

## Sum of shortest distance on source to destination and back having at least a common vertex

Given a directed weighted graph and the source and destination vertex. The task is to find the sum of shortest distance on the path going… Read More »

## Bellman Ford Algorithm (Simple Implementation)

We have introduced Bellman Ford and discussed on implementation here. Input: Graph and a source vertex src Output: Shortest distance to all vertices from src.… Read More »

## Shortest paths from all vertices to a destination

Given a Weighted Directed Graph and a destination vertex in the graph, find the shortest distance from all vertex to the destination vertex. Input :… Read More »

## Uniform-Cost Search (Dijkstra for large Graphs)

Uniform-Cost Search is a variant of Dijikstra’s algorithm. Here, instead of inserting all vertices into a priority queue, we insert only source, then one by… Read More »

## Finding the path from one vertex to rest using BFS

Given an adjacency list representation of a directed graph, the task is to find the path from source to every other node in the graph… Read More »