Question

3. (10 points) Let G be an undirected graph with nodes vi,..Vn. The adja.- cency matriz representation for G is the nx n matr

Please show work clearly. Thanks

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

    Answer:

    Undirected Graph:

    An undirected graph G is a set of vertices or nodes that are connected together where all the edges are bidirectional. An undirected graph is sometimes called an undirected network. In contrast, a graph where the edges point in a direction is called a directed graph.

    One can define the undirected graph as G= (N, E), consisting of the set N of nodes and the set E of edges, which are unordered pairs of elements of N.

    The most commonly used representation ways of graphs are:

    • Adjacency Matrix
    • Adjacency List

    Adjacency Matrix:

    An adjacency matrix is a square matrix which used to represent a finite graph. The elements of the matrix indicate whether pairs of vertices are adjacent or not in the given graph.

    Adjacency Matrix is basically a 2D array of size nx n where n is the number of vertices in a graph. Let the 2D array be M [][]. A slot M [i][j] = 1 indicates that there is an edge from vertex i to vertex j.

    Adjacency matrix for undirected graph is in always symmetric manner. Adjacency Matrix is also used to represent weighted graphs. If M[i][j] = w, then there is an edge from vertex i to vertex j with weight w.

    The adjacency matrix cell (i,j) contains a “1” if the graph has an edge from vertex i to vertex j.If there is an edge from i to j is undirected then there is also an edge from j to i. Thus, the cell (j,i) contains a value “1” as well. Cell (i,j) is equal to cell (j,i) for all cells.

    A triangle is a set {Vi,Vj,Vk} of 3 distinct vertices so that there is an edge from Vi to Vj, second from Vj to Vk and third from Vk to Vi. These edges form a cycle.

    Algorithm:

    • Determine if an undirected graph G = (V, E) is connected where set of V = n and set of E= m.
    • Find the cycle Vi to Vk through Vj in an undirected graph G.

    1) Initialize all vertices as not visited.

    2) Do following for every vertex 'v'.

           (a) If 'v' is not visited before, call DFSUtil(v)

           (b) Print new line character

    DFSUtil(v)

    1) Mark 'v' as visited.

    2) Print 'v'

    3) Do following for every adjacent 'u' of 'v'.

         If 'u' is not visited, then recursively call DFSUtil(u)

         Check for cycle CyclicUtil(v)

    CyclicUtil(v)

    1) Mark 'v' as visited.

    2) From adjacency Vi to Vk through Vj

                If Vi is visited

                    CyclicUtil(Vi)

                Else

                            Parent (Vi) not equal to Vk ( // If an adjacent is visited and not parent of current vertex, then there is a cycle.)

    Print Cycle

    3) Do following for every adjacent 'Vk' to 'Vi'.

    CyclicUtil(Vk)

    Algorithm's Performance Analysis:

    We have used matrix representation of undirected graph. we allocate n×n nodes of matrix to store node-connectivity information for example M[i][j]=1 if there is edge between nodes i and j, otherwise M[i][j]=0.

    Complexity of an algorithm in Worst Case:

    (1) In terms of nodes n of the graph:

    Adjacency matrix will take O(n2) time cpmplexity.

    (2) In terms of nodes n and number of edges m of the graph:

      Adjacency matrix will take O(n+m) time cpmplexity.

    Add a comment
    Know the answer?
    Add Answer to:
    3. (10 points) Let G be an undirected graph with nodes vi,..Vn. The adja.- cency matriz represent...
    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,...

    • Consider an unweighted, undirected graph G = 〈V, E). The neighbourhood of a node u E V in the gr...

      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 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...

    • Write a program to process a weighted undirected graph as follows.   (a) Read in the number...

      Write a program to process a weighted undirected graph as follows.   (a) Read in the number of vertices V and the number of edges E of the graph followed by its E edges, each in the form u, v, w where 1 <= u, v <= V & w > 0 representing an edge uv with weight w.     (b) Set up and print the adjacency matrix representation of the Graph.     (c) Determine whether the graph is connected.    ...

    • Problem 3's picture are given below. 5. (a) Let G = (V, E) be a weighted connected undirected simple graph. For n...

      Problem 3's picture are given below. 5. (a) Let G = (V, E) be a weighted connected undirected simple graph. For n 1, let cycles in G. Modify {e1, e2,.. . ,en} be a subset of edges (from E) that includes no Kruskal's algorithm in order to obtain a spanning tree of G that is minimal among all the spanning trees of G that include the edges e1, e2, . . . , Cn. (b) Apply your algorithm in (a)...

    • IN JAVA Given is a weighted undirected graph G = (V, E) with positive weights and...

      IN JAVA Given is a weighted undirected graph G = (V, E) with positive weights and a subset of its edges F E. ⊆ E. An F-containing spanning tree of G is a spanning tree that contains all edges from F (there might be other edges as well). Give an algorithm that finds the cost of the minimum-cost F-containing spanning tree of G and runs in time O(m log n) or O(n2). Input: The first line of the text file...

    • Other answer is incorrect Problem 1. (15 points) Consider an undirected connected graph G = (V,...

      Other answer is incorrect Problem 1. (15 points) Consider an undirected connected graph G = (V, E) with edge costs ce > 0 for e € E which are all distinct. (a) [8 points). Let E' CE be defined as the following set of edges: for each node v, E' contains the cheapest of all edges incident on v, i.e., the cheapest edge that has v as one of its endpoints. Is the graph (V, E') connected? Is it acyclic?...

    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