Question: IN JAVA PLEASE Example Sample OUTPUT: Enter a URL: https:// ........ The number of vertices is 6 0 (0): (0, 1) (0, 2) 1 (1):
IN JAVA PLEASE

Example Sample OUTPUT:
Enter a URL: https:// ........ The number of vertices is 6 0 (0): (0, 1) (0, 2) 1 (1): (1, 0) (1, 3) 2 (2): (2, 0) (2, 3) (2, 4) 3 (3): (3, 1) (3, 2) (3, 4) (3, 5) 4 (4): (4, 2) (4, 3) (4, 5) 5 (5): (5, 3) (5, 4) The graph is connected
*28.1 (Test whether a graph is connected) Write a program that reads a graph from a file and determines whether the graph is connected. The first line in the file contains a number that indicates the number of vertices (n). The vertices are labeled as 0, 1 n -1. Each subsequent line, with the format u v 1 v 2. describes edges (u, v 1), u, v2), and so on Figure 28.210 gives the examples of two files for their corresponding graphs. File File 0 1 0 1 2 3 0 1 2 1 0 3 1 0 3 O 3 20 3 4 2 0 3 3 0 1 2 3 1 2 4 5 2 3 4 2 3 5 4 5 5 3 4 5 4 5 (b) (a) Figure 28.21 The vertices and edges of a graph can be stored in a file. Your program should prompt the user to enter a URL for the file, then it should read data from the file, create an instance g of UnweightedGraph, invoke g. prin Edges to display all edges, and invoke dfs to obtain an instance tree of Unweighted Graph V SearchTree. If tree getNumberofVertices Found s the same as the number of vertices in the graph, the graph is connected. Here is a sample run of the program
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
