Consider the following directed graph, which is given in adjacency list form as described above and where vertices have numerical labels:
1: 9 2: 3, 5 3: 7, 9 4: 2, 3, 6 5: 6: 5 7: 5 8: 2, 3, 4 9: 7
Consider the following undirected graph, which is given in adjacency matrix form and where vertices have character labels and edges have non-negative integer weights (no value indicates no edge exists):
A B C D E F G +-------------- A | 2 8 4 2 B | 2 1 7 C | 8 9 3 5 D | 4 1 9 3 E | 7 3 1 F | 3 1 9 G | 2 5 9
Iteration | List of Visited Vertexes and their shortest distances from start |
Priority Queue's items (listed in increasing order) |
0 | - | 0 E |
1 | E 0 | 1 F, 3 D, 7 B |
2 | E 0, F 1 |
public static void printPairs(int arr[], int sum) {