3. (6) The directed graph below with node 1, 2, 3 in orange color and directed edges in blue color. (Note, there is an...
For a directed graph the in-degree of a vertex is the number of edges it has coming in to it, and the out- degree is the number of edges it has coming out. (a) Let G[i,j] be the adjacency matrix representation of a directed graph, write pseudocode (in the same detail as the text book) to compute the in-degree and out-degree of every vertex in the Page 1 of 2 CSC 375 Homework 3 Spring 2020 directed graph. Store results...
5. The in-degree of a vertex in a directed graph is the number of edges directed into it. Here is an algorithm for labeling each vertex with its in-degree, given an adjacency-list representation of the graph. for each vertex i: i.indegree = 0 for each vertex i: for each neighbor j of i: j.indegree = j.indegree + 1 Label each line with a big-bound on the time spent at the line over the entire run on the graph. Assume that...
CS 3345: Data Structures and Algorithms -Homework 7 1. These three questions about graphs all have the same subparts. Note that for parts (iii), (iv), and (v), your answer should be in terms of an arbitrary k, not assuming k-4 a) Suppose a directed graph has k nodes, where there are two lspecial" nodes. One has an edge from itself to every non-special node and the other has an edge from every non-special node to itself. There are no other...
5. Suppose we are given an unweighted, directed graph G with n vertices (labelled 1 to n), and let M be the n × n adjacency matrix for G (that is, M (i,j-1 if directed edge (1J) is in G and 0 otherwise). a. Let the product of M with itself (M2) be defined, for 1 S i,jS n, as follows where "." is the Boolean and operator and "+" is the Boolean or operator. Given this definition what does...
Write a program that specifies a simple undirected graph by its “adjacency matrix”. Recall that that the adjacency matrix A is such that A(i, j) = 1 if nodes i and j are adjacent and A(i, j) = 0 otherwise. Let αk(i ,j) be the number of paths of length k between nodes i and j. For instance, the number of paths of length-1 between nodes i and j in a simple undirected graph is 1 if they are adjacent...
Can you please solve this
fully
Question 9 (10 marks) (i) How many vertices and how many edges do each of the following graphs have? [3 marks] (b) C16 (a) K70 (d) K2,5 (ii Suppose you have a graph G with vertices vi, v. vi7. Explain (clearly) how you would use the adjacency matrix A to find a. The number of paths from v to vir of length 12.12 marks] b. The length of a shortest path from vi to...
How would I traverse through this graph? Provide example code, please! class Edge { int src, dest; Edge(int src, int dest) { this.src = src; this.dest = dest; } }; // class to represent a graph object class Graph { // A list of lists to represent adjacency list List<List<Integer>> adj = new ArrayList<>(); // Constructor to construct graph public Graph(List<Edge> edges) { // allocate memory for adjacency list for (int i = 0; i < edges.size(); i++) { adj.add(i,...
Note that for the following question you should use technology to do the matrix calculations. Consider a graph with the following adjacency matrix: 0100 0 1 110011 0 01 0 11 00 0 11 1 01 1 10 0 Assuming the nodes are labelled 1,2,3,4,5,6 in the same order as the rows and columns, answer the folllowing questions: (a) How many walks of length 2 are there from node 4 to itself? (b) How many walks of length 3 are...
Consider the problem of finding the shortest paths in a weighted directed graph using Dijkstra's algorithm. Denote the set of vertices as V, the number of vertices as |V|, the set of edges as E, and the number of edges as |E|. Answer the following questions.Below is a pseudo-code of the algorithm that computes the length c[v] of the shortest path from the start node s to each node v. Answer code to fill in the blank _______ .
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:...