Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package hw4;
- import java.util.Iterator;
- /**
- * Graph represents a mutable, directed, labeled multi-graph. Graphs are a
- * collection of nodes and edges, each labeled by a String
- *
- * Nodes are uniquely defined by their label, no two nodes have the same label
- * Edges are directed and are not unique (two edges may be identical)
- */
- public class Graph {
- // private T adjList;
- // Abstraction function:
- // Representation invariant:
- /**
- * @effects Constructs a new, empty Graph (no nodes and no edges)
- */
- public Graph() {
- throw new RuntimeException("Graph constructor is not yet implemented");
- }
- /**
- * @param label The String representing the node to be added
- * @modifies this
- * @effects Adds a node represented by the String label to the graph. If
- * node already exists in the graph, does nothing
- */
- public void addNode(String label) {
- throw new RuntimeException("Graph.addNode() is not yet implemented");
- }
- /**
- * @param parent The node from which the added edge starts from
- * @param child The node to which the added edge goes
- * @param label The String which the new edge will be labeled with
- * @modifies this
- * @effects Adds an edge from parent to child labeled label. If
- * either parent or child does not exist, does nothing.
- */
- public void addEdge(String parent, String child, String label) {
- throw new RuntimeException("Graph.addEdge() is not yet implemented");
- }
- /**
- * @return Iterator which returns all the nodes in lexicographical order.
- */
- public Iterator<String> listNodes() {
- throw new RuntimeException("Graph.listNodes() is not yet implemented");
- }
- /**
- * @param parent The node whose children are to be found
- * @return Iterator which returns a list of childNode(edgeLabel) in lexicographic
- * order by node name and secondarily by edge label.
- */
- public Iterator<String> listChildren(String parent) {
- throw new RuntimeException("Graph.listChildren() is not yet implemented");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement