Question: In this Java programming project you are to implement a graph G(V, E) searching algorithm that will take two source nodes and outputs all nodes

In this Java programming project 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 Vcolumns 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

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.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!