V
V
Victor2015-02-24 17:31:19
Algorithms
Victor, 2015-02-24 17:31:19

How to find the shortest path in a bipartite graph?

In Sedgwick's book "Algorithms in Java", in the section on symbolic graphs, I encountered the problem of "Degrees of separation". And there he wrote the phrase that "Breadth-first search guarantees finding the" right path ", but not the fact that this path will be the shortest.
Maybe it depends on the fact that the graph is symbolic - but this condition is perfectly manageable, just symbolic vertices turn into index ones and, in theory, breadth-first search should behave as usual.
Tell me, which of the algorithms can be used to find the shortest path in a graph? Well, or tell me, maybe I misunderstood something.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
machinedebaser, 2015-02-24
@davinctor

Breadth first search finds the shortest path only if the weights (lengths) of the graph's edges are the same. If the edge weights are different, Dijkstra's algorithm should be used to find the shortest path. In the case of edges with negative weight, the Bellman-Ford algorithm.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question