Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2019
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.15 KB | None | 0 0
  1. package hw4;
  2.  
  3. import java.util.Iterator;
  4.  
  5. /**
  6. * Graph represents a mutable, directed, labeled multi-graph. Graphs are a
  7. * collection of nodes and edges, each labeled by a String
  8. *
  9. * Nodes are uniquely defined by their label, no two nodes have the same label
  10. * Edges are directed and are not unique (two edges may be identical)
  11. */
  12. public class Graph {
  13. // private T adjList;
  14.  
  15. // Abstraction function:
  16. // Representation invariant:
  17.  
  18. /**
  19. * @effects Constructs a new, empty Graph (no nodes and no edges)
  20. */
  21. public Graph() {
  22. throw new RuntimeException("Graph constructor is not yet implemented");
  23. }
  24.  
  25. /**
  26. * @param label The String representing the node to be added
  27. * @modifies this
  28. * @effects Adds a node represented by the String label to the graph. If
  29. * node already exists in the graph, does nothing
  30. */
  31. public void addNode(String label) {
  32. throw new RuntimeException("Graph.addNode() is not yet implemented");
  33. }
  34.  
  35. /**
  36. * @param parent The node from which the added edge starts from
  37. * @param child The node to which the added edge goes
  38. * @param label The String which the new edge will be labeled with
  39. * @modifies this
  40. * @effects Adds an edge from parent to child labeled label. If
  41. * either parent or child does not exist, does nothing.
  42. */
  43. public void addEdge(String parent, String child, String label) {
  44. throw new RuntimeException("Graph.addEdge() is not yet implemented");
  45. }
  46.  
  47. /**
  48. * @return Iterator which returns all the nodes in lexicographical order.
  49. */
  50. public Iterator<String> listNodes() {
  51. throw new RuntimeException("Graph.listNodes() is not yet implemented");
  52. }
  53.  
  54. /**
  55. * @param parent The node whose children are to be found
  56. * @return Iterator which returns a list of childNode(edgeLabel) in lexicographic
  57. * order by node name and secondarily by edge label.
  58. */
  59. public Iterator<String> listChildren(String parent) {
  60. throw new RuntimeException("Graph.listChildren() is not yet implemented");
  61. }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement