Answered step by step
Verified Expert Solution
Link Copied!

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.image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Probabilistic Databases

Authors: Dan Suciu, Dan Olteanu, Christopher Re, Christoph Koch

1st Edition

3031007514, 978-3031007514

More Books

Students also viewed these Databases questions

Question

Are large batch sizes preferable to small batch sizes Explain?

Answered: 1 week ago

Question

How do Excel Pivot Tables handle data from non OLAP databases?

Answered: 1 week ago