A communication network, such as the Internet, can be modeled as an undirected g
ID: 3795168 • Letter: A
Question
A communication network, such as the Internet, can be modeled as an undirected graph G = (V, E). Here the vertices V are the machines on the network, and the edge set consists of one edge for each pair of machines that are directly connected. We assume that the edges of G are undirected, that is, if there is a direct connection from machine u to machine v, then there is also a direct connection from machine v to machine u.
It is highly desirable for a communication network graph to be connected, so that every machine on the network can communicate, possibly through a series of relays, with any other machine. But networks can change, with some machines failing and other machines being added to the network. It is useful to have a monitoring algorithm that collects information about the current network graph (vertices and edges) at designated times, and determines properties related to connectivity.
(a) Describe (in words and pseudocode) a monitoring algorithm, which does the following. As input, it is given an undirected graph G = (V, E) representing the current network, in adjacency list format. It should output a Boolean saying whether or not G is connected. Your algorithm should run in time O(V + E).
(b) It is very nice if the network is connected, but even if it is, we might worry that it might become disconnected soon. This is likely if the network graph has critical vertices, whose removal would disconnect the graph. That is, u is a critical vertex exactly if there are two other vertices, v and w, for which every connecting path in the graph runs through u (this is equivalent to saying that removing u disconnects the graph, because removing u leaves no path from v to w.)
Describe (in words and pseudocode) a new monitoring algorithm, which does the following. As input, it is given a connected undirected graph G = (V, E) representing the current network, in adjacency list format. It should output a list of all the critical vertices of the graph. Your algorithm should run in time O(V + E).
Explanation / Answer
(a)
We can use DFS traversal to decide connectivity of a graph. A graph is connected if there is a path between any pair of vertices. So, we need to run DFS on graph G (starting at any vertex), if all the nodes of G are visited in the DFS tree, then the graph is connected. This will take O(V + E) time as DFS takes O(V+E) time.
Pseudocode:
S = choose a random vertex in G;
DFS(S);
for each vertex v of G:
{
if v is not visited:
{
return false;
}
}
return true;
b)
we can use DFS to find critical points of a connected graph. A vertex u is critical point if it satisfies any one of the following conditions:
1) u is root of the DFS tree, and it has more than of equal to 2 children.
2) u is non root, and there is a child v of u in DFS tree such that there is back-edge from v to any one of the ancestors of u.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.