Question

This question needs to be done using pseudocode (not any particular programming language). Thanks

Consider an unweighted, undirected graph G = 〈V, E). The neighbourhood of a node u E V in the graph is the set of all nodes t

0 0
Add a comment Improve this question Transcribed image text
Answer #1

a)

function(G)

//n is number of vertices or equal to V

deg[n]

//calculate degree of each vertex

for i=0 to i=n-1

deg[i]=len(adjacency_list[i])

neighbourhood_degree[n]

//for each vertex calculate it neighbourhood degree

for i=0 to n-1

//neighbourhood[i] is sum of degree of all vertices in adjacency_list of i

for j=0 to len(adjacency_list[i]-1)

neighbour_degree[i]+=degree[adjacency_list[i][j]]

return neighbourhood_degree

The time complexity of algorithm is O(V+E)

b)The time complexity of this part will be O(V2)

pseudo code

function neighbourhood_degree(G)

degree[n]

//calculate degree of each vertex

//in adjacency matrix one has to traverse each vertex and check if it has edge with that edge or not

//this operation take n2

for i=0 to n-1

for j=0 to n-1

if adjacency_matrix [i][j] is non zero

degree[i]+=1

neighbourhood_degree[n]

//calculate neighbourhood_degree of each vertex

for i=0 to n-1

for j=0 to j=n-1

//if there is a edge between i and j

//add the degree[j] to neighbourhood of i

if adjacency_matrix[i][j] is non zero

neighbourhood_degree[i]+=degree[j]

return neighbourhood_degree

Add a comment
Know the answer?
Add Answer to:
Consider an unweighted, undirected graph G = 〈V, E). The neighbourhood of a node u E V in the gr...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Consider an unweighted, undirected graph G = 〈V, E). The neighbourhood of a node u E V in the gr...

    Consider an unweighted, undirected graph G = 〈V, E). The neighbourhood of a node u E V in the graph is the set of all nodes that are adjacent (or directly connected) to v. Subsequently, we can define the neighbourhood degree of the node v as the sum of the degrees of all its neighbours (those nodes that are directly connects to v) (a) Design an algorithm that returns a list containing the neighbourhood degree for each node v V,...

  • 114points Let G- (V,E) be a directed graph. The in-degree of a vertex v is the...

    114points Let G- (V,E) be a directed graph. The in-degree of a vertex v is the number of edges (a) Design an algorithm (give pseudocode) that, given a vertex v EV, computes the in-degree of v under (b) Design an algorithm (give pseudocode) that, given a vertex v E V, computes the in-degree of v incident into v. the assumption that G is represented by an adjacency list. Give an analysis of your algorithm. under the assumption that G is...

  • 2. Let G = (V, E) be an undirected connected graph with n vertices and with...

    2. Let G = (V, E) be an undirected connected graph with n vertices and with an edge-weight function w : E → Z. An edge (u, v) ∈ E is sparkling if it is contained in some minimum spanning tree (MST) of G. The computational problem is to return the set of all sparkling edges in E. Describe an efficient algorithm for this computational problem. You do not need to use pseudocode. What is the asymptotic time complexity of...

  • 2. Consider the (undirected) graph G having the following vertex set Vand edge set E. V-0,1,2,3,4,5,6,7,8,9...

    2. Consider the (undirected) graph G having the following vertex set Vand edge set E. V-0,1,2,3,4,5,6,7,8,9 E- 0,1,10,2), 11,2;, 12,4), 12,3), 13,4), (4,5), {5.6,, 14,6, 2,7) e) [8pts] Show the action of BFS starting at vertex 2. Show action of queue, parent array implementation of BFS spanning tree and display nodes in order they are traversed. Choose next node as it occurs in the adjacency list.

  • 2) Let G ME) be an undirected Graph. A node cover of G is a subset...

    2) Let G ME) be an undirected Graph. A node cover of G is a subset U of the vertex set V such that every edge in E is incident to at least one vertex in U. A minimum node cover MNC) is one with the lowest number of vertices. For example {1,3,5,6is a node cover for the following graph, but 2,3,5} is a min node cover Consider the following Greedy algorithm for this problem: Algorithm NodeCover (V,E) Uempty While...

  • Suppose you are given an undirected graph G. Find a pair of vertices (u, v) in...

    Suppose you are given an undirected graph G. Find a pair of vertices (u, v) in G with the largest number of common adjacent vertices (neighbors). Give pseudocode for this algorithm and show the worst-case running time.

  • Exercise (15 points) Consider an adjacency-list representation of a directed graph G=(V.E). a) Propose in pseudocode...

    Exercise (15 points) Consider an adjacency-list representation of a directed graph G=(V.E). a) Propose in pseudocode an algorithm A to compute the in-degree of each vertex in V. b) What is the time complexity of A? c) Propose in pseudocode an algorithm B to compute the out-degree of each vertex in V. d) What is the time complexity of B?

  • 2 Node removal Consider the following specifications: Algorithm 1 Removes node vk from graph G represented...

    2 Node removal Consider the following specifications: Algorithm 1 Removes node vk from graph G represented as an adjacency matrix A Require: A E {0,1}"x", kEN, k<n Ensure: A' E {0,1)(n-1)×(1-1) 1: function NODEREMOVAL(A,k) 2: ... 3: return A 4: end function The function accepts an adjacency matrix A, which represents a graph G, and an integer k, and returns adjacency matrix A', representing graph G', that is the result of removing node the k-th node us from G. Question:...

  • Let G = (V;E) be an undirected and unweighted graph. Let S be a subset of the vertices. The graph...

    Let G = (V;E) be an undirected and unweighted graph. Let S be a subset of the vertices. The graph induced on S, denoted G[S] is a graph that has vertex set S and an edge between two vertices u, v that is an element of S provided that {u,v} is an edge of G. A subset K of V is called a killer set of G if the deletion of K kills all the edges of G, that is...

  • Reachability. You are given a connected undirected graph G = (V, E ) as an adjacency...

    Reachability. You are given a connected undirected graph G = (V, E ) as an adjacency list. The graph G might not be connected. You want to fill-in a two-dimensional array R[,] so that R[u,v] is 1 if there is a path from vertex u to vertex v. If no such path exists, then R[u,v] is 0. From this two-dimensional array, you can determine whether vertex u is reachable from vertex v in O(1) time for any pair of vertices...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT