Class OrderedKAryTree<V,E>

All Implemented Interfaces:
DirectedGraph<V,E>, Forest<V,E>, Graph<V,E>, Hypergraph<V,E>, Tree<V,E>, Serializable

public class OrderedKAryTree<V,E> extends AbstractTypedGraph<V,E> implements Tree<V,E>
An implementation of Tree in which each vertex has ≤ k children. The value of 'k' is specified by the constructor parameter. A specific child (edge) can be retrieved directly by specifying the index at which the child is located. By default, new (child) vertices are added at the lowest index available, if no index is specified.
See Also:
  • Field Details

    • edge_vpairs

      protected Map<E,Pair<V>> edge_vpairs
    • vertex_data

      protected Map<V,OrderedKAryTree<V,E>.VertexData> vertex_data
    • height

      protected int height
    • root

      protected V root
    • order

      protected int order
  • Constructor Details

    • OrderedKAryTree

      public OrderedKAryTree(int order)
      Creates a new instance with the specified order (maximum number of children).
      Parameters:
      order - the maximum number of children ("k") that any vertex can have
  • Method Details

    • getFactory

      public static <V, E> com.google.common.base.Supplier<DirectedGraph<V,E>> getFactory(int order)
      Type Parameters:
      V - the vertex type for the graph Supplier
      E - the edge type for the graph Supplier
      Parameters:
      order - the maximum number of children ("k") that any vertex can have
      Returns:
      a Supplier that creates an instance of this graph type.
    • getChildCount

      public int getChildCount(V vertex)
      Description copied from interface: Forest
      Returns the number of children that vertex has in this tree. The children of a vertex are defined as being the successors of that vertex on the respective (unique) shortest paths from the root to those vertices. This is syntactic (maple) sugar for getSuccessorCount(vertex).
      Specified by:
      getChildCount in interface Forest<V,E>
      Parameters:
      vertex - the vertex whose number of children is to be returned
      Returns:
      the number of children that vertex has
      See Also:
    • getChildEdge

      public E getChildEdge(V vertex, int index)
      Parameters:
      vertex - the vertex whose child edge is to be returned
      index - the index of the edge to be returned
      Returns:
      the child edge of vertex at index index, that is, its ith child edge.
    • getChildEdges

      public Collection<E> getChildEdges(V vertex)
      Description copied from interface: Forest
      Returns the edges connecting vertex to its children in this tree. The children of a vertex are defined as being the successors of that vertex on the respective (unique) shortest paths from the root to those vertices. This is syntactic (maple) sugar for getOutEdges(vertex).
      Specified by:
      getChildEdges in interface Forest<V,E>
      Parameters:
      vertex - the vertex whose child edges are to be returned
      Returns:
      the Collection of edges connecting vertex to its children in this tree
      See Also:
    • getChildren

      public Collection<V> getChildren(V vertex)
      Returns an ordered list of vertex's child vertices. If there is no child in position i, then the list will contain null in position i. If vertex has no children then the empty set will be returned.
      Specified by:
      getChildren in interface Forest<V,E>
      Parameters:
      vertex - the vertex whose children are to be returned
      Returns:
      the Collection of children of vertex in this tree
      See Also:
    • getDepth

      public int getDepth(V vertex)
      Description copied from interface: Tree
      Returns the (unweighted) distance of vertex from the root of this tree.
      Specified by:
      getDepth in interface Tree<V,E>
      Parameters:
      vertex - the vertex whose depth is to be returned.
      Returns:
      the depth of the vertex in this tree, or -1 if the vertex is not present in this tree
      See Also:
    • getHeight

      public int getHeight()
      Returns the height of the tree, or -1 if the tree is empty.
      Specified by:
      getHeight in interface Tree<V,E>
      Returns:
      the maximum depth in this tree
      See Also:
    • getParent

      public V getParent(V vertex)
      Description copied from interface: Forest
      Returns the parent of vertex in this tree. (If vertex is the root, returns null.) The parent of a vertex is defined as being its predecessor in the (unique) shortest path from the root to this vertex. This is a convenience method which is equivalent to Graph.getPredecessors(vertex).iterator().next().
      Specified by:
      getParent in interface Forest<V,E>
      Parameters:
      vertex - the vertex whose parent is to be returned
      Returns:
      the parent of vertex in this tree
      See Also:
    • getParentEdge

      public E getParentEdge(V vertex)
      Description copied from interface: Forest
      Returns the edge connecting vertex to its parent in this tree. (If vertex is the root, returns null.) The parent of a vertex is defined as being its predecessor in the (unique) shortest path from the root to this vertex. This is a convenience method which is equivalent to Graph.getInEdges(vertex).iterator().next(), and also to Graph.findEdge(vertex, getParent(vertex)).
      Specified by:
      getParentEdge in interface Forest<V,E>
      Parameters:
      vertex - the vertex whose incoming edge is to be returned
      Returns:
      the edge connecting vertex to its parent, or null if vertex is the root
      See Also:
    • getRoot

      public V getRoot()
      Description copied from interface: Tree
      Returns the root of this tree. The root is defined to be the vertex (designated either at the tree's creation time, or as the first vertex to be added) with respect to which vertex depth is measured.
      Specified by:
      getRoot in interface Tree<V,E>
      Returns:
      the root of this tree
      See Also:
    • getTrees

      public Collection<Tree<V,E>> getTrees()
      Description copied from interface: Forest
      Returns a view of this graph as a collection of Tree instances.
      Specified by:
      getTrees in interface Forest<V,E>
      Returns:
      a view of this graph as a collection of Trees
      See Also:
    • addEdge

      public boolean addEdge(E e, V parent, V child, int index)
      Adds the specified child vertex and edge e to the graph with the specified parent vertex parent. If index is greater than or equal to 0, then the child is placed at position index; if it is less than 0, the child is placed at the lowest available position; if it is greater than or equal to the order of this tree, an exception is thrown.
      Parameters:
      e - the edge to add
      parent - the source of the edge to be added
      child - the destination of the edge to be added
      index - the position at which e is to be added as a child of parent
      Returns:
      true if the graph has been modified
      See Also:
    • addEdge

      public boolean addEdge(E e, V parent, V child)
      Description copied from interface: Graph
      Adds edge e to this graph such that it connects vertex v1 to v2. Equivalent to addEdge(e, new Pair(v1, v2)). If this graph does not contain v1, v2, or both, implementations may choose to either silently add the vertices to the graph or throw an IllegalArgumentException. If this graph assigns edge types to its edges, the edge type of e will be the default for this graph. See Hypergraph.addEdge() for a listing of possible reasons for failure.
      Specified by:
      addEdge in interface Graph<V,E>
      Overrides:
      addEdge in class AbstractGraph<V,E>
      Parameters:
      e - the edge to be added
      parent - the first vertex to be connected
      child - the second vertex to be connected
      Returns:
      true if the add is successful, false otherwise
      See Also:
    • addEdge

      public boolean addEdge(E e, V v1, V v2, EdgeType edge_type)
      Description copied from interface: Graph
      Adds edge e to this graph such that it connects vertex v1 to v2. Equivalent to addEdge(e, new Pair(v1, v2)). If this graph does not contain v1, v2, or both, implementations may choose to either silently add the vertices to the graph or throw an IllegalArgumentException. If edgeType is not legal for this graph, this method will throw IllegalArgumentException. See Hypergraph.addEdge() for a listing of possible reasons for failure.
      Specified by:
      addEdge in interface Graph<V,E>
      Overrides:
      addEdge in class AbstractGraph<V,E>
      Parameters:
      e - the edge to be added
      v1 - the first vertex to be connected
      v2 - the second vertex to be connected
      edge_type - the type to be assigned to the edge
      Returns:
      true if the add is successful, false otherwise
      See Also:
    • getDest

      public V getDest(E directed_edge)
      Description copied from interface: Graph
      If directed_edge is a directed edge in this graph, returns the destination; otherwise returns null. The destination of a directed edge d is defined to be the vertex incident to d for which d is an incoming edge. directed_edge is guaranteed to be a directed edge if its EdgeType is DIRECTED.
      Specified by:
      getDest in interface Graph<V,E>
      Specified by:
      getDest in interface Hypergraph<V,E>
      Parameters:
      directed_edge - the edge whose destination is to be returned
      Returns:
      the destination of directed_edge if it is a directed edge in this graph, or null otherwise
      See Also:
    • getEndpoints

      public Pair<V> getEndpoints(E edge)
      Description copied from interface: Graph
      Returns the endpoints of edge as a Pair.
      Specified by:
      getEndpoints in interface Graph<V,E>
      Parameters:
      edge - the edge whose endpoints are to be returned
      Returns:
      the endpoints (incident vertices) of edge
      See Also:
    • getInEdges

      public Collection<E> getInEdges(V vertex)
      Description copied from interface: Graph
      Returns a Collection view of the incoming edges incident to vertex in this graph.
      Specified by:
      getInEdges in interface Graph<V,E>
      Specified by:
      getInEdges in interface Hypergraph<V,E>
      Parameters:
      vertex - the vertex whose incoming edges are to be returned
      Returns:
      a Collection view of the incoming edges incident to vertex in this graph
      See Also:
    • getOpposite

      public V getOpposite(V vertex, E edge)
      Description copied from interface: Graph
      Returns the vertex at the other end of edge from vertex. (That is, returns the vertex incident to edge which is not vertex.)
      Specified by:
      getOpposite in interface Graph<V,E>
      Overrides:
      getOpposite in class AbstractGraph<V,E>
      Parameters:
      vertex - the vertex to be queried
      edge - the edge to be queried
      Returns:
      the vertex at the other end of edge from vertex
      See Also:
    • getOutEdges

      public Collection<E> getOutEdges(V vertex)
      Description copied from interface: Graph
      Returns a Collection view of the outgoing edges incident to vertex in this graph.
      Specified by:
      getOutEdges in interface Graph<V,E>
      Specified by:
      getOutEdges in interface Hypergraph<V,E>
      Parameters:
      vertex - the vertex whose outgoing edges are to be returned
      Returns:
      a Collection view of the outgoing edges incident to vertex in this graph
      See Also:
    • getPredecessorCount

      public int getPredecessorCount(V vertex)
      Description copied from interface: Graph
      Returns the number of predecessors that vertex has in this graph. Equivalent to vertex.getPredecessors().size().
      Specified by:
      getPredecessorCount in interface Graph<V,E>
      Overrides:
      getPredecessorCount in class AbstractGraph<V,E>
      Parameters:
      vertex - the vertex whose predecessor count is to be returned
      Returns:
      0 if vertex is the root, -1 if the vertex is not an element of this tree, and 1 otherwise
      See Also:
    • getPredecessors

      public Collection<V> getPredecessors(V vertex)
      Description copied from interface: Graph
      Returns a Collection view of the predecessors of vertex in this graph. A predecessor of vertex is defined as a vertex v which is connected to vertex by an edge e, where e is an outgoing edge of v and an incoming edge of vertex.
      Specified by:
      getPredecessors in interface Graph<V,E>
      Specified by:
      getPredecessors in interface Hypergraph<V,E>
      Parameters:
      vertex - the vertex whose predecessors are to be returned
      Returns:
      a Collection view of the predecessors of vertex in this graph
      See Also:
    • getSource

      public V getSource(E directed_edge)
      Description copied from interface: Graph
      If directed_edge is a directed edge in this graph, returns the source; otherwise returns null. The source of a directed edge d is defined to be the vertex for which d is an outgoing edge. directed_edge is guaranteed to be a directed edge if its EdgeType is DIRECTED.
      Specified by:
      getSource in interface Graph<V,E>
      Specified by:
      getSource in interface Hypergraph<V,E>
      Parameters:
      directed_edge - the edge whose source is to be returned
      Returns:
      the source of directed_edge if it is a directed edge in this graph, or null otherwise
      See Also:
    • getSuccessorCount

      public int getSuccessorCount(V vertex)
      Description copied from interface: Graph
      Returns the number of successors that vertex has in this graph. Equivalent to vertex.getSuccessors().size().
      Specified by:
      getSuccessorCount in interface Graph<V,E>
      Overrides:
      getSuccessorCount in class AbstractGraph<V,E>
      Parameters:
      vertex - the vertex whose successor count is to be returned
      Returns:
      the number of successors that vertex has in this graph
      See Also:
    • getSuccessors

      public Collection<V> getSuccessors(V vertex)
      Description copied from interface: Graph
      Returns a Collection view of the successors of vertex in this graph. A successor of vertex is defined as a vertex v which is connected to vertex by an edge e, where e is an incoming edge of v and an outgoing edge of vertex.
      Specified by:
      getSuccessors in interface Graph<V,E>
      Specified by:
      getSuccessors in interface Hypergraph<V,E>
      Parameters:
      vertex - the vertex whose predecessors are to be returned
      Returns:
      a Collection view of the successors of vertex in this graph
      See Also:
    • inDegree

      public int inDegree(V vertex)
      Description copied from interface: Graph
      Returns the number of incoming edges incident to vertex. Equivalent to getInEdges(vertex).size().
      Specified by:
      inDegree in interface Graph<V,E>
      Specified by:
      inDegree in interface Hypergraph<V,E>
      Overrides:
      inDegree in class AbstractGraph<V,E>
      Parameters:
      vertex - the vertex whose indegree is to be calculated
      Returns:
      the number of incoming edges incident to vertex
      See Also:
    • isDest

      public boolean isDest(V vertex, E edge)
      Description copied from interface: Graph
      Returns true if vertex is the destination of edge. Equivalent to getDest(edge).equals(vertex).
      Specified by:
      isDest in interface Graph<V,E>
      Parameters:
      vertex - the vertex to be queried
      edge - the edge to be queried
      Returns:
      true iff vertex is the destination of edge
      See Also:
    • isLeaf

      public boolean isLeaf(V vertex)
      Returns true if vertex is a leaf of this tree, i.e., if it has no children.
      Parameters:
      vertex - the vertex to be queried
      Returns:
      true if outDegree(vertex)==0
    • isPredecessor

      public boolean isPredecessor(V v1, V v2)
      Returns true iff v1 is the parent of v2. Note that if v2 is the root and v1 is null, this method returns true.
      Specified by:
      isPredecessor in interface Graph<V,E>
      Overrides:
      isPredecessor in class AbstractGraph<V,E>
      Parameters:
      v1 - the first vertex to be queried
      v2 - the second vertex to be queried
      Returns:
      true if v1 is a predecessor of v2, and false otherwise.
      See Also:
    • isRoot

      public boolean isRoot(V vertex)
      Returns true if vertex is a leaf of this tree, i.e., if it has no children.
      Parameters:
      vertex - the vertex to be queried
      Returns:
      true if outDegree(vertex)==0
    • isSource

      public boolean isSource(V vertex, E edge)
      Description copied from interface: Graph
      Returns true if vertex is the source of edge. Equivalent to getSource(edge).equals(vertex).
      Specified by:
      isSource in interface Graph<V,E>
      Parameters:
      vertex - the vertex to be queried
      edge - the edge to be queried
      Returns:
      true iff vertex is the source of edge
      See Also:
    • isSuccessor

      public boolean isSuccessor(V v1, V v2)
      Description copied from interface: Graph
      Returns true if v1 is a successor of v2 in this graph. Equivalent to v1.getSuccessors().contains(v2).
      Specified by:
      isSuccessor in interface Graph<V,E>
      Overrides:
      isSuccessor in class AbstractGraph<V,E>
      Parameters:
      v1 - the first vertex to be queried
      v2 - the second vertex to be queried
      Returns:
      true if v1 is a successor of v2, and false otherwise.
      See Also:
    • outDegree

      public int outDegree(V vertex)
      Description copied from interface: Graph
      Returns the number of outgoing edges incident to vertex. Equivalent to getOutEdges(vertex).size().
      Specified by:
      outDegree in interface Graph<V,E>
      Specified by:
      outDegree in interface Hypergraph<V,E>
      Overrides:
      outDegree in class AbstractGraph<V,E>
      Parameters:
      vertex - the vertex whose outdegree is to be calculated
      Returns:
      the number of outgoing edges incident to vertex
      See Also:
    • addEdge

      public boolean addEdge(E edge, Collection<? extends V> vertices, EdgeType edge_type)
      Description copied from interface: Hypergraph
      Adds edge to this graph with type edge_type. Fails under the following circumstances:
      • edge is already an element of the graph
      • either edge or vertices is null
      • vertices has the wrong number of vertices for the graph type
      • vertices are already connected by another edge in this graph, and this graph does not accept parallel edges
      • edge_type is not legal for this graph
      Specified by:
      addEdge in interface Hypergraph<V,E>
      Overrides:
      addEdge in class AbstractGraph<V,E>
      Parameters:
      edge - edge to add to this graph
      vertices - vertices which are to be connected by this edge
      edge_type - type of edge to add
      Returns:
      true if the add is successful, and false otherwise
      See Also:
    • addVertex

      public boolean addVertex(V vertex)
      Description copied from interface: Hypergraph
      Adds vertex to this graph. Fails if vertex is null or already in the graph.
      Specified by:
      addVertex in interface Hypergraph<V,E>
      Parameters:
      vertex - the vertex to add
      Returns:
      true if the add is successful, and false otherwise
      See Also:
    • isIncident

      public boolean isIncident(V vertex, E edge)
      Description copied from interface: Hypergraph
      Returns true if vertex and edge are incident to each other. Equivalent to getIncidentEdges(vertex).contains(edge) and to getIncidentVertices(edge).contains(vertex).
      Specified by:
      isIncident in interface Hypergraph<V,E>
      Overrides:
      isIncident in class AbstractGraph<V,E>
      Parameters:
      vertex - vertex to test
      edge - edge to test
      Returns:
      true if vertex and edge are incident to each other
      See Also:
    • isNeighbor

      public boolean isNeighbor(V v1, V v2)
      Description copied from interface: Hypergraph
      Returns true if v1 and v2 share an incident edge. Equivalent to getNeighbors(v1).contains(v2).
      Specified by:
      isNeighbor in interface Hypergraph<V,E>
      Overrides:
      isNeighbor in class AbstractGraph<V,E>
      Parameters:
      v1 - the first vertex to test
      v2 - the second vertex to test
      Returns:
      true if v1 and v2 share an incident edge
      See Also:
    • containsEdge

      public boolean containsEdge(E edge)
      Description copied from interface: Hypergraph
      Returns true if this graph's edge collection contains edge. Equivalent to getEdges().contains(edge).
      Specified by:
      containsEdge in interface Hypergraph<V,E>
      Parameters:
      edge - the edge whose presence is being queried
      Returns:
      true iff this graph contains an edge edge
      See Also:
    • containsVertex

      public boolean containsVertex(V vertex)
      Description copied from interface: Hypergraph
      Returns true if this graph's vertex collection contains vertex. Equivalent to getVertices().contains(vertex).
      Specified by:
      containsVertex in interface Hypergraph<V,E>
      Parameters:
      vertex - the vertex whose presence is being queried
      Returns:
      true iff this graph contains a vertex vertex
      See Also:
    • findEdge

      public E findEdge(V v1, V v2)
      Description copied from interface: Hypergraph
      Returns an edge that connects this vertex to v. If this edge is not uniquely defined (that is, if the graph contains more than one edge connecting v1 to v2), any of these edges may be returned. findEdgeSet(v1, v2) may be used to return all such edges. Returns null if either of the following is true:
      • v2 is not connected to v1
      • either v1 or v2 are not present in this graph

      Note: for purposes of this method, v1 is only considered to be connected to v2 via a given directed edge e if v1 == e.getSource() && v2 == e.getDest() evaluates to true. (v1 and v2 are connected by an undirected edge u if u is incident to both v1 and v2.)

      Specified by:
      findEdge in interface Hypergraph<V,E>
      Overrides:
      findEdge in class AbstractGraph<V,E>
      Parameters:
      v1 - the first endpoint of the returned edge
      v2 - the second endpoint of the returned edge
      Returns:
      an edge that connects v1 to v2, or null if no such edge exists (or either vertex is not present)
      See Also:
    • findEdgeSet

      public Collection<E> findEdgeSet(V v1, V v2)
      Description copied from interface: Hypergraph
      Returns all edges that connects this vertex to v. If this edge is not uniquely defined (that is, if the graph contains more than one edge connecting v1 to v2), any of these edges may be returned. findEdgeSet(v1, v2) may be used to return all such edges. Returns null if v2 is not connected to v1.
      Returns an empty collection if either v1 or v2 are not present in this graph.

      Note: for purposes of this method, v1 is only considered to be connected to v2 via a given directed edge d if v1 == d.getSource() && v2 == d.getDest() evaluates to true. (v1 and v2 are connected by an undirected edge u if u is incident to both v1 and v2.)

      Specified by:
      findEdgeSet in interface Hypergraph<V,E>
      Overrides:
      findEdgeSet in class AbstractGraph<V,E>
      Parameters:
      v1 - the first endpoint of the returned edge set
      v2 - the second endpoint of the returned edge set
      Returns:
      a collection containing all edges that connect v1 to v2, or null if either vertex is not present
      See Also:
    • getChild

      public V getChild(V vertex, int index)
      Returns the child of vertex at position index in this tree, or null if it has no child at that position.
      Parameters:
      vertex - the vertex to query
      index - the index of the child to return
      Returns:
      the child of vertex at position index in this tree, or null if it has no child at that position
      Throws:
      ArrayIndexOutOfBoundsException - if index is not in the range [0, order-1]
    • getEdgeCount

      public int getEdgeCount()
      Description copied from interface: Hypergraph
      Returns the number of edges in this graph.
      Specified by:
      getEdgeCount in interface Hypergraph<V,E>
      Returns:
      the number of edges in this graph
      See Also:
    • getEdges

      public Collection<E> getEdges()
      Description copied from interface: Hypergraph
      Returns a view of all edges in this graph. In general, this obeys the Collection contract, and therefore makes no guarantees about the ordering of the vertices within the set.
      Specified by:
      getEdges in interface Hypergraph<V,E>
      Returns:
      a Collection view of all edges in this graph
      See Also:
    • getIncidentCount

      public int getIncidentCount(E edge)
      Description copied from interface: Hypergraph
      Returns the number of vertices that are incident to edge. For hyperedges, this can be any nonnegative integer; for edges this must be 2 (or 1 if self-loops are permitted).

      Equivalent to getIncidentVertices(edge).size().

      Specified by:
      getIncidentCount in interface Hypergraph<V,E>
      Overrides:
      getIncidentCount in class AbstractGraph<V,E>
      Parameters:
      edge - the edge whose incident vertex count is to be returned
      Returns:
      the number of vertices that are incident to edge.
      See Also:
    • getIncidentEdges

      public Collection<E> getIncidentEdges(V vertex)
      Description copied from interface: Hypergraph
      Returns the collection of edges in this graph which are connected to vertex.
      Specified by:
      getIncidentEdges in interface Hypergraph<V,E>
      Parameters:
      vertex - the vertex whose incident edges are to be returned
      Returns:
      the collection of edges which are connected to vertex, or null if vertex is not present
      See Also:
    • getIncidentVertices

      public Collection<V> getIncidentVertices(E edge)
      Description copied from interface: Hypergraph
      Returns the collection of vertices in this graph which are connected to edge. Note that for some graph types there are guarantees about the size of this collection (i.e., some graphs contain edges that have exactly two endpoints, which may or may not be distinct). Implementations for those graph types may provide alternate methods that provide more convenient access to the vertices.
      Specified by:
      getIncidentVertices in interface Hypergraph<V,E>
      Overrides:
      getIncidentVertices in class AbstractGraph<V,E>
      Parameters:
      edge - the edge whose incident vertices are to be returned
      Returns:
      the collection of vertices which are connected to edge, or null if edge is not present
      See Also:
    • getNeighborCount

      public int getNeighborCount(V vertex)
      Description copied from interface: Hypergraph
      Returns the number of vertices that are adjacent to vertex (that is, the number of vertices that are incident to edges in vertex's incident edge set).

      Equivalent to getNeighbors(vertex).size().

      Specified by:
      getNeighborCount in interface Hypergraph<V,E>
      Overrides:
      getNeighborCount in class AbstractGraph<V,E>
      Parameters:
      vertex - the vertex whose neighbor count is to be returned
      Returns:
      the number of neighboring vertices
      See Also:
    • getNeighbors

      public Collection<V> getNeighbors(V vertex)
      Description copied from interface: Hypergraph
      Returns the collection of vertices which are connected to vertex via any edges in this graph. If vertex is connected to itself with a self-loop, then it will be included in the collection returned.
      Specified by:
      getNeighbors in interface Hypergraph<V,E>
      Parameters:
      vertex - the vertex whose neighbors are to be returned
      Returns:
      the collection of vertices which are connected to vertex, or null if vertex is not present
      See Also:
    • getVertexCount

      public int getVertexCount()
      Description copied from interface: Hypergraph
      Returns the number of vertices in this graph.
      Specified by:
      getVertexCount in interface Hypergraph<V,E>
      Returns:
      the number of vertices in this graph
      See Also:
    • getVertices

      public Collection<V> getVertices()
      Description copied from interface: Hypergraph
      Returns a view of all vertices in this graph. In general, this obeys the Collection contract, and therefore makes no guarantees about the ordering of the vertices within the set.
      Specified by:
      getVertices in interface Hypergraph<V,E>
      Returns:
      a Collection view of all vertices in this graph
      See Also:
    • removeEdge

      public boolean removeEdge(E edge)
      Description copied from interface: Hypergraph
      Removes edge from this graph. Fails if edge is null, or is otherwise not an element of this graph.
      Specified by:
      removeEdge in interface Hypergraph<V,E>
      Parameters:
      edge - the edge to remove
      Returns:
      true if the removal is successful, false otherwise
      See Also:
    • removeVertex

      public boolean removeVertex(V vertex)
      Description copied from interface: Hypergraph
      Removes vertex from this graph. As a side effect, removes any edges e incident to vertex if the removal of vertex would cause e to be incident to an illegal number of vertices. (Thus, for example, incident hyperedges are not removed, but incident edges--which must be connected to a vertex at both endpoints--are removed.)

      Fails under the following circumstances:

      • vertex is not an element of this graph
      • vertex is null
      Specified by:
      removeVertex in interface Hypergraph<V,E>
      Parameters:
      vertex - the vertex to remove
      Returns:
      true if the removal is successful, false otherwise
      See Also:
    • addEdge

      public boolean addEdge(E edge, Pair<? extends V> endpoints, EdgeType edgeType)
      Description copied from class: AbstractGraph
      Adds edge to this graph with the specified endpoints and EdgeType.
      Specified by:
      addEdge in class AbstractGraph<V,E>
      Parameters:
      edge - the edge to be added
      endpoints - the endpoints to be connected to this edge
      edgeType - the type of edge to add
      Returns:
      true iff the graph was modified as a result of this call