Question: In Java implement the Graph ADT. That means implementing all the 15 functions and run your codes to create the graph in Figure 14.2. Your

In Java implement the Graph ADT. That means implementing all the 15 functions and run your codes to create the graph in Figure 14.2. Your program should print out the graph in Figure 14.2. You can use that kind of matrix in Figure 14.7 (b) to represent graph.

In Java implement the Graph ADT. That means implementing all the 15

functions and run your codes to create the graph in Figure 14.2.

numVertices( ): Returns the number of vertices of the graph. vertices( ): Returns an iteration of all the vertices of the graph. numEdges( ): Returns the number of edges of the graph. edges( ): Returns an iteration of all the edges of the graph. getEdge (u,v) : Returns the edge from vertex u to vertex v, if one exists; otherwise return null. For an undirected graph, there is no difference between getEdge (u,v) and getEdge (v,u). endVertices (e) : Returns an array containing the two endpoint vertices of edge e. If the graph is directed, the first vertex is the origin and the second is the destination. opposite (v,e) : For edge e incident to vertex v, returns the other vertex of the edge; an error occurs if e is not incident to v. outDegree (v) : Returns the number of outgoing edges from vertex v. inDegree (v) : Returns the number of incoming edges to vertex v. For an undirected graph, this returns the same value as does outDegree (v). outgoingEdges (v) : Returns an iteration of all outgoing edges from vertex v. incomingEdges (v) : Returns an iteration of all incoming edges to vertex v. For an undirected graph, this returns the same collection as does outgoingEdges (v). insertVertex (x) : Creates and returns a new Vertex storing element x. insertEdge (u,v,x) : Creates and returns a new Edge from vertex u to vertex v, storing element x; an error occurs if there already exists an edge from u to v. removeVertex (v) : Removes vertex v and all its incident edges from the graph. removeEdge (e) : Removes edge e from the graph

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!