Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using java do the following: Implement the following simple graph that has stable number of nodes (that is, number of nodes will not change). However,

Using java do the following:

Implement the following simple graph that has stable number of nodes (that is, number of nodes will not change). However, the links (edges) shown are initial edges and may change later. You are allowed to use any data structure that you deem suitable. Each node in the graph is identified by the content (that is, letters A through G). Note: degree of a node is the number of edges connected to the node The initial graph is as follows: Programming: Your main() method should be interactive (menu driven) and should give the following options to a user: G A C D E F B

i) Display degree of a chosen node. This option should prompt the user to input a node. Once the user type the node, say C, the program displays degree of C which is 5 in this case.

ii) Display list of nodes adjacent to a chosen node. This option should prompt the user to input a node. Once the user type the node, say F, the program displays list of nodes adjacent to F which are A, E, and G in this case.

iii) Drop an edge between a chosen pair of nodes. This option should prompt the user to enter a pair of nodes. Once the user specifies two nodes the program should made appropriate changes in the graph. Output of this option: if there is no existing edge between user specified pair of nodes, an error message like, No edge exists between these nodes. Nothing to delete. should be displayed. If there is an existing edge then a message like Edge dropped successfully should be displayed.

iv) Add an edge between a chosen pair of nodes. This option should prompt the user to enter a pair of nodes. Once the user specifies two nodes the program should made appropriate changes in the graph. Output of this option: if there is no existing edge between user specified pair of nodes then a message similar to Edge added successfully should be displayed. If there is already an edge between the nodes, an error message like, Edge exists between these nodes. Nothing to add. should be displayed.

v) Quit The program should start with the menu and the user should be able to choose any option from the menu. The menu should keep coming back, after completing each user choice, until the user selects Quit option.

vi ) Add another menu feature that allows user to check visual representation of the graph at any stage. To implement this feature, knowledge of Java GUI may be needed.

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

Students also viewed these Databases questions