Question
Java code and no JOption Pane please. Use the author's version of SimpleGraph (attached) as your starting point and add the methods requested. For part
Java code and no JOption Pane please.
Use the author's version of SimpleGraph (attached) as your starting point and add the methods requested. For part A of #36, the pseudocode represents your up front thinking on this problem. Be sure to test your programs
36. We wish to expand the class SimpleGraph, shown in Figure 9.14, to include methods to delete a vertex, delete an edge, fetch a vertex, fetch an edge, update an edge, update a vertex.
a. Give the pseudocode of the methods' algorithms.
b. Extend the code of the class SimpleGraph, to include the new methods and write a simple application to demonstrate they function properly.
37. Modify the class SimpleGraph so that it can store a weighted graph and expand its methods to include those mentioned in Exercise 36.
Figure 9.14
1 class SimpleGraph /I a directed graph, (digraph) 2. Listing vertex[ the reference to the vertex array int edge II reference to the adjacency matrix array int max, numberOfVertices; public SimpleGraph (int n) vertexnew Listing[n] allocation of the vertex array 6 8 10 edgenew intnn adjacency matrix initialized to zeros max n numberOfVertices0; public boolean insertVertex (int vertexNumber, Listing newListing) 11.if (vertexNumbermax) I the graph is full 12 return false vertex[vertexNumber]newListing.deepCopy return true; I end insertVertex method numberofVertices++ 14 16 17. 18 public boolean insertEdge (int fromVertex, int toVertex) { if (vertex(fromvertex] == null II vertex(tovertex] == null) return false; /I nonexistent vertex edge[fromVertex[toVertex]1; return true; 20 21.I end insertEdge method public void showVertex (int vertexNumber) System.out.printin(vertex[vertexNumber]); I end showVertex method 23 24 25 26 27. 28 29 30 31. i end of class SimpleGraph public void showEdges (int vertexNumber) emanating from vertexNumber { for(int column 0; columnStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started