Here is the problem:
provided that two people are registered on the social network website, how to decide whether they are connected or not?
my analysis (after reading more): in fact, the question is looking for - the shortest path from A to B in the graph. I think that BFS and Dijkstra Algorithms work here, and the time complexity is the same (O (V + E)), because it is an unweighted schedule, so we cannot use the priority queue. Thus, a simple task can solve the problem. But, both of them do not solve the problem, which: find a path between them.
Bidrectrol should be the best solution for now.
source
share