I really appreciate your help! The extra credit would also really help if possible!
/**
* Program for generating kanji component dependency order via topological sort.
*
* @author (your name), Acuna
* @version (version)
*/
public class BaseMain {
/**
* Entry point for testing.
* @param args the command line arguments
*/
public static void main(String[] args) {
//TODO: implement this
//Freebie: this is one way to load the UTF8 formated character data.
//BufferedReader indexReader = new BufferedReader(new InputStreamReader(new FileInputStream(new File("data-kanji.txt")), "UTF8"));
}
}
/**
* Interface for classes providing a topological sort of a digraph.
*
* @author Sedgewick and Wayne, Acuna
*/
public interface TopologicalSort
{
/**
* Returns an iterable object containing a topological sort.
* @return a topological sort.
*/
public Iterable order();
/**
* Returns true if the graph being sorted is a DAG, false otherwise.
* @return is graph a DAG
*/
public boolean isDAG();
}
import java.util.NoSuchElementException;
/**
* Implements an editable graph with sparse vertex support.
*
* @author Acuna
*/
public interface EditableDiGraph {
/**
* Adds an edge between two vertices, v and w. If vertices do not exist,
* adds them first.
*
* @param v source vertex
* @param w destination vertex
*/
void addEdge(int v, int w);
/**
* Adds a vertex to the graph. Does not allow duplicate vertices.
*
* @param v vertex number
*/
void addVertex(int v);
/**
* Returns the direct successors of a vertex v.
*
* @param v vertex
* @return successors of v
*/
Iterable getAdj(int v);
/**
* Number of edges.
*
* @return edge count
*/
int getEdgeCount();
/**
* Returns the in-degree of a vertex.
* @param v vertex
* @return in-degree.
* @throws NoSuchElementException exception thrown if vertex does not exist.
*/
int getIndegree(int 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 removeEdge(int v, int w);
/**
* Removes vertex from graph. If vertex does not exist, does not try to
* remove it.
*
* @param v vertex
*/
void removeVertex(int v);
/**
* Returns iterable object containing all vertices in graph.
*
* @return iterable object of vertices
*/
Iterable vertices();
/**
* Returns true 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 containsVertex(int v);
}