|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface InspectableGraph
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 nz.ac.waikato.jdsl.core.api.InspectablePositionalContainer |
---|
positions |
Methods inherited from interface nz.ac.waikato.jdsl.core.api.InspectableContainer |
---|
contains, elements, isEmpty, size |
Method Detail |
---|
int numVertices()
int numEdges()
VertexIterator vertices()
Vertex aVertex()
EdgeIterator edges()
Edge anEdge()
EdgeIterator directedEdges()
EdgeIterator undirectedEdges()
boolean areAdjacent(Vertex v1, Vertex v2) throws InvalidAccessorException
v1
- a vertexv2
- a vertex
v1
and v2
are adjacent,
i.e., whether they are
the endvertices of a common edge
InvalidAccessorException
- if either v1
or
v2
is not contained in this graphboolean areAdjacent(Edge e1, Edge e2) throws InvalidAccessorException
e1
- an edgee2
- an edge
e1
and e2
are adjacent,
i.e., whether they have at least one common endvertex
InvalidAccessorException
- if either e1
or
e2
is not contained in this graphboolean areIncident(Vertex v, Edge e) throws InvalidAccessorException
v
- a vertexe
- an edge
v
and e
are incident,
i.e., whether v
is an endvertex of e
InvalidAccessorException
- if either v
or
e
is not contained in this graphint degree(Vertex v) throws InvalidAccessorException
v
- a vertex
v
InvalidAccessorException
- if v
is
not contained in this graphint degree(Vertex v, int edgetype) throws InvalidAccessorException
v
- a vertexedgetype
- A constant from the EdgeDirection
interface
v
InvalidAccessorException
- if v
is
not contained in this graphEdgeDirection
VertexIterator adjacentVertices(Vertex v) throws InvalidAccessorException
v
- a vertex
v
by undirected,
incoming and outgoing edges
InvalidAccessorException
- if v
is not contain in this graphVertexIterator adjacentVertices(Vertex v, int edgetype) throws InvalidAccessorException
v
- a vertexedgetype
- A constant from the EdgeDirection
interface
v
by edges of the specified type
InvalidAccessorException
- if v
is
is not contained in this graphEdgeDirection
EdgeIterator incidentEdges(Vertex v) throws InvalidAccessorException
v
- a vertex
v
InvalidAccessorException
- if v
is not
contained in this graphEdgeIterator incidentEdges(Vertex v, int edgetype) throws InvalidAccessorException
v
- a vertexedgetype
- A constant from the EdgeDirection
interface
v
InvalidAccessorException
- if v
is not
contained in this graphEdgeDirection
Edge anIncidentEdge(Vertex v) throws InvalidAccessorException
v
- a vertex
v
, or Edge.NONE if
there is no edge incident on v
InvalidAccessorException
- if v
is not
contained in this graphEdge anIncidentEdge(Vertex v, int edgetype) throws InvalidAccessorException
v
- a vertexedgetype
- A constant from the EdgeDirection
interface
v
,
or Edge.NONE if there is no such edge incident on v
InvalidAccessorException
- if v
is not
contained in this graphEdgeDirection
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 vertex
v1
and v2
InvalidAccessorException
- if v1
or v2
is not contained in this graphEdge 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 vertex
v1
and v2
,
or Edge.NONE if there is no such edge
InvalidAccessorException
Vertex[] endVertices(Edge e) throws InvalidAccessorException
e
- an edge
e
;
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 graphVertex opposite(Vertex v, Edge e) throws InvalidVertexException, InvalidAccessorException
v
- one endvertex of e
e
- an edge
e
different from v
InvalidVertexException
- if v
is not an
endvertex of e
InvalidAccessorException
- if v
or e
is not contained in this graphVertex origin(Edge e) throws InvalidEdgeException, InvalidAccessorException
e
- an edge
e
, if e
is directed
InvalidEdgeException
- if e
is undirected
InvalidAccessorException
- if e
is not
contained in this graphVertex destination(Edge e) throws InvalidEdgeException, InvalidAccessorException
e
- an edge
e
, if
e
is directed
InvalidEdgeException
- if e
is undirected
InvalidAccessorException
- if e
is not
contained in this graphVertex aCommonVertex(Edge e1, Edge e2) throws InvalidAccessorException
e1
- an edgee2
- an edge
e1
and e2
, or Vertex.NONE if there is
no such vertex
InvalidAccessorException
- if e1
or e2
is not contained in this graphboolean isDirected(Edge e) throws InvalidAccessorException
e
- an edge
true
if e
is directed,
false
otherwise
InvalidAccessorException
- if e
is not
contained in this graph
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |