Question: Hi there! I need help creating a new class called BetterDiGraph that implements the EditableDiGraph interface ( code included below ) provided by my teacher.
Hi there! I need help creating a new class called BetterDiGraph that implements the EditableDiGraph interface code included belowprovided by my teacher. There is also more information provided about the assignment included in the photo above.
DO NOT USE ANY STAR IMPORTS OR PACKAGES OTHER THAN THE FOLLOWING:
java.ioBufferedReader
java.ioBufferedWriter
java.ioFile
java.ioFileInputStream
java.ioFileNotFoundException
java.ioFileOutputStream
java.ioFileReader
java.ioInputStreamReader
java.ioIOException
java.ioOutputStreamWriter
java.ioUnsupportedEncodingException
java.util.HashMap
java.util.LinkedList
java.util.NoSuchElementException
Here is EditableDiGraph interface provided:
package edu.serm;
import java.util.NoSuchElementException;
Implements an editable graph with sparse vertex support.
@author Acuna
@version
public interface EditableDiGraph
Adds an edge between two vertices, v and w If vertices do not exist,
adds them first. Does not allow duplicate parallel edges to be created.
@param v source vertex
@param w destination vertex
void addEdgeint v int w;
Adds a vertex to the graph. Does not allow duplicate vertices.
@param v vertex number
void addVertexint v;
Returns the direct successors of a vertex v
@param v vertex
@return successors of v
Iterable getAdjint v;
Number of edges.
@return edge count
int getEdgeCount;
Returns the indegree of a vertex.
@param v vertex
@return indegree.
@throws NoSuchElementException exception thrown if vertex does not exist.
int getIndegreeint v throws NoSuchElementException;
Returns number of vertices.
@return vertex count
int getVertexCount;
Removes edge from graph. If vertices do not exist, does not remove edge.
@param v source vertex
@param w destination vertex
void removeEdgeint v int w;
Removes vertex from graph. If vertex does not exist, does not try to
remove it
@param v vertex
void removeVertexint v;
Returns iterable object containing all vertices in graph.
@return iterable object of vertices
Iterable vertices;
Returns false if the graph contains at least one vertex.
@return boolean
boolean isEmpty;
Returns true if the graph contains a specific vertex.
@param v vertex
@return boolean
boolean containsVertexint 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
