Question: ALL CODES MUST BE WRITTEN IN JAVA MUST USE named files to handle I/O. There will be a penalty for hardcoded file names. The diagram
ALL CODES MUST BE WRITTEN IN JAVA
MUST USE named files to handle I/O. There will be a penalty for hardcoded file names.
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 be adjacent to B if there is also an edge from B to A. It is possible to associate a matrix called the adjacency matrix with a graph. Adj[i,j] = 1 if and only if there is an edge from node i to node j in the graph. If Adj[i,j] = 0 then there is no edge from node i to node j. (You may find it helpful to review the chapter in the text on graphs). We will assume that our adjacency matrices contain only 1s or 0s.
In a graph, one is usually interested in the possible paths from one node to another. The ones which are the most useful are the ones which do not contain loops (cycles), i.e.. do not visit a node more than once. The node sequence 1 2 4 is an example of a path with no loops. 1 2 2 4 1 3 is an example of a with a cycle and a loop. An allowable exception is for the starting and ending node to be the same. 1 2 1 is OK but not 1 2 1 2 4 1.

Instead of using an array to represent the adjacency matrix, you are to use the adjacency matrix to build the graph using a linked allocation.
The recursion is not the most important part of this assignment. You may choose to find the path iteratively. Compare solution using recursion vs using linked allocation and their implementations.
Your program should read an adjacency matrix from the file, build the graph using linked structures, and process the graph to find all the paths, then read an new adjacency matrix, etc., until the file is empty. Make sure to allow for reasonable error situations. Programs which use the adjacency matrix to find the paths will receive no credit under correctness.
You may not use Array lists or List classes from the Java library.
You may store the adjacency matrix in any way you like. You may use any variation of linked strucutres to represent the graph. Justify your implementation and design decisions.
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Input file: input.txt
4 0 1 1 0 1 1 1 1 1 0 0 0 1 1 0 1 6 0 1 0 1 1 0 1 0 0 1 1 0 0 0 1 0 0 1 0 0 0 0 1 0 1 0 0 0 0 0 0 0 1 0 0 1 3 0 1 1 1 0 1 1 1 0
I have only the code using recursive to represent the adjacency matrix. need code to do what the assignment asked for
"To Nodes" 0 110 Adjacency "From11 1 1 Matrix Nodes 1 0 0 0 4 "To Nodes" 0 110 Adjacency "From11 1 1 Matrix Nodes 1 0 0 0 4
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
