Most efficient shortest path algorithm on non-negative-edged graph - algorithm

What is the most efficient shortest path algorithm performed on a graph that is not directed and only has positive edges out of these five algorithms?
BFS
DAG
Dijkstra
Floyd-Warshall
Bellman-Ford
So I know Dijkstra's can't be used on negative edges and has a running time of O(E * logV) where E is the number of edges and V is the number of vertices, so this would be my best guess. Is this correct?

If you need to find the shortest path in an unweighted graph, BFS would be the best option, however if there are weights on the edges, and you only need to find the optimal route between a single source and one or many other nodes, Dijkstra would be the best option. If you need to find the shortest path between any two pairs of nodes(i.e. have multiple sources), the best option is Floyd-Warshall.

Related

Are Prim's and Kruskal's Algorithm, shortest path algorithms?

Can these algorithms come under Dijkshtra's , Bellman-Ford , BFS, DFS algorithms?
I think no, and this is why;
Prim's and Kruskal's algorithms solve the Minimum Spanning Tree problem, and MST problem is different than Shortest Path problem.
What is the difference between them?:
MST: requirement is to reach each vertex once (create graph tree) and total (collective) cost of reaching each vertex is required to be minimum among all possible combinations.
SP: requirement is to reach destination vertex from source vertex with lowest possible cost (shortest weight). So here we do not worry about reaching each vertex instead only focus on source and destination vertices and thats where lies the difference.

Minimum weight edge in all paths of a directed graph

Given a directed graph with edges having -ve or +ve weights, what is the algorithms to find the smallest weight edges of all paths from vertex s to vertes d?
From Wikipedia
You are describing the Single Source shortest path problem. Which can be solved using Dijkstra's if the edges are only positive or Bellman-Ford if the edges are allowed to be negative as well.
The most important algorithms for solving this problem are:
Dijkstra's algorithm solves the single-source shortest path problem.
Bellman–Ford algorithm solves the single-source problem if edge weights may be negative.
A* search algorithm solves for single pair shortest path using heuristics to try to speed up the search.
Floyd–Warshall algorithm solves all pairs shortest paths.
Johnson's algorithm solves all pairs shortest paths, and may be faster than Floyd–Warshall on sparse graphs.
Viterbi algorithm solves the shortest stochastic path problem with an additional probabilistic weight on each node.
I would find all reachable from s, e.g. by depth first search. Then find all nodes that can reach d (equivalently, all nodes reachable from d in the graph with directions reversed). Now you want the smallest weight edges that start in the first set and end in the second set.

Dijkstra vs BellFord algorithm

If I need to find shortest paths from one source to all other vertices in graph, which is both directed and weighed, can I use Dijkstras algorithm or do I need to use BellFord algorithm?
Since a proper implementation of Dijkstra is faster than Bellman-Ford, use Dijkstra unless there are negative weight edges in the graph. In this case Dijkstra can be incorrect, but Bellman-Ford will still return the correct answer.
Remember that if a graph has a negative weight cycle, then the shortest path is not well defined. Bellman-Ford can be modified to be able to check if a given graph has a negative weight cycle.

Modifying shortest path to get a min-cost path

If we modify the shortest path problem such that the cost of a path between two vertices is the maximum of the costs of the edges on it, then for any pair of vertices u and v,
the path between them that follows a minimum-cost spanning tree is a min-cost path.
How can I prove this approach is true? It makes sense but I am not sure. Does anyone know if this algorithm exists in the literature? Is there a name for it?
The approach you mentioned is discussed in detail in literatures that discuss the relationship between Prim's algorithm and Dijkstra's algorithm, as usual wikipedia is a good place to start your research:
The process that underlies Dijkstra's algorithm is similar to the greedy process used in Prim's algorithm. Prim's purpose is to find a minimum spanning tree that connects all nodes in the graph; Dijkstra is concerned with only the lowest cost path beteen two nodes.
You can use some basic facts of MST (that are usually discussed in the correctness proof for Prim's & Kruskal's algorithms). The one that matters now is that
Lema 1:
Given a graph cut (a partitioning of the vertices into two
disjoint sets) the edge in the MST connecting the two parts will be
the cheapest of the edges connecting the two parts.
(The proof is straighfoward, if there were a cheaper edge we would be able to easily contruct a cheaper spanning tree)
We can now prove that the paths in a MST are all min-cost paths if you consider the maximum-cost:
Take any two vertices s and t in G and the path p that connects them in a MST of G. Now let uv be the most expensive edge in this path. We can describe a graph cut over this edge, with one partition with the vertices on the u side of the MST and the other partition with the vertices on the v side. We know that any path connecting s and t must pass this cut, therefore we can determine that the cost of any path from s to t must be at least the cost of the cheapest edge on this cut. But Lemma 1 tells us that uv is the cheapest edge on this cut so p must be a min-cost path.

shortest paths not path in graph

I was wondering if there is an algorithm which would find shortest paths in graph.
Let's say that I have a graph where there are couples of path from one vertex to another. Two or more of these paths have the same cost. How can I mark, find etc all shortest paths between these vertices ? As far as I know Dijkstra or Bellman-Ford algorithms will find shortest path but they "choose" only one.
Dijkstra's algorithm gives you the cost to all the possible intermediate nodes, and the cost of the shortest path to the sink. You can get all the paths from source to sink by doing a depth first search from the sink to the source (going backwards), where you traverse an edge (backwards) only if the cost of that edge is equal to the difference between cost of the shortest path from the source to the two nodes. Of course you get the paths in reverse order, but reversing them is easy.
.
Take a look at Floyd-Warshall.
In computer science, the
Floyd–Warshall algorithm (sometimes
known as the WFI
Algorithm or
Roy–Floyd algorithm) is a graph
analysis algorithm for finding
shortest paths in a weighted graph
(with positive or negative edge
weights). A single execution of the
algorithm will find the lengths
(summed weights) of the shortest paths
between all pairs of vertices though
it does not return details of the
paths themselves. The algorithm is an
example of dynamic programming.

Resources