Answered You can hire a professional tutor to get the answer.

QUESTION

The diagram below is an example of a directed graph. Each edge has an arrow denoting its direction. Node B is considered adjacent to node A if there...

Path from 1 to 1:

           1-2-1, 1-3-1, 1-2-3-1, 1-3-2-1

Path from 1 to 2:

           1-2, 1-3-2

Path from 1 to 3:

           1-3,1-2-3

Path from 2 to 1:

           Xxxxxxxxxxx

Path from 2 to 2:

           Xxxxxxxxxxxx

Path from 2 to 3:

           Xxxxxxxxxxxxx

Path from 3 to 1:

           Xxxxxxxxxxxx

Path from 3 to 2:

           Xxxxxxxxxxxx

Path from 3 to 3:

           xxxxxxxxxxxx

The diagram below is an example of a directed graph. Each edge has an arrow denoting its direction.Node B is considered adjacent to node A if there is a directed edge from A to B. A will only beadjacent to B if there is also an edge from B to A. It is possible to associate a matrix called theadjacency matrix with a graph. Adj[i,j] = 1 if and only if there is an edge from node i to nodej in thegraph. lfAdj[i,j] = D then there is no edge from node i to node j. (You may find it helpful to review thechapter in the text on graphs). We will assume that our adjacency matrices contain only 1's or 0’s. In a graph, one is usually interested in the possible paths from one node to another. The ones whichare the most useful are the ones which do not contain loops (cycles), i.e.. do not visit a node morethan once. The node sequence 1 2 4 is an example of a path with no loops. 1 2 2 41 3 is an example of a with a cycle and a loop. An allowable exception is for the starting and ending node tobethe same. 121 isOKbutnot1 21 241. "To Nodes" O 1 1 O AdjacencyMatrix Write a program to read in the number of nodes in the graph and the corresponding adjacencymatrix, one row at a time. Echo the adjacency matrix to your output file. The program should use recursion to find and list all possible non-looping paths between all possible pairs of nodes. It is ok ifthe start and end nodes are the same but othenNise the nodes should not repeat within the path. If no path exists for a particular pair of nodes then print 'No Path Found'. Check out all possible paths in each graph. See the attached file for the required input. Make up some other graphs as additionalinput. You will lose points for having insufficient HQ. The recursion is the most important part ofthis assignment. Use an array to store the adjacencymatrix. Consider why it is appropriate. You may not use ArrayLists. Consider an iterative solution aspart ofyour analysis. What impact would that have on your data strucutres. Remember, you are responsible for showing that your program does all that it is supposed to do. Ifyou put in any special features, you need to have an l/O set which demonstrates the features Your program should read an adjacency matrix from the file and process the graph to find all the paths, then read an new adjacency matrix, until the file is empty. Make sure to allow for reasonableerror situations.
Show more
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question