## Fastest Algorithm for finding All Pairs Shortest Paths on Sparse Non-Negative Graph

As discussed here Johnson’s Algorithm can be used to solve the APSP-Problem in $$O(V^2\log V + VE)$$ in stead of $$O(V^3)$$ for Floyd-Warshall. However, Johnsons Algorithm does quite a bit of work for the case that some weights are negative. Is there a faster way to compute this given that all weights are positive?

## Djikstra’s Shortest Path Question

I’m having some trouble conceptualizing the process for this algorithm. Do I have the following question correct?

## Shortest path with exactly k edges in a directed and weighted graph big o

how to calculate the big O of Shortest path with exactly k edges in a directed and weighted graph big O

the algorithm is:

## Determine whether given f is shortest path function

I have the following question: Let $$G = (V,E)$$ be a directed graph with a weight function $$w:E\rightarrow \mathbb{R}^+$$, and let $$s \in V$$ be a vertex such that there is a path from $$v$$ to every other vertex, i.e $$0\leq dist(s,v) < \infty$$. Let $$f\colon V \to \mathbb R$$ a given function. Describe an algorithm that runs in $$O(|V| + |E|)$$ that determines wethter this given $$f$$ is the shortest path function from $$s$$, i.e $$\forall v \in V :f(v)=dist(s,v)$$.

What I thought about was to check for every $$v \in V$$ whether $$f$$ fulfill the two following demands:

1. $$f(s)=0$$
2. $$f(v) \leq f(u) + w(uv)$$ for all $$u \in V$$ and $$uv \in E$$

This runs in the proper complexity. I thought to prove it by showing that $$f(v) \leq dist(s,v) \land f(v) \geq dist(u,v) \Rightarrow f(v) = dist(f,v)$$

I proved that $$f(v) \leq dist(s,v)$$, but I am stuck at proving that $$f(v) \geq dist(s,v)$$.

## Create an algorithm for computing the shortest path in O(m + nlogn)

So I’m trying to write an algorithm for computing the shortest path with constraints on the vertices you can visit in O(m + nlogn) time. In this problem, we are given an indirect weighted (non negative) graph G = (V, E), a set of vertices X ⊂ V, and two vertices s, t ∈ V \ X. The graph is given with adjacency lists and we can assume that it takes O(1) time to determine if a vertex is in X. I’m trying to write an algorithm which can compute the shortest path between s and t in G such that the path includes at most one vertex from X if such a path exists in O(m + nlogn) time. I know that this algorithm would require a modified Dijkstra’s algorithm but I’m unsure how to proceed from here. Could anyone please help me out? Thank you

## find shortest paths from source to all vertices using Dijkstra’s Algorithm?

For Dijkstra’s,i can find shortest paths from source to all vertices in the given graph but how can i calling the algorithm |V| times taking each vertex as a source and store all tables ??? For example : What is the shortest path from 1 to 4? You need to print the value and the exact path vertices starting from 1 and ending at 4.

## write a c++ code to solve shortest path between any two input vertices

Implement Floyd’s Algorithm and Dijkstra’s algorithm using all vertices as sources to solve All- pairs shortest path problem. For Dijkstra’s, you need to call the algorithm |V| times taking each

vertex as a source and store all tables. As a hint you may define T, presented in class, as a two- dimensional array, instead of being a one-dimensional array, of structures. You will read a graph

with random edge weights from a file and store the graph information in an adjacency matrix. Then, you need to answer any query asking for the shortest path between any two input vertices. You need to print the path from Floyd’s and Dijkstra’s algorithms. Your program should ask the user for the name of the input file.

## Shortest cycle for each vertex

I have an unweighted undirected graph.How is it possible in this graph for each vertex to find the length of the shortest cycle containing it?

## Shortest path in graph

I have an undirected graph, where the value of the path is the maximum weight among all weights edges included in it. And I want find the shortest path (by value) for two any given vertices in $$O(n + m)$$, where $$n$$ – number of vertices, $$m$$ – number of edges.

## Shortest path using less than or equal to m edges in a directed, weighted graph with negative cycles

I’m solving a problem:

Given a directed, weighted graph $$G$$ that has $$V$$ vertices and $$E$$ edges and a positive integer $$m$$, describe an algorithm that finds the length of the shortest path using less than or equal to $$m$$ edges. Note that the graph may contain negative cycles.

First, I tried Bellman-Ford algorithm, but I cannot deal with negative cycles. Next, I tried one using recursive DFS, but it takes too much time! I think dynamic programming may solve this problem, but I don’t know how to start with DP. Is there any fancy way to solve this problem in short time?