Following statement is true or false?

If we make following changes to Dijkstra, then it can be used to find the longest simple path, assume that the graph is acyclic. 1) Initialize all distances as minus infinite instead of plus infinite. 2) Modify the relax condition in Dijkstra's algorithm to update distance of an adjacent v of the currently considered vertex u only if "dist[u]+graph[u][v] > dist[v]". In shortest path algo, the sign is opposite.

**(A)** True

**(B)** False

**Answer:** **(B)** **Explanation:** In shortest path algo, we pick the minimum distance vertex from the set of vertices for which distance is not finalized yet. And we finalize the distance of the minimum distance vertex.

For maximum distance problem, we cannot finalize the distance because there can be a longer path through not yet finalized vertices.

Quiz of this Question

## Recommended Posts:

- Algorithms | Graph Shortest Paths | Question 4
- Algorithms | Graph Shortest Paths | Question 14
- Algorithms | Graph Shortest Paths | Question 2
- Algorithms | Graph Shortest Paths | Question 8
- Algorithms | Graph Shortest Paths | Question 3
- Algorithms | Graph Shortest Paths | Question 7
- Algorithms | Graph Shortest Paths | Question 14
- Algorithms | Graph Shortest Paths | Question 11
- Algorithms | Graph Shortest Paths | Question 15
- Algorithms | Graph Shortest Paths | Question 13
- Algorithms | Graph Shortest Paths | Question 14
- Algorithms | Graph Shortest Paths | Question 10
- Algorithms | Graph Shortest Paths | Question 12
- Johnson’s algorithm for All-pairs shortest paths | Implementation
- Number of paths from source to destination in a directed acyclic graph