4th Assignment
4th Assignment
Graph:
Adjacency matrix A:
Q2) Consider the weighted graph G, and assume the nodes are stored in
an array DATA as follows:
DATA:X, Y, S, T
7
3
6 2
(ii)
W=
Q3) Find the matrix Q of shortest paths using Warshall’s algorithm for
the graph given in Q2.
Ans
Q0 =
Using A
Q1 =
Using A & B
Q2 =
Q3 =
Q4) The Web can be modeled as a directed graph. Come up with a graph
traversal algorithm. Make the algorithm non-recursive and breadth-first.
Ans) Many graph algorithms require one to systematically examine the nodes and edges
of a graph G. there are two standard ways that this is done. One way is called a breadth-first
search , and the other is called a depth-first search. The breadth-first search will use a queue
as an auxiliary structure to hold for future processing and analogously.
2. Pushing v3.
The result we get is..by poping the above i.e v6, v5, v3, v4, v2 and v1.
The traversal would be as- v0, v2, v4,v1, v3, v5 and v6.
Ans) Graph:
Incidence matrix:
M =
b) 9614*9614 = 92428996 = 28
5882*5882 = 34597924 = 97
6713*6713 = 45064369 = 64
4409*4409 = 19439281 = 39
1825*1825 = 3330625 = 30