|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.uci.ics.jung.graph.AbstractGraph<V,E>
public abstract class AbstractGraph<V,E>
Abstract implementation of the Graph
interface. Designed to simplify implementation of
new graph classes.
Constructor Summary | |
---|---|
AbstractGraph()
|
Method Summary | |
---|---|
boolean |
addEdge(E edge,
Collection<? extends V> vertices)
Adds edge to this graph. |
boolean |
addEdge(E edge,
Collection<? extends V> vertices,
EdgeType edgeType)
Adds edge to this graph with type edge_type . |
abstract boolean |
addEdge(E edge,
Pair<? extends V> endpoints)
|
abstract boolean |
addEdge(E edge,
Pair<? extends V> endpoints,
EdgeType edgeType)
|
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 . |
Collection<E> |
findEdgeSet(V v1,
V v2)
Returns all edges that connects this vertex to v . |
int |
getIncidentCount(E edge)
Returns the number of vertices that are incident to edge . |
Collection<V> |
getIncidentVertices(E edge)
Returns the collection of vertices in this graph which are connected to edge . |
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). |
V |
getOpposite(V vertex,
E edge)
Returns the vertex at the other end of edge from vertex . |
int |
getPredecessorCount(V vertex)
Returns the number of predecessors that vertex has in this graph. |
int |
getSuccessorCount(V vertex)
Returns the number of successors that vertex has in this graph. |
protected Pair<V> |
getValidatedEndpoints(E edge,
Pair<? extends V> endpoints)
|
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. |
boolean |
isPredecessor(V v1,
V v2)
Returns true if v1 is a predecessor of v2 in this graph. |
boolean |
isSuccessor(V v1,
V v2)
Returns true if v1 is a successor of v2 in this graph. |
int |
outDegree(V vertex)
Returns the number of outgoing edges incident to vertex . |
String |
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.Graph |
---|
addEdge, addEdge, getDest, getEndpoints, getInEdges, getOutEdges, getPredecessors, getSource, getSuccessors, isDest, isSource |
Methods inherited from interface edu.uci.ics.jung.graph.Hypergraph |
---|
addVertex, containsEdge, containsVertex, getEdgeCount, getEdgeCount, getEdges, getEdges, getEdgeType, getIncidentEdges, getNeighbors, getVertexCount, getVertices, removeEdge, removeVertex |
Constructor Detail |
---|
public AbstractGraph()
Method Detail |
---|
public boolean addEdge(E edge, Collection<? extends V> vertices)
Hypergraph
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
addEdge
in interface Hypergraph<V,E>
true
if the add is successful, and false
otherwisepublic boolean addEdge(E edge, Collection<? extends V> vertices, EdgeType edgeType)
Hypergraph
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
addEdge
in interface Hypergraph<V,E>
true
if the add is successful, and false
otherwisepublic abstract boolean addEdge(E edge, Pair<? extends V> endpoints)
public abstract boolean addEdge(E edge, Pair<? extends V> endpoints, EdgeType edgeType)
protected Pair<V> getValidatedEndpoints(E edge, Pair<? extends V> endpoints)
public int inDegree(V vertex)
Graph
vertex
.
Equivalent to getInEdges(vertex).size()
.
inDegree
in interface Graph<V,E>
vertex
- the vertex whose indegree is to be calculated
vertex
public int outDegree(V vertex)
Graph
vertex
.
Equivalent to getOutEdges(vertex).size()
.
outDegree
in interface Graph<V,E>
vertex
- the vertex whose outdegree is to be calculated
vertex
public boolean isPredecessor(V v1, V v2)
Graph
true
if v1
is a predecessor of v2
in this graph.
Equivalent to v1.getPredecessors().contains(v2)
.
isPredecessor
in interface Graph<V,E>
v1
- the first vertex to be queriedv2
- the second vertex to be queried
true
if v1
is a predecessor of v2
, and false otherwise.public boolean isSuccessor(V v1, V v2)
Graph
true
if v1
is a successor of v2
in this graph.
Equivalent to v1.getSuccessors().contains(v2)
.
isSuccessor
in interface Graph<V,E>
v1
- the first vertex to be queriedv2
- the second vertex to be queried
true
if v1
is a successor of v2
, and false otherwise.public int getPredecessorCount(V vertex)
Graph
vertex
has in this graph.
Equivalent to vertex.getPredecessors().size()
.
getPredecessorCount
in interface Graph<V,E>
vertex
- the vertex whose predecessor count is to be returned
vertex
has in this graphpublic int getSuccessorCount(V vertex)
Graph
vertex
has in this graph.
Equivalent to vertex.getSuccessors().size()
.
getSuccessorCount
in interface Graph<V,E>
vertex
- the vertex whose successor count is to be returned
vertex
has in this graphpublic boolean isNeighbor(V v1, V v2)
Hypergraph
true
if v1
and v2
share an incident edge.
Equivalent to getNeighbors(v1).contains(v2)
.
isNeighbor
in interface Hypergraph<V,E>
v1
- the first vertex to testv2
- the second vertex to test
true
if v1
and v2
share an incident edgepublic boolean isIncident(V vertex, E edge)
Hypergraph
true
if vertex
and edge
are incident to each other.
Equivalent to getIncidentEdges(vertex).contains(edge)
and to
getIncidentVertices(edge).contains(vertex)
.
isIncident
in interface Hypergraph<V,E>
true
if vertex
and edge
are incident to each otherpublic int getNeighborCount(V vertex)
Hypergraph
vertex
(that is, the number of vertices that are incident to edges in vertex
's
incident edge set).
Equivalent to getNeighbors(vertex).size()
.
getNeighborCount
in interface Hypergraph<V,E>
vertex
- the vertex whose neighbor count is to be returned
public int degree(V vertex)
Hypergraph
vertex
.
Special cases of interest:
getNeighborCount
).
Equivalent to getIncidentEdges(vertex).size()
.
degree
in interface Hypergraph<V,E>
vertex
- the vertex whose degree is to be returned
Hypergraph.getNeighborCount(Object)
public int getIncidentCount(E edge)
Hypergraph
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()
.
getIncidentCount
in interface Hypergraph<V,E>
edge
- the edge whose incident vertex count is to be returned
edge
.public V getOpposite(V vertex, E edge)
Graph
edge
from vertex
.
(That is, returns the vertex incident to edge
which is not vertex
.)
getOpposite
in interface Graph<V,E>
vertex
- the vertex to be queriededge
- the edge to be queried
edge
from vertex
public E findEdge(V v1, V v2)
Hypergraph
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
.)
findEdge
in interface Hypergraph<V,E>
v1
to v2
,
or null
if no such edge exists (or either vertex is not present)Hypergraph.findEdgeSet(Object, Object)
public Collection<E> findEdgeSet(V v1, V v2)
Hypergraph
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
.)
findEdgeSet
in interface Hypergraph<V,E>
v1
to v2
,
or null
if either vertex is not presentHypergraph.findEdge(Object, Object)
public Collection<V> getIncidentVertices(E edge)
Hypergraph
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.
getIncidentVertices
in interface Hypergraph<V,E>
edge
- the edge whose incident vertices are to be returned
edge
,
or null
if edge
is not presentpublic String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |