You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Consider an undirected graph where each edge is the same weight. Each of the nodes is labeled consecutively.
You will be given a number of queries. For each query, you will be given a list of edges describing an undirected graph. After you create a representation of the graph,
you must determine and report the shortest distance to each of the other nodes from a given starting position using the breadth-first search algorithm (BFS).
Distances are to be reported in node number order, ascending. If a node is unreachable, print -1 for that node. Each of the edges weighs 6 units of distance.
For example, given a graph with 5 nodes and 3 edges [1,2],[1,3],[3,4].
The start node for the example is node 1. Outputs are calculated for distances to nodes 2 through 5:[6,6,12,-1] . Each edge is 6 units, and the unreachable node 5