Package edu.uci.ics.jung.graph
Class OrderedKAryTree<V,E>
java.lang.Object
edu.uci.ics.jung.graph.AbstractGraph<V,E>
edu.uci.ics.jung.graph.AbstractTypedGraph<V,E>
edu.uci.ics.jung.graph.OrderedKAryTree<V,E>
- All Implemented Interfaces:
DirectedGraph<V,
,E> Forest<V,
,E> Graph<V,
,E> Hypergraph<V,
,E> Tree<V,
,E> Serializable
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:
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected int
protected int
protected V
protected Map
<V, OrderedKAryTree<V, E>.VertexData> Fields inherited from class edu.uci.ics.jung.graph.AbstractTypedGraph
edge_type
-
Constructor Summary
ConstructorsConstructorDescriptionOrderedKAryTree
(int order) Creates a new instance with the specified order (maximum number of children). -
Method Summary
Modifier and TypeMethodDescriptionboolean
Addsedge
to this graph with the specifiedendpoints
andEdgeType
.boolean
addEdge
(E edge, Collection<? extends V> vertices, EdgeType edge_type) Addsedge
to this graph with typeedge_type
.boolean
Adds edgee
to this graph such that it connects vertexv1
tov2
.boolean
Adds the specifiedchild
vertex and edgee
to the graph with the specified parent vertexparent
.boolean
Adds edgee
to this graph such that it connects vertexv1
tov2
.boolean
Addsvertex
to this graph.boolean
containsEdge
(E edge) Returns true if this graph's edge collection containsedge
.boolean
containsVertex
(V vertex) Returns true if this graph's vertex collection containsvertex
.Returns an edge that connects this vertex tov
.findEdgeSet
(V v1, V v2) Returns all edges that connects this vertex tov
.Returns the child ofvertex
at positionindex
in this tree, ornull
if it has no child at that position.int
getChildCount
(V vertex) Returns the number of children thatvertex
has in this tree.getChildEdge
(V vertex, int index) getChildEdges
(V vertex) Returns the edges connectingvertex
to its children in this tree.getChildren
(V vertex) Returns an ordered list ofvertex
's child vertices.int
Returns the (unweighted) distance ofvertex
from the root of this tree.Ifdirected_edge
is a directed edge in this graph, returns the destination; otherwise returnsnull
.int
Returns the number of edges in this graph.getEdges()
Returns a view of all edges in this graph.getEndpoints
(E edge) Returns the endpoints ofedge
as aPair
.static <V,
E> com.google.common.base.Supplier <DirectedGraph<V, E>> getFactory
(int order) int
Returns the height of the tree, or -1 if the tree is empty.int
getIncidentCount
(E edge) Returns the number of vertices that are incident toedge
.getIncidentEdges
(V vertex) Returns the collection of edges in this graph which are connected tovertex
.getIncidentVertices
(E edge) Returns the collection of vertices in this graph which are connected toedge
.getInEdges
(V vertex) Returns aCollection
view of the incoming edges incident tovertex
in this graph.int
getNeighborCount
(V vertex) Returns the number of vertices that are adjacent tovertex
(that is, the number of vertices that are incident to edges invertex
's incident edge set).getNeighbors
(V vertex) Returns the collection of vertices which are connected tovertex
via any edges in this graph.getOpposite
(V vertex, E edge) Returns the vertex at the other end ofedge
fromvertex
.getOutEdges
(V vertex) Returns aCollection
view of the outgoing edges incident tovertex
in this graph.Returns the parent ofvertex
in this tree.getParentEdge
(V vertex) Returns the edge connectingvertex
to its parent in this tree.int
getPredecessorCount
(V vertex) Returns the number of predecessors thatvertex
has in this graph.getPredecessors
(V vertex) Returns aCollection
view of the predecessors ofvertex
in this graph.getRoot()
Returns the root of this tree.Ifdirected_edge
is a directed edge in this graph, returns the source; otherwise returnsnull
.int
getSuccessorCount
(V vertex) Returns the number of successors thatvertex
has in this graph.getSuccessors
(V vertex) Returns aCollection
view of the successors ofvertex
in this graph.Collection
<Tree<V, E>> getTrees()
Returns a view of this graph as a collection ofTree
instances.int
Returns the number of vertices in this graph.Returns a view of all vertices in this graph.int
Returns the number of incoming edges incident tovertex
.boolean
Returnstrue
ifvertex
is the destination ofedge
.boolean
isIncident
(V vertex, E edge) Returnstrue
ifvertex
andedge
are incident to each other.boolean
Returnstrue
ifvertex
is a leaf of this tree, i.e., if it has no children.boolean
isNeighbor
(V v1, V v2) Returnstrue
ifv1
andv2
share an incident edge.boolean
isPredecessor
(V v1, V v2) Returns true iffv1
is the parent ofv2
.boolean
Returnstrue
ifvertex
is a leaf of this tree, i.e., if it has no children.boolean
Returnstrue
ifvertex
is the source ofedge
.boolean
isSuccessor
(V v1, V v2) Returnstrue
ifv1
is a successor ofv2
in this graph.int
Returns the number of outgoing edges incident tovertex
.boolean
removeEdge
(E edge) Removesedge
from this graph.boolean
removeVertex
(V vertex) Removesvertex
from this graph.Methods inherited from class edu.uci.ics.jung.graph.AbstractTypedGraph
getDefaultEdgeType, getEdgeCount, getEdges, getEdgeType, hasEqualEdgeType, validateEdgeType
Methods inherited from class edu.uci.ics.jung.graph.AbstractGraph
addEdge, addEdge, degree, getValidatedEndpoints, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface edu.uci.ics.jung.graph.Hypergraph
addEdge, degree, getDefaultEdgeType, getEdgeCount, getEdges, getEdgeType
-
Field Details
-
edge_vpairs
-
vertex_data
-
height
protected int height -
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
- Type Parameters:
V
- the vertex type for the graph SupplierE
- 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
Description copied from interface:Forest
Returns the number of children thatvertex
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 forgetSuccessorCount(vertex)
.- Specified by:
getChildCount
in interfaceForest<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
- Parameters:
vertex
- the vertex whose child edge is to be returnedindex
- the index of the edge to be returned- Returns:
- the child edge of
vertex
at indexindex
, that is, its ith child edge.
-
getChildEdges
Description copied from interface:Forest
Returns the edges connectingvertex
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 forgetOutEdges(vertex)
.- Specified by:
getChildEdges
in interfaceForest<V,
E> - Parameters:
vertex
- the vertex whose child edges are to be returned- Returns:
- the
Collection
of edges connectingvertex
to its children in this tree - See Also:
-
getChildren
Returns an ordered list ofvertex
's child vertices. If there is no child in position i, then the list will containnull
in position i. Ifvertex
has no children then the empty set will be returned.- Specified by:
getChildren
in interfaceForest<V,
E> - Parameters:
vertex
- the vertex whose children are to be returned- Returns:
- the
Collection
of children ofvertex
in this tree - See Also:
-
getDepth
Description copied from interface:Tree
Returns the (unweighted) distance ofvertex
from the root of this tree. -
getHeight
public int getHeight()Returns the height of the tree, or -1 if the tree is empty. -
getParent
Description copied from interface:Forest
Returns the parent ofvertex
in this tree. (Ifvertex
is the root, returnsnull
.) 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 toGraph.getPredecessors(vertex).iterator().next()
. -
getParentEdge
Description copied from interface:Forest
Returns the edge connectingvertex
to its parent in this tree. (Ifvertex
is the root, returnsnull
.) 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 toGraph.getInEdges(vertex).iterator().next()
, and also toGraph.findEdge(vertex, getParent(vertex))
.- Specified by:
getParentEdge
in interfaceForest<V,
E> - Parameters:
vertex
- the vertex whose incoming edge is to be returned- Returns:
- the edge connecting
vertex
to its parent, ornull
ifvertex
is the root - See Also:
-
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. -
getTrees
Description copied from interface:Forest
Returns a view of this graph as a collection ofTree
instances. -
addEdge
Adds the specifiedchild
vertex and edgee
to the graph with the specified parent vertexparent
. Ifindex
is greater than or equal to 0, then the child is placed at positionindex
; 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 addparent
- the source of the edge to be addedchild
- the destination of the edge to be addedindex
- the position at which e is to be added as a child ofparent
- Returns:
true
if the graph has been modified- See Also:
-
addEdge
Description copied from interface:Graph
Adds edgee
to this graph such that it connects vertexv1
tov2
. Equivalent toaddEdge(e, new Pair(v1, v2))
. If this graph does not containv1
,v2
, or both, implementations may choose to either silently add the vertices to the graph or throw anIllegalArgumentException
. If this graph assigns edge types to its edges, the edge type ofe
will be the default for this graph. SeeHypergraph.addEdge()
for a listing of possible reasons for failure. -
addEdge
Description copied from interface:Graph
Adds edgee
to this graph such that it connects vertexv1
tov2
. Equivalent toaddEdge(e, new Pair(v1, v2))
. If this graph does not containv1
,v2
, or both, implementations may choose to either silently add the vertices to the graph or throw anIllegalArgumentException
. IfedgeType
is not legal for this graph, this method will throwIllegalArgumentException
. SeeHypergraph.addEdge()
for a listing of possible reasons for failure.- Specified by:
addEdge
in interfaceGraph<V,
E> - Overrides:
addEdge
in classAbstractGraph<V,
E> - Parameters:
e
- the edge to be addedv1
- the first vertex to be connectedv2
- the second vertex to be connectededge_type
- the type to be assigned to the edge- Returns:
true
if the add is successful,false
otherwise- See Also:
-
getDest
Description copied from interface:Graph
Ifdirected_edge
is a directed edge in this graph, returns the destination; otherwise returnsnull
. The destination of a directed edged
is defined to be the vertex incident tod
for whichd
is an incoming edge.directed_edge
is guaranteed to be a directed edge if itsEdgeType
isDIRECTED
. -
getEndpoints
Description copied from interface:Graph
Returns the endpoints ofedge
as aPair
.- Specified by:
getEndpoints
in interfaceGraph<V,
E> - Parameters:
edge
- the edge whose endpoints are to be returned- Returns:
- the endpoints (incident vertices) of
edge
- See Also:
-
getInEdges
Description copied from interface:Graph
Returns aCollection
view of the incoming edges incident tovertex
in this graph.- Specified by:
getInEdges
in interfaceGraph<V,
E> - Specified by:
getInEdges
in interfaceHypergraph<V,
E> - Parameters:
vertex
- the vertex whose incoming edges are to be returned- Returns:
- a
Collection
view of the incoming edges incident tovertex
in this graph - See Also:
-
getOpposite
Description copied from interface:Graph
Returns the vertex at the other end ofedge
fromvertex
. (That is, returns the vertex incident toedge
which is notvertex
.)- Specified by:
getOpposite
in interfaceGraph<V,
E> - Overrides:
getOpposite
in classAbstractGraph<V,
E> - Parameters:
vertex
- the vertex to be queriededge
- the edge to be queried- Returns:
- the vertex at the other end of
edge
fromvertex
- See Also:
-
getOutEdges
Description copied from interface:Graph
Returns aCollection
view of the outgoing edges incident tovertex
in this graph.- Specified by:
getOutEdges
in interfaceGraph<V,
E> - Specified by:
getOutEdges
in interfaceHypergraph<V,
E> - Parameters:
vertex
- the vertex whose outgoing edges are to be returned- Returns:
- a
Collection
view of the outgoing edges incident tovertex
in this graph - See Also:
-
getPredecessorCount
Description copied from interface:Graph
Returns the number of predecessors thatvertex
has in this graph. Equivalent tovertex.getPredecessors().size()
.- Specified by:
getPredecessorCount
in interfaceGraph<V,
E> - Overrides:
getPredecessorCount
in classAbstractGraph<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
Description copied from interface:Graph
Returns aCollection
view of the predecessors ofvertex
in this graph. A predecessor ofvertex
is defined as a vertexv
which is connected tovertex
by an edgee
, wheree
is an outgoing edge ofv
and an incoming edge ofvertex
.- Specified by:
getPredecessors
in interfaceGraph<V,
E> - Specified by:
getPredecessors
in interfaceHypergraph<V,
E> - Parameters:
vertex
- the vertex whose predecessors are to be returned- Returns:
- a
Collection
view of the predecessors ofvertex
in this graph - See Also:
-
getSource
Description copied from interface:Graph
Ifdirected_edge
is a directed edge in this graph, returns the source; otherwise returnsnull
. The source of a directed edged
is defined to be the vertex for whichd
is an outgoing edge.directed_edge
is guaranteed to be a directed edge if itsEdgeType
isDIRECTED
. -
getSuccessorCount
Description copied from interface:Graph
Returns the number of successors thatvertex
has in this graph. Equivalent tovertex.getSuccessors().size()
.- Specified by:
getSuccessorCount
in interfaceGraph<V,
E> - Overrides:
getSuccessorCount
in classAbstractGraph<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
Description copied from interface:Graph
Returns aCollection
view of the successors ofvertex
in this graph. A successor ofvertex
is defined as a vertexv
which is connected tovertex
by an edgee
, wheree
is an incoming edge ofv
and an outgoing edge ofvertex
.- Specified by:
getSuccessors
in interfaceGraph<V,
E> - Specified by:
getSuccessors
in interfaceHypergraph<V,
E> - Parameters:
vertex
- the vertex whose predecessors are to be returned- Returns:
- a
Collection
view of the successors ofvertex
in this graph - See Also:
-
inDegree
Description copied from interface:Graph
Returns the number of incoming edges incident tovertex
. Equivalent togetInEdges(vertex).size()
. -
isDest
Description copied from interface:Graph
Returnstrue
ifvertex
is the destination ofedge
. Equivalent togetDest(edge).equals(vertex)
. -
isLeaf
Returnstrue
ifvertex
is a leaf of this tree, i.e., if it has no children.- Parameters:
vertex
- the vertex to be queried- Returns:
true
ifoutDegree(vertex)==0
-
isPredecessor
Returns true iffv1
is the parent ofv2
. Note that ifv2
is the root andv1
isnull
, this method returnstrue
.- Specified by:
isPredecessor
in interfaceGraph<V,
E> - Overrides:
isPredecessor
in classAbstractGraph<V,
E> - Parameters:
v1
- the first vertex to be queriedv2
- the second vertex to be queried- Returns:
true
ifv1
is a predecessor ofv2
, and false otherwise.- See Also:
-
isRoot
Returnstrue
ifvertex
is a leaf of this tree, i.e., if it has no children.- Parameters:
vertex
- the vertex to be queried- Returns:
true
ifoutDegree(vertex)==0
-
isSource
Description copied from interface:Graph
Returnstrue
ifvertex
is the source ofedge
. Equivalent togetSource(edge).equals(vertex)
. -
isSuccessor
Description copied from interface:Graph
Returnstrue
ifv1
is a successor ofv2
in this graph. Equivalent tov1.getSuccessors().contains(v2)
.- Specified by:
isSuccessor
in interfaceGraph<V,
E> - Overrides:
isSuccessor
in classAbstractGraph<V,
E> - Parameters:
v1
- the first vertex to be queriedv2
- the second vertex to be queried- Returns:
true
ifv1
is a successor ofv2
, and false otherwise.- See Also:
-
outDegree
Description copied from interface:Graph
Returns the number of outgoing edges incident tovertex
. Equivalent togetOutEdges(vertex).size()
. -
addEdge
Description copied from interface:Hypergraph
Addsedge
to this graph with typeedge_type
. Fails under the following circumstances:edge
is already an element of the graph- either
edge
orvertices
isnull
vertices
has the wrong number of vertices for the graph typevertices
are already connected by another edge in this graph, and this graph does not accept parallel edgesedge_type
is not legal for this graph
- Specified by:
addEdge
in interfaceHypergraph<V,
E> - Overrides:
addEdge
in classAbstractGraph<V,
E> - Parameters:
edge
- edge to add to this graphvertices
- vertices which are to be connected by this edgeedge_type
- type of edge to add- Returns:
true
if the add is successful, andfalse
otherwise- See Also:
-
addVertex
Description copied from interface:Hypergraph
Addsvertex
to this graph. Fails ifvertex
is null or already in the graph.- Specified by:
addVertex
in interfaceHypergraph<V,
E> - Parameters:
vertex
- the vertex to add- Returns:
true
if the add is successful, andfalse
otherwise- See Also:
-
isIncident
Description copied from interface:Hypergraph
Returnstrue
ifvertex
andedge
are incident to each other. Equivalent togetIncidentEdges(vertex).contains(edge)
and togetIncidentVertices(edge).contains(vertex)
.- Specified by:
isIncident
in interfaceHypergraph<V,
E> - Overrides:
isIncident
in classAbstractGraph<V,
E> - Parameters:
vertex
- vertex to testedge
- edge to test- Returns:
true
ifvertex
andedge
are incident to each other- See Also:
-
isNeighbor
Description copied from interface:Hypergraph
Returnstrue
ifv1
andv2
share an incident edge. Equivalent togetNeighbors(v1).contains(v2)
.- Specified by:
isNeighbor
in interfaceHypergraph<V,
E> - Overrides:
isNeighbor
in classAbstractGraph<V,
E> - Parameters:
v1
- the first vertex to testv2
- the second vertex to test- Returns:
true
ifv1
andv2
share an incident edge- See Also:
-
containsEdge
Description copied from interface:Hypergraph
Returns true if this graph's edge collection containsedge
. Equivalent togetEdges().contains(edge)
.- Specified by:
containsEdge
in interfaceHypergraph<V,
E> - Parameters:
edge
- the edge whose presence is being queried- Returns:
- true iff this graph contains an edge
edge
- See Also:
-
containsVertex
Description copied from interface:Hypergraph
Returns true if this graph's vertex collection containsvertex
. Equivalent togetVertices().contains(vertex)
.- Specified by:
containsVertex
in interfaceHypergraph<V,
E> - Parameters:
vertex
- the vertex whose presence is being queried- Returns:
- true iff this graph contains a vertex
vertex
- See Also:
-
findEdge
Description copied from interface:Hypergraph
Returns an edge that connects this vertex tov
. If this edge is not uniquely defined (that is, if the graph contains more than one edge connectingv1
tov2
), 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 tov1
- either
v1
orv2
are not present in this graph
Note: for purposes of this method,
v1
is only considered to be connected tov2
via a given directed edgee
ifv1 == e.getSource() && v2 == e.getDest()
evaluates totrue
. (v1
andv2
are connected by an undirected edgeu
ifu
is incident to bothv1
andv2
.)- Specified by:
findEdge
in interfaceHypergraph<V,
E> - Overrides:
findEdge
in classAbstractGraph<V,
E> - Parameters:
v1
- the first endpoint of the returned edgev2
- the second endpoint of the returned edge- Returns:
- an edge that connects
v1
tov2
, ornull
if no such edge exists (or either vertex is not present) - See Also:
-
findEdgeSet
Description copied from interface:Hypergraph
Returns all edges that connects this vertex tov
. If this edge is not uniquely defined (that is, if the graph contains more than one edge connectingv1
tov2
), any of these edges may be returned.findEdgeSet(v1, v2)
may be used to return all such edges. Returns null ifv2
is not connected tov1
.
Returns an empty collection if eitherv1
orv2
are not present in this graph.Note: for purposes of this method,
v1
is only considered to be connected tov2
via a given directed edged
ifv1 == d.getSource() && v2 == d.getDest()
evaluates totrue
. (v1
andv2
are connected by an undirected edgeu
ifu
is incident to bothv1
andv2
.)- Specified by:
findEdgeSet
in interfaceHypergraph<V,
E> - Overrides:
findEdgeSet
in classAbstractGraph<V,
E> - Parameters:
v1
- the first endpoint of the returned edge setv2
- the second endpoint of the returned edge set- Returns:
- a collection containing all edges that connect
v1
tov2
, ornull
if either vertex is not present - See Also:
-
getChild
Returns the child ofvertex
at positionindex
in this tree, ornull
if it has no child at that position.- Parameters:
vertex
- the vertex to queryindex
- the index of the child to return- Returns:
- the child of
vertex
at positionindex
in this tree, ornull
if it has no child at that position - Throws:
ArrayIndexOutOfBoundsException
- ifindex
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 interfaceHypergraph<V,
E> - Returns:
- the number of edges in this graph
- See Also:
-
getEdges
Description copied from interface:Hypergraph
Returns a view of all edges in this graph. In general, this obeys theCollection
contract, and therefore makes no guarantees about the ordering of the vertices within the set.- Specified by:
getEdges
in interfaceHypergraph<V,
E> - Returns:
- a
Collection
view of all edges in this graph - See Also:
-
getIncidentCount
Description copied from interface:Hypergraph
Returns the number of vertices that are incident toedge
. 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 interfaceHypergraph<V,
E> - Overrides:
getIncidentCount
in classAbstractGraph<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
Description copied from interface:Hypergraph
Returns the collection of edges in this graph which are connected tovertex
.- Specified by:
getIncidentEdges
in interfaceHypergraph<V,
E> - Parameters:
vertex
- the vertex whose incident edges are to be returned- Returns:
- the collection of edges which are connected to
vertex
, ornull
ifvertex
is not present - See Also:
-
getIncidentVertices
Description copied from interface:Hypergraph
Returns the collection of vertices in this graph which are connected toedge
. 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 interfaceHypergraph<V,
E> - Overrides:
getIncidentVertices
in classAbstractGraph<V,
E> - Parameters:
edge
- the edge whose incident vertices are to be returned- Returns:
- the collection of vertices which are connected to
edge
, ornull
ifedge
is not present - See Also:
-
getNeighborCount
Description copied from interface:Hypergraph
Returns the number of vertices that are adjacent tovertex
(that is, the number of vertices that are incident to edges invertex
's incident edge set).Equivalent to
getNeighbors(vertex).size()
.- Specified by:
getNeighborCount
in interfaceHypergraph<V,
E> - Overrides:
getNeighborCount
in classAbstractGraph<V,
E> - Parameters:
vertex
- the vertex whose neighbor count is to be returned- Returns:
- the number of neighboring vertices
- See Also:
-
getNeighbors
Description copied from interface:Hypergraph
Returns the collection of vertices which are connected tovertex
via any edges in this graph. Ifvertex
is connected to itself with a self-loop, then it will be included in the collection returned.- Specified by:
getNeighbors
in interfaceHypergraph<V,
E> - Parameters:
vertex
- the vertex whose neighbors are to be returned- Returns:
- the collection of vertices which are connected to
vertex
, ornull
ifvertex
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 interfaceHypergraph<V,
E> - Returns:
- the number of vertices in this graph
- See Also:
-
getVertices
Description copied from interface:Hypergraph
Returns a view of all vertices in this graph. In general, this obeys theCollection
contract, and therefore makes no guarantees about the ordering of the vertices within the set.- Specified by:
getVertices
in interfaceHypergraph<V,
E> - Returns:
- a
Collection
view of all vertices in this graph - See Also:
-
removeEdge
Description copied from interface:Hypergraph
Removesedge
from this graph. Fails ifedge
is null, or is otherwise not an element of this graph.- Specified by:
removeEdge
in interfaceHypergraph<V,
E> - Parameters:
edge
- the edge to remove- Returns:
true
if the removal is successful,false
otherwise- See Also:
-
removeVertex
Description copied from interface:Hypergraph
Removesvertex
from this graph. As a side effect, removes any edgese
incident tovertex
if the removal ofvertex
would causee
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 graphvertex
isnull
- Specified by:
removeVertex
in interfaceHypergraph<V,
E> - Parameters:
vertex
- the vertex to remove- Returns:
true
if the removal is successful,false
otherwise- See Also:
-
addEdge
Description copied from class:AbstractGraph
Addsedge
to this graph with the specifiedendpoints
andEdgeType
.- Specified by:
addEdge
in classAbstractGraph<V,
E> - Parameters:
edge
- the edge to be addedendpoints
- the endpoints to be connected to this edgeedgeType
- the type of edge to add- Returns:
- true iff the graph was modified as a result of this call
-