Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please help me solve this. The fourth programming project involves writing a program that allows the user to create an undirected graph that is visually

Please help me solve this.
The fourth programming project involves writing a program that allows the user to create an
undirected graph that is visually displayed and to check whether the graph is connected and
whether it has cycles in response to button clicks. In addition, it should provide buttons, when
clicked, display a depth-first or breadth-first graph search. The GUI for the program is shown
below:
The user should be able to add vertices to the graph by left elicking the mouse at the desired
location. The first vertex created should be labeled A and subsequent vertices labeled the next
letter of the alphabet. Edges are added by supplying the vertices in the text fields labeled Vertex
l and Vertex 2 and then clicking the Add Edge button. If the user enters a nonexistent vertex
name, an error message should be displayed in the text field at the bottom.
The four buttons at the bottom should analyze the graph. The Is Connected button should
indicate whether the graph is connected. The Has Cycles button should indicate whether the
graph has cycles. In both cases, an appropriate message should be displayed in the text field at
the bottom. The Depth First Search and the Breadth First Search buttons should display the list
of the vertices resulting from the corresponding search, starting at vertex A.
The program should consist of four classes. The first class should be an immutable class that
defines a vertex of the graph and contains the x and y coordinates of the vertex along with its
name. It should have a constructor and three getter methods.
The second class should be a class that defines the graph. You may use any graph representation
that allows an unlimited number of vertices and edges. It should have the following public
methods
A method to add a vertex
A method to add an edge
A method that checks whether the graph has cycles
A method to check whether the graph is connected
A method that retums a list of vertices resulting from a depth-first graph search
A method that returns a list of vertices resulting from a breadth-first graph search
You may add any other methods as needed.
The third class is should be an extension of the javafx Pane class that visually displays the
graph. It should contain an event handler that responds to mouse clicks that creates new vertices
and a method that is called to draw edges.
The fourth class should contain the main method and should create the GUI including all the
buttons and text fields. It should include event handlers for each of the buttons.
image text in transcribed

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

Modern Database Management

Authors: Jeffrey A. Hoffer Fred R. McFadden

4th Edition

0805360476, 978-0805360479

More Books

Students also viewed these Databases questions

Question

Write short notes on Interviews.

Answered: 1 week ago

Question

LO10.3 Explain how demand is seen by a purely competitive seller.

Answered: 1 week ago