public interface Hypergraph<V,E>
V and a
set of hyperedges of type E which connect the vertices. This is
the base interface for all JUNG graph types.
This interface permits, but does not enforce, any of the following common variations of graphs:
Notes:
Hypergraph instances should be
treated in general as if read-only. While they are not contractually
guaranteed (or required) to be immutable, this interface does not define the
outcome if they are mutated. Mutations should be done via
{add,remove}{Edge,Vertex}, or in the constructor.
Ported to Javascript by:, Fritz Ray (fritz.ray@eduworks.com), Tom Buskirk (tom.buskirk@eduworks.com)
| Modifier and Type | Method and Description |
|---|---|
boolean |
addHyperEdge(E edge,
org.stjs.javascript.Array<? extends V> vertices)
Adds
edge to this graph. |
boolean |
addVertex(V vertex)
Adds
vertex to this graph. |
boolean |
containsEdge(E edge)
Returns true if this graph's edge collection contains
edge. |
boolean |
containsVertex(V vertex)
Returns true if this graph's vertex collection contains
vertex. |
int |
degree(V vertex)
Returns the number of edges incident to
vertex. |
E |
findEdge(V v1,
V v2)
Returns an edge that connects this vertex to
v. |
org.stjs.javascript.Array<E> |
findEdgeSet(V v1,
V v2)
Returns all edges that connects this vertex to
v. |
String |
getDefaultEdgeType()
Returns the default edge type for this graph.
|
V |
getDest(E directed_edge)
If
directed_edge is a directed edge in this graph, returns
the destination; otherwise returns null. |
int |
getEdgeCount()
Returns the number of edges in this graph.
|
int |
getEdgeCountOfType(String edge_type)
Returns the number of edges of type
edge_type in this graph. |
org.stjs.javascript.Array<E> |
getEdges()
Returns a view of all edges in this graph.
|
org.stjs.javascript.Array<E> |
getEdgesOfType(String edge_type)
Returns the collection of edges in this graph which are of type
edge_type. |
String |
getEdgeType(E edge)
Returns the edge type of
edge in this graph. |
int |
getIncidentCount(E edge)
Returns the number of vertices that are incident to
edge. |
org.stjs.javascript.Array<E> |
getIncidentEdges(V vertex)
Returns the collection of edges in this graph which are connected to
vertex. |
org.stjs.javascript.Array<V> |
getIncidentVertices(E edge)
Returns the collection of vertices in this graph which are connected to
edge. |
org.stjs.javascript.Array<E> |
getInEdges(V vertex)
Returns a
Array view of the incoming edges incident to
vertex in this graph. |
int |
getNeighborCount(V vertex)
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). |
org.stjs.javascript.Array<V> |
getNeighbors(V vertex)
Returns the collection of vertices which are connected to
vertex via any edges in this graph. |
org.stjs.javascript.Array<E> |
getOutEdges(V vertex)
Returns a
Array view of the outgoing edges incident to
vertex in this graph. |
org.stjs.javascript.Array<V> |
getPredecessors(V vertex)
Returns a
Array view of the predecessors of
vertex in this graph. |
V |
getSource(E directed_edge)
If
directed_edge is a directed edge in this graph, returns
the source; otherwise returns null. |
org.stjs.javascript.Array<V> |
getSuccessors(V vertex)
Returns a
Array view of the successors of
vertex in this graph. |
int |
getVertexCount()
Returns the number of vertices in this graph.
|
org.stjs.javascript.Array<V> |
getVertices()
Returns a view of all vertices in this graph.
|
int |
inDegree(V vertex)
Returns the number of incoming edges incident to
vertex. |
boolean |
isIncident(V vertex,
E edge)
Returns
true if vertex and edge
are incident to each other. |
boolean |
isNeighbor(V v1,
V v2)
Returns
true if v1 and v2 share an
incident edge. |
int |
outDegree(V vertex)
Returns the number of outgoing edges incident to
vertex. |
boolean |
removeEdge(E edge)
Removes
edge from this graph. |
boolean |
removeVertex(V vertex)
Removes
vertex from this graph. |
org.stjs.javascript.Array<E> getEdges()
Array contract, and therefore makes no guarantees about the
ordering of the vertices within the set.Array view of all edges in this graphorg.stjs.javascript.Array<V> getVertices()
Array contract, and therefore makes no guarantees about the
ordering of the vertices within the set.Array view of all vertices in this graphboolean containsVertex(V vertex)
vertex. Equivalent to
getVertices().contains(vertex).vertex - the vertex whose presence is being queriedvertexboolean containsEdge(E edge)
edge.
Equivalent to getEdges().contains(edge).edge - the edge whose presence is being queriededgeint getEdgeCount()
int getVertexCount()
org.stjs.javascript.Array<V> getNeighbors(V vertex)
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.vertex - the vertex whose neighbors are to be returnedvertex, or null if vertex
is not presentorg.stjs.javascript.Array<E> getIncidentEdges(V vertex)
vertex.vertex - the vertex whose incident edges are to be returnedvertex, or null if vertex
is not presentorg.stjs.javascript.Array<V> getIncidentVertices(E edge)
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.edge - the edge whose incident vertices are to be returnededge, or null if edge is
not presentE findEdge(V v1, V v2)
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.)
v1 - between thisv2 - and thatv1 to v2, or
null if no such edge exists (or either vertex is not
present)findEdgeSet(Object, Object)org.stjs.javascript.Array<E> findEdgeSet(V v1, V v2)
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. 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.)
v1 - between thisv2 - and thatv1 to
v2, or null if either vertex is not
presentfindEdge(Object, Object)boolean addVertex(V vertex)
vertex to this graph. Fails if vertex is
null or already in the graph.vertex - the vertex to addtrue if the add is successful, and
false otherwiseIllegalArgumentException - if vertex is nullboolean addHyperEdge(E edge, org.stjs.javascript.Array<? extends V> vertices)
edge to this graph. 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 - vertices - true if the add is successful, and
false otherwiseIllegalArgumentException - if edge or vertices is null, or if
a different vertex set in this graph is already connected by
edge, or if vertices are not a
legal vertex set for edgeboolean removeVertex(V vertex)
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
vertex - the vertex to removetrue if the removal is successful,
false otherwiseboolean removeEdge(E edge)
edge from this graph. Fails if edge is
null, or is otherwise not an element of this graph.edge - the edge to removetrue if the removal is successful,
false otherwiseboolean isNeighbor(V v1, V v2)
true if v1 and v2 share an
incident edge. Equivalent to getNeighbors(v1).contains(v2).v1 - the first vertex to testv2 - the second vertex to testtrue if v1 and v2 share an
incident edgeboolean isIncident(V vertex, E edge)
true if vertex and edge
are incident to each other. Equivalent to
getIncidentEdges(vertex).contains(edge) and to
getIncidentVertices(edge).contains(vertex).vertex - edge - true if vertex and edge
are incident to each otherint degree(V vertex)
vertex. Special
cases of interest:
getNeighborCount).
Equivalent to getIncidentEdges(vertex).size().
vertex - the vertex whose degree is to be returnedgetNeighborCount(Object)int getNeighborCount(V vertex)
vertex
(that is, the number of vertices that are incident to edges in
vertex's incident edge set).
Equivalent to getNeighbors(vertex).size().
vertex - the vertex whose neighbor count is to be returnedint getIncidentCount(E edge)
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().
edge - the edge whose incident vertex count is to be returnededge.String getEdgeType(E edge)
edge in this graph.edge - EdgeType of edge, or
null if edge has no defined typeString getDefaultEdgeType()
org.stjs.javascript.Array<E> getEdgesOfType(String edge_type)
edge_type.edge_type - the type of edges to be returnededge_type,
or null if the graph does not accept edges of this
typeEdgeTypeint getEdgeCountOfType(String edge_type)
edge_type in this graph.edge_type - the type of edge for which the count is to be returnededge_type in this graphorg.stjs.javascript.Array<E> getInEdges(V vertex)
Array view of the incoming edges incident to
vertex in this graph.vertex - the vertex whose incoming edges are to be returnedArray view of the incoming edges incident to
vertex in this graphorg.stjs.javascript.Array<E> getOutEdges(V vertex)
Array view of the outgoing edges incident to
vertex in this graph.vertex - the vertex whose outgoing edges are to be returnedArray view of the outgoing edges incident to
vertex in this graphint inDegree(V vertex)
vertex.
Equivalent to getInEdges(vertex).size().vertex - the vertex whose indegree is to be calculatedvertexint outDegree(V vertex)
vertex.
Equivalent to getOutEdges(vertex).size().vertex - the vertex whose outdegree is to be calculatedvertexV getSource(E directed_edge)
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.directed_edge - directed_edge if it is a directed edge
in this graph, or null otherwiseV getDest(E directed_edge)
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.directed_edge - directed_edge if it is a directed
edge in this graph, or null otherwiseorg.stjs.javascript.Array<V> getPredecessors(V vertex)
Array 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.vertex - the vertex whose predecessors are to be returnedArray view of the predecessors of
vertex in this graphorg.stjs.javascript.Array<V> getSuccessors(V vertex)
Array 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.vertex - the vertex whose predecessors are to be returnedArray view of the successors of
vertex in this graphCopyright © 2021 Eduworks Corporation. All rights reserved.