|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
An interface describing the accessor methods of a combinatorial graph. Holds both directed and undirected edges, and self-loops and parallel edges. An undirected edge is not the same as a pair of undirected edges. The graph can be disconnected. Subinterfaces can restrict any of these properties.
All iterators returned from graphs have snapshot semantics. That is, their contents are fixed at the moment the iterator is returned and remain unchanged even if the container is changed before the iterator has been exhausted.
No order is guaranteed on the vertices or edges of the graph (the sets of vertices and edges are just that: unordered sets).
Some methods dealing with edge directions take a constant, or an
OR of constants, from the EdgeDirection
interface. For instance,
incidentEdges(v)
gets all edges incident on v
,
incidentEdges(v, EdgeDirection.IN)
gets all edges
directed toward v
, and
incidentEdges(v, EdgeDirection.IN | EdgeDirection.OUT)
gets all directed edges incident on v
.
ModifiableGraph
,
EdgeDirection
Method Summary | |
Vertex |
aCommonVertex(Edge e1,
Edge e2)
|
Edge |
aConnectingEdge(Vertex v1,
Vertex v2)
Gives an arbitrary edge from among those connecting the two specified vertices. |
VertexIterator |
adjacentVertices(Vertex v)
Lists all vertices adjacent to a particular vertex by any kind of edge, with repeats corresponding to parallel edges. |
VertexIterator |
adjacentVertices(Vertex v,
int edgetype)
Lists all vertices adjacent to a particular vertex by all edges of the types specified. |
Edge |
anEdge()
|
Edge |
anIncidentEdge(Vertex v)
|
Edge |
anIncidentEdge(Vertex v,
int edgetype)
|
boolean |
areAdjacent(Edge e1,
Edge e2)
Checks whether two edges have at least one common endpoint. |
boolean |
areAdjacent(Vertex v1,
Vertex v2)
|
boolean |
areIncident(Vertex v,
Edge e)
|
Vertex |
aVertex()
|
EdgeIterator |
connectingEdges(Vertex v1,
Vertex v2)
Gives all edges connecting two vertices. |
int |
degree(Vertex v)
Gives the degree of a vertex, counting both directed and undirected edges. |
int |
degree(Vertex v,
int edgetype)
Gives the degree of a vertex, counting all edges of the specified type. |
Vertex |
destination(Edge e)
|
EdgeIterator |
directedEdges()
|
EdgeIterator |
edges()
|
Vertex[] |
endVertices(Edge e)
|
EdgeIterator |
incidentEdges(Vertex v)
|
EdgeIterator |
incidentEdges(Vertex v,
int edgetype)
|
boolean |
isDirected(Edge e)
|
int |
numEdges()
|
int |
numVertices()
|
Vertex |
opposite(Vertex v,
Edge e)
|
Vertex |
origin(Edge e)
|
EdgeIterator |
undirectedEdges()
|
VertexIterator |
vertices()
|
Methods inherited from interface jdsl.core.api.InspectablePositionalContainer |
positions |
Methods inherited from interface jdsl.core.api.InspectableContainer |
contains, elements, isEmpty, size |
Method Detail |
public int numVertices()
public int numEdges()
public VertexIterator vertices()
public Vertex aVertex()
public EdgeIterator edges()
public Edge anEdge()
public EdgeIterator directedEdges()
public EdgeIterator undirectedEdges()
public boolean areAdjacent(Vertex v1, Vertex v2) throws InvalidAccessorException
v1
- a vertexv2
- a vertexv1
and v2
are adjacent,
i.e., whether they are
the endvertices of a common edgeInvalidAccessorException
- if either v1
or
v2
is not contained in this graphpublic boolean areAdjacent(Edge e1, Edge e2) throws InvalidAccessorException
e1
- an edgee2
- an edgee1
and e2
are adjacent,
i.e., whether they have at least one common endvertexInvalidAccessorException
- if either e1
or
e2
is not contained in this graphpublic boolean areIncident(Vertex v, Edge e) throws InvalidAccessorException
v
- a vertexe
- an edgev
and e
are incident,
i.e., whether v
is an endvertex of e
InvalidAccessorException
- if either v
or
e
is not contained in this graphpublic int degree(Vertex v) throws InvalidAccessorException
v
- a vertexv
InvalidAccessorException
- if v
is
not contained in this graphpublic int degree(Vertex v, int edgetype) throws InvalidAccessorException
v
- a vertexedgetype
- A constant from the EdgeDirection
interfacev
InvalidAccessorException
- if v
is
not contained in this graphEdgeDirection
public VertexIterator adjacentVertices(Vertex v) throws InvalidAccessorException
v
- a vertexv
by undirected,
incoming and outgoing edgesInvalidAccessorException
- if v
is not contain in this graphpublic VertexIterator adjacentVertices(Vertex v, int edgetype) throws InvalidAccessorException
v
- a vertexedgetype
- A constant from the EdgeDirection
interfacev
by edges of the specified typeInvalidAccessorException
- if v
is
is not contained in this graphEdgeDirection
public EdgeIterator incidentEdges(Vertex v) throws InvalidAccessorException
v
- a vertexv
InvalidAccessorException
- if v
is not
contained in this graphpublic EdgeIterator incidentEdges(Vertex v, int edgetype) throws InvalidAccessorException
v
- a vertexedgetype
- A constant from the EdgeDirection
interfacev
InvalidAccessorException
- if v
is not
contained in this graphEdgeDirection
public Edge anIncidentEdge(Vertex v) throws InvalidAccessorException
v
- a vertexv
, or Edge.NONE if
there is no edge incident on v
InvalidAccessorException
- if v
is not
contained in this graphpublic Edge anIncidentEdge(Vertex v, int edgetype) throws InvalidAccessorException
v
- a vertexedgetype
- A constant from the EdgeDirection
interfacev
,
or Edge.NONE if there is no such edge incident on v
InvalidAccessorException
- if v
is not
contained in this graphEdgeDirection
public EdgeIterator connectingEdges(Vertex v1, Vertex v2) throws InvalidAccessorException
v1==v2
,
gives all self-loops of the vertex, each reported twice as in
incidentEdges(.).v1
- a vertexv2
- a vertexv1
and v2
InvalidAccessorException
- if v1
or v2
is not contained in this graphpublic Edge aConnectingEdge(Vertex v1, Vertex v2) throws InvalidAccessorException
v1==v2
, gives a self-loop
of the vertex. If there is no edge that can be returned, returns Edge.NONE.v1
- a vertexv2
- a vertexv1
and v2
,
or Edge.NONE if there is no such edgepublic Vertex[] endVertices(Edge e) throws InvalidAccessorException
e
- an edgee
;
if e
is directed, the first element of the array is the origin of e
and the second element is the destination of e
InvalidAccessorException
- if e
is not
contained in this graphpublic Vertex opposite(Vertex v, Edge e) throws InvalidVertexException, InvalidAccessorException
v
- one endvertex of e
e
- an edgee
different from v
InvalidVertexException
- if v
is not an
endvertex of e
InvalidAccessorException
- if v
or e
is not contained in this graphpublic Vertex origin(Edge e) throws InvalidEdgeException, InvalidAccessorException
e
- an edgee
, if e
is directedInvalidEdgeException
- if e
is undirectedInvalidAccessorException
- if e
is not
contained in this graphpublic Vertex destination(Edge e) throws InvalidEdgeException, InvalidAccessorException
e
- an edgee
, if
e
is directedInvalidEdgeException
- if e
is undirectedInvalidAccessorException
- if e
is not
contained in this graphpublic Vertex aCommonVertex(Edge e1, Edge e2) throws InvalidAccessorException
e1
- an edgee2
- an edgee1
and e2
, or Vertex.NONE if there is
no such vertexInvalidAccessorException
- if e1
or e2
is not contained in this graphpublic boolean isDirected(Edge e) throws InvalidAccessorException
e
- an edgetrue
if e
is directed,
false
otherwiseInvalidAccessorException
- if e
is not
contained in this graph
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |