Guest User

Untitled

a guest
Nov 25th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5.79 KB | None | 0 0
  1. public interface Edge<
  2.         T,
  3.         EP extends Edge.Endpoint<T>
  4.       > extends Serializable, Cloneable, XmlSerializable<EdgeXml, Object>, ContextReporter
  5. {
  6.     interface Endpoint<
  7.             T
  8.           >
  9.     {
  10.         Set<Edge.Endpoint<T>> getNeighbors();
  11.         Set<Edge.Endpoint<T>> getTraversableNeighborsTo();
  12.         Set<Edge.Endpoint<T>> getTraversableNeighborsFrom();
  13.         boolean isTraversable();
  14.         boolean isTraversable(final Edge.Endpoint<T> destination);
  15.         boolean isTraversable(final T destination);
  16.         T getTarget();
  17.     };
  18.  
  19.     Set<EP> getEndPoints();
  20.     Set<EP> getEndPoints(final T node);
  21.     boolean contains(final T node);
  22.     Set<T> getTargets();
  23.     Set<T> getNeighbors(final T source);
  24.     Set<T> getTraversableFrom(final T source);
  25.     Set<T> getTraversableTo(final T destination);
  26.     boolean isTraversable(final T source, final T destination);
  27.     int getDegree();
  28. }
  29.  
  30. =========================================================
  31.  
  32.  
  33. public interface Graph<
  34.         PA,
  35.         N extends PA,
  36.         E extends Edge<N,? extends Edge.Endpoint<N>>,
  37.         NEP extends Graph.NodeEndpoint<N, E>,
  38.         EEP extends Graph.EdgeEndpoint<N, E>
  39.       > extends Edge<PA,Graph.Endpoint<N,E,PA>>, Serializable, Cloneable, ContextReporter
  40. {
  41.     interface Endpoint<
  42.         ON,
  43.         OE extends Edge<ON,? extends Edge.Endpoint<? extends ON>>,
  44.         T
  45.       > extends Edge.Endpoint<T>
  46.     {
  47.         Set<Graph.Endpoint<ON,OE,T>> getAdjacent();
  48.         Set<Graph.Endpoint<ON,OE,T>> getTraversableAdjacentTo();
  49.         Set<Graph.Endpoint<ON,OE,T>> getTraversableAdjacentFrom();
  50.  
  51.         Set<Graph.NodeEndpoint<ON, OE>> getAdjacentNodes();
  52.         Set<Graph.NodeEndpoint<ON, OE>> getTraversableAdjacentNodesTo();
  53.         Set<Graph.NodeEndpoint<ON, OE>> getTraversableAdjacentNodesFrom();
  54.  
  55.         Set<Graph.EdgeEndpoint<ON, OE>> getAdjacentEdges();
  56.         Set<Graph.EdgeEndpoint<ON, OE>> getTraversableAdjacentEdgesTo();
  57.         Set<Graph.EdgeEndpoint<ON, OE>> getTraversableAdjacentEdgesFrom();
  58.     };
  59.  
  60.     interface NodeEndpoint<
  61.           ON,
  62.           OE extends Edge<ON,? extends Edge.Endpoint<? extends ON>>
  63.       > extends Graph.Endpoint<ON,OE,ON>
  64.     {
  65.     };
  66.  
  67.     interface EdgeEndpoint<
  68.             ON,
  69.             OE extends Edge<ON,? extends Edge.Endpoint<? extends ON>>
  70.         > extends Graph.Endpoint<ON,OE,OE>
  71.     {
  72.     };
  73.  
  74.     Set<EEP> getEdgeEndpoints();
  75.     Set<EEP> getEdgeEndpoints(E edge);
  76.  
  77.     Set<NEP> getNodeEndpoints();
  78.     Set<NEP> getNodeEndpoints(N node);
  79.  
  80.     /**
  81.      * Get a set of all nodes in the graph.
  82.      *
  83.      * @return An unmodifiable set of all nodes in the graph.
  84.      * @since 2.0
  85.      */
  86.     Set<N> getNodes();
  87.     /**
  88.      * Get a set of all edges in the graph. Two edges in the set, and in the graph,
  89.      * may have the same end points unless equals in the edges used by this graph
  90.      * restrict that possiblity.
  91.      *
  92.      * @return An unmodifiable set of a all edges in the graph.
  93.      * @since 2.0
  94.      */
  95.     Set<E> getEdges();
  96.     /**
  97.      * Get a list of all nodes adjacent to the specified node. All edges connected
  98.      * to this node has its other end points added to the list returned. The
  99.      * specified node itself will appear in the list once for every loop. If there
  100.      * are multiple edges connecting node with a particular end point it will
  101.      * appear multiple times in the list, once for each hop to the end point.
  102.      *
  103.      * @param node The whose neighbors are to be returned.
  104.      * @return A list of all nodes adjacent to the specified node, empty set if the
  105.      *         node has no edges.
  106.      * @since 2.0
  107.      */
  108.     Set<N> getAdjacentNodes(N node);
  109.     /**
  110.      * Get a set of all edges which is connected to node (adjacent). You may not be
  111.      * able to traverse from the specified node to all of these edges returned. If
  112.      * you only want edges you can traverse then see getTraversableAdjacentEdges.
  113.      *
  114.      * @param node the end point for all edges to retrieve.
  115.      * @return An unmodifiable set of all edges that has node as an end point.
  116.      * @throws IllegalArgumentException if specified node is not in the graph.
  117.      * @since 2.0
  118.      */
  119.     Set<E> getAdjacentEdges(N node);
  120.  
  121.     Set<E> getTraversableEdgesFrom(final N source);
  122.     Set<E> getTraversableEdgesFrom(final E source);
  123.     Set<E> getTraversableEdgesTo(final N destination);
  124.     Set<E> getTraversableEdgesTo(final E destination);
  125.  
  126.     Set<N> getTraversableNodesFrom(final N source);
  127.     Set<N> getTraversableNodesFrom(final E source);
  128.     Set<N> getTraversableNodesTo(final N destination);
  129.     Set<N> getTraversableNodesTo(final E destination);
  130.  
  131.     Set<E> getTraversableAdjacentEdgesFrom(final N source);
  132.     Set<E> getTraversableAdjacentEdgesFrom(final E source);
  133.     Set<E> getTraversableAdjacentEdgesTo(final N destination);
  134.     Set<E> getTraversableAdjacentEdgesTo(final E destination);
  135.  
  136.     Set<N> getTraversableAdjacentNodesFrom(final N source);
  137.     Set<N> getTraversableAdjacentNodesFrom(final E source);
  138.  
  139.     /**
  140.      * Get a list of all reachable nodes adjacent to node. All edges connected to
  141.      * node and is traversable from node will have its destination node(s) added to
  142.      * the returned list. node itself will appear in the list once for every loop.
  143.      * If there are multiple edges connecting node with a particular end point then
  144.      * the end point will appear multiple times in the list, once for each hop to
  145.      * the end point.
  146.      *
  147.      * @param destination The whose traversable neighbors are to be returned.
  148.      * @return A list of all nodes adjacent to the specified node and traversable
  149.      *         from the spevified node, empty set if the node has no edges.
  150.      * @since 2.0
  151.      */
  152.     Set<N> getTraversableAdjacentNodesTo(final N destination);
  153.  
  154.     /**
  155.      * Get a set of all edges which you can traverse from node. Of course node will
  156.      * always be an end point for each edge returned. Throws an
  157.      * IllegalArgumentException if node is not in the graph.
  158.      *
  159.      * @param destination edges returned will be traversable from this node.
  160.      * @return An unmodifiable set of all edges that can be traversed from node.
  161.      * @since 2.0
  162.      */
  163.     Set<N> getTraversableAdjacentNodesTo(final E destination);
  164. }
Add Comment
Please, Sign In to add comment