|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnz.ac.waikato.jdsl.core.ref.AbstractPositionalContainer
nz.ac.waikato.jdsl.graph.ref.AbstractGraph
public abstract class AbstractGraph
An implementation of many of the methods of InspectableGraph in terms of a few primitives. Note that that says "InspectableGraph," not "Graph," but that this class extends AbstractPositionalContainer, which implements replaceElements(.). All the methods implemented here belong to InspectableGraph.
The implementor must define the primitives called by the
functions here. In addition, the implementor must define any
primitives needed for AbstractPositionalContainer
not defined here.
In several places when the AbstractGraph calls a method that the implementer must define, the AbstractGraph is relying on the implementer also checking the input vertex or edge for validity.
The complexities of the methods implemented here depend on the complexities of the underlying methods. Therefore, the complexity documented for each method below is based on suppositions about the underlying implementation.
Nested Class Summary | |
---|---|
protected static class |
AbstractGraph.OO_to_O_MergerIterator
|
Constructor Summary | |
---|---|
protected |
AbstractGraph()
|
Method Summary | |
---|---|
Vertex |
aCommonVertex(Edge e1,
Edge e2)
Built on endVertices(.) |
Edge |
aConnectingEdge(Vertex v1,
Vertex v2)
Built on incidentEdges(.) |
VertexIterator |
adjacentVertices(Vertex v)
Built on incidentEdges(.) |
VertexIterator |
adjacentVertices(Vertex v,
int edgetype)
Built on incidentEdges(.) |
boolean |
areAdjacent(Edge e1,
Edge e2)
Built on endVertices(.) |
boolean |
areAdjacent(Vertex v1,
Vertex v2)
Built on incidentEdges(.) |
EdgeIterator |
connectingEdges(Vertex v1,
Vertex v2)
Built on incidentEdges(.) |
EdgeIterator |
directedEdges()
Built on edges() and isDirected(.) |
PositionIterator |
positions()
Built on vertices() and edges(). |
int |
size()
Built on numVertices() and numEdges(). |
EdgeIterator |
undirectedEdges()
Built on edges() and isDirected(.) |
Methods inherited from class nz.ac.waikato.jdsl.core.ref.AbstractPositionalContainer |
---|
isEmpty, swapElements |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface nz.ac.waikato.jdsl.graph.api.InspectableGraph |
---|
anEdge, anIncidentEdge, anIncidentEdge, areIncident, aVertex, degree, degree, destination, edges, endVertices, incidentEdges, incidentEdges, isDirected, numEdges, numVertices, opposite, origin, vertices |
Methods inherited from interface nz.ac.waikato.jdsl.core.api.InspectableContainer |
---|
contains, elements, isEmpty |
Methods inherited from interface nz.ac.waikato.jdsl.core.api.Container |
---|
newContainer, replaceElement |
Constructor Detail |
---|
protected AbstractGraph()
Method Detail |
---|
public int size()
O(1)
size
in interface InspectableContainer
InspectableGraph.numVertices()
,
InspectableGraph.numEdges()
public PositionIterator positions()
O(V+E)
positions
in interface InspectablePositionalContainer
InspectableGraph.vertices()
,
InspectableGraph.edges()
public EdgeIterator directedEdges()
O(E)
directedEdges
in interface InspectableGraph
InspectableGraph.edges()
,
InspectableGraph.isDirected(Edge)
public EdgeIterator undirectedEdges()
O(E)
undirectedEdges
in interface InspectableGraph
InspectableGraph.edges()
,
InspectableGraph.isDirected(Edge)
public VertexIterator adjacentVertices(Vertex v)
O(deg[v])
adjacentVertices
in interface InspectableGraph
v
- a vertex
v
by undirected,
incoming and outgoing edgesInspectableGraph.incidentEdges(Vertex)
public VertexIterator adjacentVertices(Vertex v, int edgetype)
O(deg[v])
adjacentVertices
in interface InspectableGraph
v
- a vertexedgetype
- A constant from the EdgeDirection
interface
v
by edges of the specified typeInspectableGraph.incidentEdges(Vertex)
public boolean areAdjacent(Vertex v1, Vertex v2)
O( min(v1.degree,v2.degree) )
areAdjacent
in interface InspectableGraph
v1
- a vertexv2
- a vertex
v1
and v2
are adjacent,
i.e., whether they are
the endvertices of a common edgeInspectableGraph.areAdjacent(Vertex,Vertex)
public boolean areAdjacent(Edge e1, Edge e2)
O(1)
areAdjacent
in interface InspectableGraph
e1
- an edgee2
- an edge
e1
and e2
are adjacent,
i.e., whether they have at least one common endvertexInspectableGraph.endVertices(Edge)
public EdgeIterator connectingEdges(Vertex v1, Vertex v2)
O( min(v1.degree,v2.degree) )
connectingEdges
in interface InspectableGraph
v1
- a vertexv2
- a vertex
v1
and v2
InspectableGraph.incidentEdges(Vertex)
public Edge aConnectingEdge(Vertex v1, Vertex v2)
O( min(v1.degree,v2.degree) )
aConnectingEdge
in interface InspectableGraph
v1
- a vertexv2
- a vertex
v1
and v2
,
or Edge.NONE if there is no such edgeInspectableGraph.incidentEdges(Vertex)
public Vertex aCommonVertex(Edge e1, Edge e2)
O(1)
aCommonVertex
in interface InspectableGraph
e1
- an edgee2
- an edge
e1
and e2
, or Vertex.NONE if there is
no such vertexInspectableGraph.endVertices(Edge)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |