Answered step by step
Verified Expert Solution
Question
1 Approved Answer
java numVertices( ): Returns the number of vertices of the graph. vertices ( ): Returns an iteration of all the vertices of the graph. numEdges(
java
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. (a) (b) Figure 14.7: (a) An undirected graph G; (b) a schematic representation of the auxiliary adjacency matrix structure for G, in which n vertices are mapped to indices 0 to n1. Although not diagrammed as such, we presume that there is a unique Edge instance for each edge, and that it maintains references to its endpoint vertices. We also assume that there is a secondary edge list (not pictured), to allow the edges() method to run in O(m) time, for a graph with m edgesStep 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