a) Dijkstra’s shortest-path algorithm to compute the shortest path from “B” to all network nodes is as follows
Explanation:
D(A): cost of the least-cost path from the source Vertex to
destination A as of this iteration of the algorithm.
P(A): previous Vertex (neighbor of b) along the current least-cost
path from the source to A.
N' : subset of Vertexes; A is in N' if the least-cost path from the
source to A is definitively known.
Step 0: Initially we
take B as a minimum Weight and highlight that value
Step 1: In
this we consider the minimum weight other than Node B that is at
Node F we have minimum weight so highlight that value
Step 2: In this we consider the minimum weight other than Nodes B
& F that is at Node E we have minimum weight so highlight that
value
Step 3: In this we consider the minimum weight other than Node B,E
& F that is at Node C we have minimum weight so highlight that
value
Step 4: In this we consider the minimum weight other than Node
B,C,E & F that is at Node G we have minimum weight so highlight
that value
Step 5: In this we consider the minimum weight other than Node
B,C,E,F & G that is at Node I we have minimum weight so
highlight that value
Step 6: In this we consider the minimum weight other than Node B,C,E,F,G & I that is at Node D we have minimum weight so highlight that value
Step 7: In this we consider the minimum weight other than Node B,C,D,E,F,G & I that is at Node A we have minimum weight so highlight that value
Step 8: In this we consider the minimum weight other than Node A,B,C,D,E,F,G & I that is at Node H we have minimum weight so highlight that value
Edge | B - A | B - C | B - D | B - E | B - F | B - G | B - H | B - I |
Cost | 7 | 5 | 6 | 2 | 1 | 5 | 12 | 5 |
The shortest path tree from the above routing table.
b) Prim’s Algorithm to find the minimum cost spanning tree of a graph starting at Node (B) as follows
Step 1: All the Nodes connected to (B) will be considered
Edge |
Cost |
|
B-C |
5 |
|
B-E |
2 |
|
B-F |
1(min) |
|
Step 2: All the Nodes connected to (B) & (F) will be considered
Edge |
Cost |
|
B-C |
5 |
|
B-E |
2(min) |
|
F-E |
2 |
|
F-G |
4 |
|
F-I |
4 |
|
Step 3: All the Nodes connected to (B), (E) & (F) will be considered
.Edge |
Cost |
|
B-C |
5 |
|
F-E |
2(min but form Loop) |
|
F-G |
4 |
|
F-I |
4 |
|
E-A |
5 |
|
E-D |
4(min) |
|
E-I |
5 |
Step 4: All the Nodes connected to (B), (D), (E) & (F) will be considered
Edge |
Cost |
|
B-C |
5 |
|
F-G |
4 |
|
F-I |
4 |
|
E-A |
5 |
|
E-I |
5 |
|
D-A |
3(min) |
|
D-H |
6 |
|
Step 5: All the Nodes connected to (A), (B), (D) , (E) & (F) will be considered
Edge |
Cost |
|
B-C |
5 |
|
F-G |
4(min) |
|
F-I |
4 |
|
E-A |
5 |
|
E-I |
5 |
|
D-H |
6 |
|
Step 6: All the Nodes connected to (A), (B), (D) , (E) , (F) & (G) will be considered
Edge |
Cost |
|
B-C |
5 |
|
F-I |
4 |
|
E-A |
5 |
|
E-I |
5 |
|
G-C |
2(min) |
|
G-I |
6 |
|
D-H |
6 |
|
Step 7: All the Nodes connected to to (A), (B), (C), (D) , (E) , (F) & (G) will be considered
Edge |
Cost |
|
B-C |
5 |
|
F-I |
4(min) |
|
E-A |
5 |
|
E-I |
5 |
|
G-I |
6 |
|
D-H |
6 |
|
Step 8: All the Nodes connected to to (A), (B), (C), (D) , (E) , (F),(G) & (I) will be considered
Edge |
Cost |
|
B-C |
5(min but form Loop) |
|
E-A |
5(min but form Loop) |
|
E-I |
5(min but form Loop) |
|
G-I |
6(min but form Loop) |
|
I-H |
7 |
|
D-H |
6(min) |
|
c) Deapth First Search(DFS)
DFS: Step 1:
Output: B C
Step 2:
Output: B C G
Step 3:
Output: B C G I
Step 4:
Output: B C G I H
Step 5:
Output: B C G I H D
Step 6 :
Output: B C G I H D A
Step 7:
Output: B C G I H D A E
Step 8:
Output: B C G I H D A E F
The DFS of a graph starting at Node B is B C G I H D A E F
DFS Tree as follows
Breadth First Search(bFS)
BFS: Step 1:
Output: B C
Step 2:
Output: B C E
Step 3:
Output: B C E F
Step 4:
Output: B C E F G
Step 5:
Output: B C E F G A
Step 6 :
Output: B C E F G A D
Step 7:
Output: B C E F G A D I
Step 8:
Output: B C E F G A D I H
The BFS of a graph starting at Node B is B C E F G A D I H
BFS Tree as follows
4. Consider the following graph: 2 . Starting from node B, please copy the above picture...
discrete 2 question 31 For Esercises 25.28, write the nodes in a breadth first search of the graph for Exercises 21 the node specified 25、 26, g 20. In the computer network in the accompanying figure, the same message is to be broade Dribe ( 21-24 28. e 27. to nodes 4.Е. F and G. One way to do this is to find the shortest path from C to send out multiple copies of the same message. A more etficient...
Consider the weighted graph below: Demonstrate Prim's algorithm starting from vertex A. Write the edges in the order they were added to the minimum spanning tree. Demonstrate Dijkstra's algorithm on the graph, using vertex A as the source. Write the vertices in the order which they are marked and compute all distances at each step.
Question II - Graph Traversal and Minimum Spanning Trees [40 Points] Consider the following graph: B 10 1 4 1 H 9 4 a) Traverse the graph starting from vertex A, and using the Breadth-First Search algorithm. Show the traversal result and the data structure you are using. [10 Points] b) Traverse the graph starting from vertex A, and using the Depth-First Search (Post-order) algorithm. Show the traversal result and the data structure you are using. [10 Points] c) Apply...
For the following questions, use the graph (starting node: S) below: 14. Show DFS traversal. 15. Show BFS traversal. 16. Show the result of a topological sorting of the graph 17. Dijikstra's single source shortest paths for all nodes 18. Show a tabular form soultion of following 0/1 knapsack problem. Value {5,7, 3, 10, 12, 4, 10} Weight {2,3,1,5, 6, 2,4} Total Weight: 12 19. Show a solution to Fractional knapsack problem with the same weight, value, and total weight...
Using the following graph and Dijkstra's algorithm, calculate the shortest distance to each other vertex starting from vertex A. Label all vertices with the total distance (from A). Indicate the order nodes are added to cloud. Draw a Minimum Spanning Tree for the graph. You should label all nodes in the tree, but you do not need to indicate edge weights or total distance. 2 D C L 7 6 2 7 2 A K B 4 7 4 1...
Problem A: Consider the following graph. (a). Find a minimum spanning tree of the graph using Kruskal's algorithm. List the edges in the order they are put into the tree. (b). Apply Prim's algorithm to the same graph starting with node A. List the edges, in order added to the MST. (c). Suppose the cost of every edge touching node A is increased by a constant. Are we guaranteed that the MST remains the MST? Explain.
Run Prim (starting from vertex "f") and Kruskal algorithms on the graph below: 3 2 9 3 . (5 points) Prim's algorithm: draw a table that shows the vertices in the queue at each iteration, similar to example from the notes (2 points) Prim's algorithm: using the table from the first part, list the order in which edges are added to the tree (3 points) Kruskal's algorithm: list the order in which edges are added to the tree
(8) Consider the following problem space with the node "A" as the starting state and the node "H" as the goal state. Please describe how breadth-first search and depth-first search is working with your problem space, and list the order that the nodes are traversed under these two search algorithms. (8) Consider the following problem space with the node "A" as the starting state and the node "H" as the goal state. Please describe how breadth-first search and depth-first search...
2. This question concerns the graph G shown below. (a) Mark the spanning tree for G obtained by performing a depth-first search starting at the vertex A, and using the convention that nearby vertices should be explored in a counter-clockwise fasion, beginning with east; so E comes first, then NE, then N, ... (b) Mark the spanning tree for G obtained by performing a breadth-first search starting at the vertex A, and using the convention that nearby vertices should be...
2. This question concerns the graph G shown below. (a) Mark the spanning tree for G obtained by performing a depth-first search starting at the vertex A, and using the convention that nearby vertices should be explored in a counter-clockwise fasion, beginning with east; so E comes first, then NE, then N, ... (b) Mark the spanning tree for G obtained by performing a breadth-first search starting at the vertex A, and using the convention that nearby vertices should be...