java.lang.Object
org.jgrapht.traverse.AbstractGraphIterator<V,E>
- Type Parameters:
V- the graph vertex typeE- the graph edge type
- All Implemented Interfaces:
Iterator<V>,GraphIterator<V,E>
- Direct Known Subclasses:
CrossComponentIterator,DegeneracyOrderingIterator,LexBreadthFirstIterator,MaximumCardinalityIterator,TopologicalOrderIterator
An empty implementation of a graph iterator to minimize the effort required to implement graph
iterators.
- Author:
- Barak Naveh
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds the specified traversal listener to this iterator.protected EdgeTraversalEvent<E>createEdgeTraversalEvent(E edge) Create an edge traversal event.protected VertexTraversalEvent<V>createVertexTraversalEvent(V vertex) Create a vertex traversal event.protected voidInforms all listeners that the traversal of the current connected component finished.protected voidInforms all listeners that a traversal of a new connected component has started.protected voidInforms all listeners that a the specified edge was visited.protected voidInforms all listeners that a the specified vertex was finished.protected voidInforms all listeners that a the specified vertex was visited.getGraph()Get the graph being traversed.booleanTest whether this iterator is set to traverse the graph across connected components.booleanTests whether thereuseEventsflag is set.voidremove()Unsupported.voidRemoves the specified traversal listener from this iterator.voidsetCrossComponentTraversal(boolean crossComponentTraversal) Sets the cross component traversal flag - indicates whether to traverse the graph across connected components.voidsetReuseEvents(boolean reuseEvents) Sets a value thereuseEventsflag.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Iterator
forEachRemaining, hasNext, next
-
Field Details
-
nListeners
protected int nListeners -
reusableEdgeEvent
-
reusableVertexEvent
protected final org.jgrapht.traverse.AbstractGraphIterator.FlyweightVertexEvent<V> reusableVertexEvent -
graph
-
crossComponentTraversal
protected boolean crossComponentTraversal -
reuseEvents
protected boolean reuseEvents
-
-
Constructor Details
-
AbstractGraphIterator
Create a new iterator- Parameters:
graph- the graph
-
-
Method Details
-
getGraph
Get the graph being traversed.- Returns:
- the graph being traversed
-
setCrossComponentTraversal
public void setCrossComponentTraversal(boolean crossComponentTraversal) Sets the cross component traversal flag - indicates whether to traverse the graph across connected components.- Parameters:
crossComponentTraversal- iftruetraverses across connected components.
-
isCrossComponentTraversal
public boolean isCrossComponentTraversal()Test whether this iterator is set to traverse the graph across connected components.- Specified by:
isCrossComponentTraversalin interfaceGraphIterator<V,E> - Returns:
trueif traverses across connected components, otherwisefalse.
-
setReuseEvents
public void setReuseEvents(boolean reuseEvents) Description copied from interface:GraphIteratorSets a value thereuseEventsflag. If thereuseEventsflag is set totruethis class will reuse previously fired events and will not create a new object for each event. This option increases performance but should be used with care, especially in multithreaded environment.- Specified by:
setReuseEventsin interfaceGraphIterator<V,E> - Parameters:
reuseEvents- whether to reuse previously fired event objects instead of creating a new event object for each event.
-
isReuseEvents
public boolean isReuseEvents()Description copied from interface:GraphIteratorTests whether thereuseEventsflag is set. If the flag is set totruethis class will reuse previously fired events and will not create a new object for each event. This option increases performance but should be used with care, especially in multithreaded environment.- Specified by:
isReuseEventsin interfaceGraphIterator<V,E> - Returns:
- the value of the
reuseEventsflag.
-
addTraversalListener
Description copied from interface:GraphIteratorAdds the specified traversal listener to this iterator.- Specified by:
addTraversalListenerin interfaceGraphIterator<V,E> - Parameters:
l- the traversal listener to be added.
-
remove
public void remove()Description copied from interface:GraphIteratorUnsupported. -
removeTraversalListener
Description copied from interface:GraphIteratorRemoves the specified traversal listener from this iterator.- Specified by:
removeTraversalListenerin interfaceGraphIterator<V,E> - Parameters:
l- the traversal listener to be removed.
-
fireConnectedComponentFinished
Informs all listeners that the traversal of the current connected component finished.- Parameters:
e- the connected component finished event.
-
fireConnectedComponentStarted
Informs all listeners that a traversal of a new connected component has started.- Parameters:
e- the connected component started event.
-
fireEdgeTraversed
Informs all listeners that a the specified edge was visited.- Parameters:
e- the edge traversal event.
-
fireVertexTraversed
Informs all listeners that a the specified vertex was visited.- Parameters:
e- the vertex traversal event.
-
fireVertexFinished
Informs all listeners that a the specified vertex was finished.- Parameters:
e- the vertex traversal event.
-
createVertexTraversalEvent
Create a vertex traversal event.- Parameters:
vertex- the vertex- Returns:
- the event
-
createEdgeTraversalEvent
Create an edge traversal event.- Parameters:
edge- the edge- Returns:
- the event
-