Directed Acyclic Graph is a very special graph and has the following properties:
The edges of this graph are directed, it means all the edges have a designated direction.
There is no cycle in the graph, which means that a path will never contain one vertex more than once.
We referred to these kind of graphs in the topological ordering post.
Here we discuss the algorithm to find single source shortest path in such graphs. The good part is that unlike Dijkstra and Bellman Ford this can be solved in linear time O(E+V).
This algorithm for finding shortest path of directed acyclic ...

Read More
# shortest path algorithms

## Shortest Path Using Bellman Ford Algorithm

Introduction
This post about Bellman Ford Algorithm is a continuation of the post Shortest Path Using Dijkstra's Algorithm. While learning about the Dijkstra's way, we learnt that it is really efficient an algorithm to find the single source shortest path in any graph provided it has no negative weight edges and no negative weight cycles.
The running time of the Dijkstra's Algorithm is also promising, O(E +VlogV) depending on our choice of data structure to implement the required Priority Queue.
Why Bellman Ford Algorithm?
There can be scenarios where a graph may contain negative weight cycle...

Read More
## Shortest Path using Dijkstra’s Algorithm

Introduction
This is the third post in the Graph Traversals – Online Classes.
After learning how to move through a graph, we might be interested in learning more. One interesting problem is determining the shortest path between two vertices of a graph.
The problem can be extended and defined in many other forms. I prefer to call it "minimizing the cost". For e.g.
When we measure the cost in terms of the distances between vertices, it can be called as the Shortest Path.
When we measure the cost in terms of the money spent between vertices, it can be called as the Cheapest Path.
Whe...

Read More