|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.AbstractCollection<E>
java.util.AbstractList<E>
java.util.AbstractSequentialList<E>
ch.bfh.algo.core.sequence.GenericLinkedSequence<V,PV>
ch.bfh.algo.core.graph.GenericAdjacencyListGraph<E,V,PE,PV>
public class GenericAdjacencyListGraph<E,V,PE extends GenericEdge<E,V,PE,PV>,PV extends GenericVertex<E,V,PE,PV>>
Field Summary | |
---|---|
protected GraphFactory<PE,PV> |
factory
|
Fields inherited from class java.util.AbstractList |
---|
modCount |
Constructor Summary | |
---|---|
GenericAdjacencyListGraph(GraphFactory<PE,PV> factory,
boolean directed)
|
Method Summary | |
---|---|
PositionList<V,PV> |
adjacentVertices(Position<?> vertex,
Direction type)
Returns a list of the vertices adjacent to vertex . |
PositionList<V,PV> |
adjacentVertices(PV vertex,
Direction type)
|
V |
delete(PV position)
|
E |
deleteEdge(PE position)
|
E |
deleteEdge(Position<?> position)
Deletes the edge position . |
V |
deleteVertex(Position<?> position)
Deletes the vertex position . |
V |
deleteVertex(PV position)
|
PV |
destination(PE edge)
|
PV |
destination(Position<?> edge)
Returns the destination of the edge edge |
void |
detach(Position<?> edge,
Position<?> vertex)
Separates edge from one of its extremities, the vertex vertex . |
void |
detachVertex(PE edge,
PV vertex)
|
E |
edgeElement(PE edge)
|
E |
edgeElement(Position<?> edge)
Returns the element contained in edge |
GenericSequence<E,PE> |
edgeElements()
Returns a list of all elements contained in the edges. |
PositionList<E,PE> |
edges()
Returns a list of all the edges contained in the graph. |
PositionList<E,PE> |
edges(Direction type)
Returns a list of all the edges of a desired type. |
GraphFactory<PE,PV> |
getFactory()
|
PositionList<E,PE> |
incidentEdges(Position<?> vertex,
Direction type)
Returns a list of the incident edges of the vertex . |
PositionList<E,PE> |
incidentEdges(PV vertex,
Direction type)
|
PV |
insertAfter(PV position,
V element)
|
PV |
insertBefore(PV position,
V element)
|
protected PV |
insertBetween(PV previous,
PV next,
V element,
PV position)
|
PE |
insertEdge(E element)
Creates a new edge containing the element . |
Position<E> |
insertEdge(E element,
Position<?> origin,
Position<?> destination)
Creates a new edge containing the element . |
PE |
insertEdge(E element,
PV origin,
PV destination)
|
PV |
insertVertex(V element)
Creates a new vertex containing the element . |
boolean |
isDirected(PE edge)
|
boolean |
isDirected(Position<?> edge)
Verifies if an edge is directed. |
PV |
opposite(PE edge,
PV vertex)
|
PV |
opposite(Position<?> edge,
Position<?> vertex)
Returns the vertex that is opposite to the vertex vertex on the edge edge . |
PV |
origin(PE edge)
|
PV |
origin(Position<?> edge)
Returns the origine of the edge edge |
PositionListIterator<V,PV> |
positionListIterator()
The positionListIterator method creates and return a ListIterator for the Position s contained in the sequence. |
PositionListIterator<V,PV> |
positionListIterator(int rank)
The positionListIterator method creates and return a ListIterator for the Position s contained in the sequence. |
E |
replaceEdge(Position<?> edge,
E element)
Replaces the element contained in the edge edge by element . |
V |
replaceVertex(Position<?> vertex,
V element)
Replaces the element contained in the vertex vertex by element . |
void |
reverse(PE edge)
|
void |
reverse(Position<?> edge)
Exchanges the two extremities of an edge. |
void |
setDestination(PE edge,
PV destination)
|
void |
setDestination(Position<?> edge,
Position<?> vertex)
Defines the vertex vertex to be the new destination of the edge edge . |
void |
setDirected(PE edge)
|
void |
setDirected(Position<?> edge)
Defines the edge as a directed edge. |
LinkedPosition<PE> |
setOrigin(PE edge,
PV origin)
|
void |
setOrigin(Position<?> edge,
Position<?> vertex)
Defines the vertex vertex to be the new origin of the edge edge . |
LinkedPosition<PE> |
setOriginAfter(PE edge,
PV origin,
LinkedPosition<PE> position)
|
LinkedPosition<PE> |
setOriginBefore(PE edge,
PV origin,
LinkedPosition<PE> position)
|
void |
setUndirected(PE edge)
|
void |
setUndirected(Position<?> edge)
Defines the edge as an undirected edge. |
void |
swapEdge(Position<?> edge0,
Position<?> edge1)
Exchanges the content of the two edges edge0 and edge1 . |
void |
swapVertex(Position<?> vertex0,
Position<?> vertex1)
Exchanges the content of the two vertices vertex0 and vertex1 . |
V |
vertexElement(Position<?> vertex)
Returns the element contained in vertex |
GenericSequence<V,PV> |
vertexElements()
Returns a list of all elements contained in the vertices. |
PositionList<V,PV> |
vertices()
Returns a list of all the vertices contained in the graph. |
Methods inherited from class ch.bfh.algo.core.sequence.GenericLinkedSequence |
---|
after, after, before, before, delete, element, element, encloses, encloses, first, head, insert, insert, insertAfter, insertBefore, insertBetween, last, listIterator, position, positionIterator, rank, rank, replace, replace, size, swap, swap, tail, validate |
Methods inherited from class java.util.AbstractSequentialList |
---|
add, addAll, get, iterator, remove, set |
Methods inherited from class java.util.AbstractList |
---|
add, clear, equals, hashCode, indexOf, lastIndexOf, listIterator, removeRange, subList |
Methods inherited from class java.util.AbstractCollection |
---|
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toString |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface ch.bfh.algo.core.GenericContainer |
---|
insert, positionIterator |
Methods inherited from interface ch.bfh.algo.Container |
---|
delete, element, encloses, replace, swap |
Methods inherited from interface java.util.Collection |
---|
add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray |
Methods inherited from interface ch.bfh.algo.Container |
---|
delete, element, encloses, replace, swap |
Methods inherited from interface java.util.Collection |
---|
add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray |
Methods inherited from interface java.util.List |
---|
add, add, addAll, addAll, clear, contains, containsAll, equals, get, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, remove, remove, removeAll, retainAll, set, subList, toArray, toArray |
Field Detail |
---|
protected final GraphFactory<PE extends GenericEdge<E,V,PE,PV>,PV extends GenericVertex<E,V,PE,PV>> factory
Constructor Detail |
---|
public GenericAdjacencyListGraph(GraphFactory<PE,PV> factory, boolean directed)
Method Detail |
---|
public GraphFactory<PE,PV> getFactory()
protected PV insertBetween(PV previous, PV next, V element, PV position)
insertBetween
in class GenericLinkedSequence<V,PV extends GenericVertex<E,V,PE,PV>>
public PV insertVertex(V element)
Graph
element
. This
vertex is then returned (it is a
Position<V>
).
insertVertex
in interface GenericGraph<E,V,PE extends GenericEdge<E,V,PE,PV>,PV extends GenericVertex<E,V,PE,PV>>
insertVertex
in interface Graph<E,V>
element
- the element to be used as a label for the new vertex.
Position
public PE insertEdge(E element)
Graph
element
. This
edge is then returned (it is a Position<E>
).
The edge does not have any extremities (adjacent
vertices). They have to be defined afterward.
insertEdge
in interface GenericGraph<E,V,PE extends GenericEdge<E,V,PE,PV>,PV extends GenericVertex<E,V,PE,PV>>
insertEdge
in interface Graph<E,V>
element
- the element to be used as a label for the new edge.
Position
public Position<E> insertEdge(E element, Position<?> origin, Position<?> destination) throws InvalidAccessorException
Graph
element
. Which
extremities are the two vertices origin
and
destination
. This edge is then returned (it is a
Position<E>
).
If the graph is directed, the new edge is directed; if we
have an undirected graph, then the new edge is also undirected.
insertEdge
in interface Graph<E,V>
element
- the element to be used as a label for the new edge.origin
- the vertex that will be the origin of the new edgedestination
- the vertex that will become the destination
of the new edge.
Position
InvalidAccessorException
public PE insertEdge(E element, PV origin, PV destination)
insertEdge
in interface GenericGraph<E,V,PE extends GenericEdge<E,V,PE,PV>,PV extends GenericVertex<E,V,PE,PV>>
public V delete(PV position)
delete
in class GenericLinkedSequence<V,PV extends GenericVertex<E,V,PE,PV>>
public V deleteVertex(PV position)
public V deleteVertex(Position<?> position) throws InvalidAccessorException
Graph
position
. This also removes all
the edges that had position for an extremity.
deleteVertex
in interface Graph<E,V>
position
- the vertex to be removed from the graph.
InvalidAccessorException
- if the position is not a
valide vertex of this graph.public E deleteEdge(Position<?> position) throws InvalidAccessorException
Graph
position
. The edge is
automatically removed from the two vertices at its extremities.
deleteEdge
in interface Graph<E,V>
position
- the edge to be removed from the graph.
InvalidAccessorException
- if the position is not a
valide edge of this graph.public E deleteEdge(PE position)
public PositionList<V,PV> vertices()
Graph
vertices
in interface GenericGraph<E,V,PE extends GenericEdge<E,V,PE,PV>,PV extends GenericVertex<E,V,PE,PV>>
vertices
in interface Graph<E,V>
public PositionList<E,PE> edges()
Graph
edges
in interface GenericGraph<E,V,PE extends GenericEdge<E,V,PE,PV>,PV extends GenericVertex<E,V,PE,PV>>
edges
in interface Graph<E,V>
public PositionList<E,PE> edges(Direction type)
Graph
type
can have the following values:
Direction.DIRECTED
Direction.UNDIRECTED
Direction.ALL
edges
in interface GenericGraph<E,V,PE extends GenericEdge<E,V,PE,PV>,PV extends GenericVertex<E,V,PE,PV>>
edges
in interface Graph<E,V>
type
- the type of the edges
public PositionList<E,PE> incidentEdges(Position<?> vertex, Direction type)
Graph
vertex
. Depending on the value of
type
, the result is different.
type==Direction.IN
the method returns
the in incident edgestype==Direction.OUT
the method returns the
out incident edgestype==Direction.ALL
then the method
returns all the incident edges (including the undirected
ones).
incidentEdges
in interface GenericGraph<E,V,PE extends GenericEdge<E,V,PE,PV>,PV extends GenericVertex<E,V,PE,PV>>
incidentEdges
in interface Graph<E,V>
vertex
- the vertextype
- the type of the edges
public PositionList<E,PE> incidentEdges(PV vertex, Direction type)
public PositionList<V,PV> adjacentVertices(Position<?> vertex, Direction type)
Graph
vertex
. Depending on the value of
type
, the result is different.
type==Direction.IN
the method returns
the vertices linked to vertex
through an in incident edgetype==Direction.OUT
the method returns the
vertices linked to vertex
through an out incident edgestype==Direction.ALL
then the method
returns all the adjacent vertices.
adjacentVertices
in interface GenericGraph<E,V,PE extends GenericEdge<E,V,PE,PV>,PV extends GenericVertex<E,V,PE,PV>>
adjacentVertices
in interface Graph<E,V>
vertex
- the vertextype
- the type of the edges
public PositionList<V,PV> adjacentVertices(PV vertex, Direction type)
public void setOrigin(Position<?> edge, Position<?> vertex)
Graph
vertex
to be the new origin of the edge edge
.
If the edge is undirected, origin is simply one of the two extremities.
setOrigin
in interface Graph<E,V>
edge
- the edge whose origin is being definedvertex
- the new originpublic LinkedPosition<PE> setOrigin(PE edge, PV origin)
public LinkedPosition<PE> setOriginBefore(PE edge, PV origin, LinkedPosition<PE> position)
public LinkedPosition<PE> setOriginAfter(PE edge, PV origin, LinkedPosition<PE> position)
public void setDestination(Position<?> edge, Position<?> vertex)
Graph
vertex
to be the new destination of the edge edge
.
If the edge is undirected, destination is simply one of the two extremities.
setDestination
in interface Graph<E,V>
edge
- the edge whose destination is being definedvertex
- the new destination.public void setDestination(PE edge, PV destination)
public void detach(Position<?> edge, Position<?> vertex)
Graph
edge
from one of its extremities, the vertex vertex
.
detach
in interface Graph<E,V>
edge
- an edgevertex
- one of the two extremities of edgepublic void detachVertex(PE edge, PV vertex)
public PV origin(Position<?> edge)
Graph
edge
origin
in interface GenericGraph<E,V,PE extends GenericEdge<E,V,PE,PV>,PV extends GenericVertex<E,V,PE,PV>>
origin
in interface Graph<E,V>
edge
- an edge
public PV origin(PE edge)
public PV destination(Position<?> edge)
Graph
edge
destination
in interface GenericGraph<E,V,PE extends GenericEdge<E,V,PE,PV>,PV extends GenericVertex<E,V,PE,PV>>
destination
in interface Graph<E,V>
edge
- an edge
public PV destination(PE edge)
public void setDirected(Position<?> edge)
Graph
edge
as a directed edge.
setDirected
in interface Graph<E,V>
edge
- an edgepublic void setDirected(PE edge)
public void setUndirected(Position<?> edge)
Graph
edge
as an undirected edge.
setUndirected
in interface Graph<E,V>
edge
- an edgepublic void setUndirected(PE edge)
public boolean isDirected(Position<?> edge)
Graph
isDirected
in interface Graph<E,V>
edge
- an edge
edge
is directedpublic boolean isDirected(PE edge)
public void reverse(Position<?> edge)
Graph
reverse
in interface Graph<E,V>
edge
- an edgepublic void reverse(PE edge)
public PV opposite(Position<?> edge, Position<?> vertex)
Graph
vertex
on the edge edge
. It
vertex
is the origin of edge
, then it
returns its destination, and it returns its origin if
vertex
is the destination of edge
.
opposite
in interface GenericGraph<E,V,PE extends GenericEdge<E,V,PE,PV>,PV extends GenericVertex<E,V,PE,PV>>
opposite
in interface Graph<E,V>
edge
- an edgepublic PV opposite(PE edge, PV vertex)
public V replaceVertex(Position<?> vertex, V element)
Graph
vertex
by element
.
replaceVertex
in interface Graph<E,V>
vertex
- the vertex whose element will be replaced;element
- the new label of the vertex
.
vertex
that has just be replaced.public E replaceEdge(Position<?> edge, E element)
Graph
edge
by element
.
replaceEdge
in interface Graph<E,V>
edge
- the edge whose element will be replaced;element
- the new label of the edge
.
edge
that has just be replaced.public void swapEdge(Position<?> edge0, Position<?> edge1)
Graph
edge0
and edge1
.
swapEdge
in interface Graph<E,V>
edge0
- the first edgeedge1
- the second edgepublic void swapVertex(Position<?> vertex0, Position<?> vertex1)
Graph
vertex0
and vertex1
.
swapVertex
in interface Graph<E,V>
vertex0
- the first vertexvertex1
- the second vertexpublic GenericSequence<V,PV> vertexElements()
Graph
vertexElements
in interface Graph<E,V>
public GenericSequence<E,PE> edgeElements()
Graph
edgeElements
in interface Graph<E,V>
public PV insertBefore(PV position, V element)
insertBefore
in class GenericLinkedSequence<V,PV extends GenericVertex<E,V,PE,PV>>
public PV insertAfter(PV position, V element)
insertAfter
in class GenericLinkedSequence<V,PV extends GenericVertex<E,V,PE,PV>>
public PositionListIterator<V,PV> positionListIterator()
Sequence
positionListIterator
method creates and return a ListIterator
for the Position
s contained in the sequence.
This method gives the possibility to iterate over all the
Positions in the sequence.
positionListIterator
in interface GenericSequence<V,PV extends GenericVertex<E,V,PE,PV>>
positionListIterator
in interface Sequence<V>
positionListIterator
in class GenericLinkedSequence<V,PV extends GenericVertex<E,V,PE,PV>>
ListIterator<Position<E>>
of all the Position
s in the sequence.public PositionListIterator<V,PV> positionListIterator(int rank)
Sequence
positionListIterator
method creates and return a ListIterator
for the Position
s contained in the sequence. This iterator is initially placed at the rank given as a parmeter
This method gives the possibility to iterate over all the
Positions in the sequence.
positionListIterator
in interface GenericSequence<V,PV extends GenericVertex<E,V,PE,PV>>
positionListIterator
in interface Sequence<V>
positionListIterator
in class GenericLinkedSequence<V,PV extends GenericVertex<E,V,PE,PV>>
rank
- an int
denoting the initial position
of the pointer of the iterator.
ListIterator<Position<E>>
of
all the Position
s in the sequence.public E edgeElement(Position<?> edge)
Graph
edge
edgeElement
in interface Graph<E,V>
edge
- the edge containing the element
public E edgeElement(PE edge)
public V vertexElement(Position<?> vertex)
Graph
vertex
vertexElement
in interface Graph<E,V>
vertex
- the vertex containing the element
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |