Description
Give an undirected graph
, in which each edge's length is 1
, and give two
nodes from the graph. We need to find the length
of the shortest path
between the given two
nodes.
样例
Given graph = {1,2,4#2,1,4#3,5#4,1,2#5,3}
, and nodeA = 3
, nodeB = 5
.
1------2 3
\ | |
\ | |
\ | |
\ | |
4 5
r