Advertisement
Guest User

Untitled

a guest
Jul 20th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 2.00 KB | None | 0 0
  1. package mypkg;
  2.  
  3. import java.io.IOException;
  4. import java.io.InputStream;
  5. import java.io.OutputStream;
  6. import java.util.List;
  7.  
  8. /**
  9.  * Graph.
  10.  *
  11.  * @author   Radek Oslejsek
  12.  * @version  2011-01-16
  13.  */
  14. public interface IDirectedGraph {
  15.  
  16.     /**
  17.      * Adds a new directed edge to this graph. If this edge already
  18.      * exists in the graph then nothing happens.
  19.      *
  20.      * @param from First node of directed edge
  21.      * @param to Second node of directed edge
  22.      * @throws IllegalArgumentException if some node parameter is null
  23.      */
  24.     void addEdge(Node from, Node to);
  25.    
  26.     /**
  27.      * Removes edge from this graph.
  28.      *
  29.      * @param from First node of the edge to be removed
  30.      * @param to Second node of the edge to be removed
  31.      * @return true on success, false if the edge does not exist
  32.      * @throws IllegalArgumentException if some node parameter is null
  33.      */
  34.     boolean removeEdge(Node from, Node to);
  35.    
  36.     /**
  37.      * @return number of edges in this graph
  38.      */
  39.     int numEdges();
  40.  
  41.     /**
  42.      * Writes graph to given output stream as follows:
  43.      * 1. Data are writen in text mode.
  44.      * 2. Edges are written to single lines in the form "from:to",
  45.      *    where "from" is the name of source node and "to" is the name of
  46.      *    desitation node of directed edge.
  47.      *
  48.      * @param os Output stream
  49.      * @throws IOException on any I/O error
  50.      */
  51.     void save(OutputStream os) throws IOException;
  52.    
  53.     /**
  54.      * Reads directed edges from given input stream and instantiates the graph.
  55.      * For format see the save() method.
  56.      *
  57.      * @param is Input stream
  58.      * @throws IOException on any I/O failure
  59.      */
  60.     void load(InputStream is) throws IOException;
  61.    
  62.     /**
  63.      * Checks whether the given path exists in the graph.
  64.      *
  65.      * @param path List of nodes defining path in graph
  66.      * @return true if path exists in this graph, false otherwise
  67.      */
  68.     boolean pathExists(List<Node> path);
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement