In this Java assignment you are to implement a graph G(V, E) searching algorithm that will take two source nodes and outputs all nodes that are reachable from both of these sources. Your program has to read an input file with the following structure:
1. integer number V that specifies how many nodes in the graph
2. a space delimited matrix of V rows and V columns that defines the graph's edges
3. integer number S1 is source 1 for the graph search (the node labels start with 0 to V-1)
4. integer number S2 is source 2 for the graph search (the node labels start with 0 to V-1)
Input File Example:
4
0 0 1 1
1 1 0 0
1 0 1 0
1 0 1 0
3
0
You program's output that would run search on the above graph would be:
0,2,3
Note:
You can use whatever algorithm we went over in the class to solve this problem.
Things to look out for:
cycles are always a problem in graphs
implement a simple cycle check to make sure you are not stuck in an endless loop