To store adjacency list of graph
n = 9 NEW_LINE edges = [ [ ] for i in range ( n ) ] NEW_LINE addEdge ( edges , 0 , 1 ) NEW_LINE addEdge ( edges , 0 , 7 ) NEW_LINE addEdge ( edges , 1 , 7 ) NEW_LINE addEdge ( edges , 1 , 2 ) NEW_LINE addEdge ( edges , 2 , 3 ) NEW_LINE addEdge ( edges , 2 , 5 ) NEW_LINE addEdge ( edges , 2 , 8 ) NEW_LINE addEdge ( edges , 3 , 4 ) NEW_LINE addEdge ( edges , 3 , 5 ) NEW_LINE addEdge ( edges , 4 , 5 ) NEW_LINE addEdge ( edges , 5 , 6 ) NEW_LINE addEdge ( edges , 6 , 7 ) NEW_LINE addEdge ( edges , 7 , 8 ) NEW_LINE u = 0 NEW_LINE v = 5 NEW_LINE print ( minEdgeBFS ( edges , u , v , n ) ) NEW_LINE