Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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.

image text in transcribed

image text in transcribed

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

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

More Books

Students also viewed these Databases questions

Question

Understanding Groups

Answered: 1 week ago