Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using the programming language Java, write a program that determines whether or not an undirected graph is connected or not when given a graph. The

Using the programming language Java, write a program that determines whether or not an undirected graph is connected or not when given a graph. The program should work by taking only on command line argument (this will be the name of the graph file given) and displaying the output in the console. Make sure you include messages (when appropriate) telling the user things like the graph file given does not follow the predetermined format, the graph given cannot be found, or the graph given is connected/not connected in the console when the program is being run.

For the graph file given, it should be a text file and each line should contain two integers separated by a tab. On the first line, the first two numbers represent the number of nodes within the graph, and the other number represents the number of edges in the graph. The rest of the lines in the file contain the two endpoints of an edge. Each node is labeled with integers (0,1 .., n-1) in order to confirm the file contains edges + 1 line (E+1). The program should work for every possible graph given up to 1000 nodes.

If appropriate, the program should let the user know when the input file is not in the correct format.

Two Sample Graph Files are below to ensure the program runs correctly.

prism.txt

3 3

0 1

0 2

1 2

edges.txt

4 2

0 1

2 3

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_2

Step: 3

blur-text-image_3

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

SQL Instant Reference

Authors: Gruber, Martin Gruber

2nd Edition

0782125395, 9780782125399

More Books

Students also viewed these Databases questions

Question

How does this lesson connect to what you learned yesterday?

Answered: 1 week ago

Question

Are look fors being used to provide feedback?

Answered: 1 week ago