Question: Please answer in JAVA. Thank you. Write a C or C++ or Java program to decide whether a given undirected graph is connected. If you

Please answer in JAVA. Thank you.Please answer in JAVA. Thank you. Write a C or C++ or

Write a C or C++ or Java program to decide whether a given undirected graph is connected. If you prefer to use another programming language, please let me know. Concept of connected graphs can be found at or 1. Your program should be a console program and should take one command line argument which is the input graph file name. Your program should work as long as the graph file is in the same directory as your program. Display appropriate messages (e.g. the specified graph is not found; input graph file does not follow the predetermined format; input graph is connected or disconnected) in the console window when a user runs your program. The input graph is given in a text file where each line contains two integers separated by a tab ("\t') character. The two numbers on the first line mean the number of nodes (N) and the number of edges (E) in the graph. Each following line contains the two end points of an edge. The nodes are assumed to be labelled with integers 0,1...,N-1. So you can verify that the file should contain E+1 lines. Two sample graph files (triangle.txt and twoedges.txt) are given. Your program should report nicely when the input graph file is not properly formatted. It should be designed to work for every possible graph with up to 1000 nodes. Possibly some online codes (e.g. functions or classes) are already there to solve this problem. Please write your own code to solve it. Write a C or C++ or Java program to decide whether a given undirected graph is connected. If you prefer to use another programming language, please let me know. Concept of connected graphs can be found at or 1. Your program should be a console program and should take one command line argument which is the input graph file name. Your program should work as long as the graph file is in the same directory as your program. Display appropriate messages (e.g. the specified graph is not found; input graph file does not follow the predetermined format; input graph is connected or disconnected) in the console window when a user runs your program. The input graph is given in a text file where each line contains two integers separated by a tab ("\t') character. The two numbers on the first line mean the number of nodes (N) and the number of edges (E) in the graph. Each following line contains the two end points of an edge. The nodes are assumed to be labelled with integers 0,1...,N-1. So you can verify that the file should contain E+1 lines. Two sample graph files (triangle.txt and twoedges.txt) are given. Your program should report nicely when the input graph file is not properly formatted. It should be designed to work for every possible graph with up to 1000 nodes. Possibly some online codes (e.g. functions or classes) are already there to solve this problem. Please write your own code to solve it

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!