Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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.
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 itStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started