Question: The Graph class below represents an UNDIRECTED graph. Complete the constructor and methods. class Graph { Map > adjacencies; public Graph ( ) { }
The Graph class below represents an UNDIRECTED graph. Complete the constructor and methods.
class Graph
Map adjacencies;
public Graph
public void addVertexV v
ensures that vertex v is in the graph
public void addEdgeV v V v
adds an edge between vertices v and v
throws an IllegalArgumentException if
either v or v are not in the graph
public boolean hasEdgeV v V v
returns true if there is an edge between v and v
and false otherwise. Returns false
in all other cases this doesn't throw an exception
public void removeEdgeV v V v
ensures that the graph does not
have an edge between vertices v and v
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
