V
- the type parameter of the nodes in the graph data sourcepublic class IncSCCAlg<V> extends java.lang.Object implements IGraphObserver<V>, ITcDataSource<V>
Modifier and Type | Field and Description |
---|---|
IBiDirectionalGraphDataSource<V> |
gds |
UnionFind<V> |
sccs |
Constructor and Description |
---|
IncSCCAlg(IGraphDataSource<V> graphDataSource) |
Modifier and Type | Method and Description |
---|---|
void |
attachObserver(ITcObserver<V> to)
Attach a transitive closure relation observer.
|
boolean |
checkTcRelation(DRedTcRelation<V> tc) |
void |
detachObserver(ITcObserver<V> to)
Detach a transitive closure relation observer.
|
void |
dispose()
Call this method to properly dispose the data structures of a transitive closure algorithm.
|
void |
edgeDeleted(V source,
V target)
Used to notify when an edge is deleted from the graph.
|
void |
edgeInserted(V source,
V target)
Used to notify when an edge is inserted into the graph.
|
java.util.Set<V> |
getAllReachableSources(V target)
Returns all nodes from which the target node is reachable.
|
java.util.Set<V> |
getAllReachableTargets(V source)
Returns all nodes which are reachable from the source node.
|
IGraphPathFinder<V> |
getPathFinder()
The returned
IGraphPathFinder can be used to retrieve paths between nodes using transitive reachability. |
java.util.List<V> |
getReachabilityPath(V source,
V target)
Returns a reachability path between the given source and target elements, or null if no such transitive reachability is present in the graph.
|
java.util.Set<Tuple<V>> |
getTcRelation() |
boolean |
isIsolated(V node) |
boolean |
isReachable(V source,
V target)
Returns true if the target node is reachable from the source node.
|
void |
nodeDeleted(V n)
Used to notify when a node is deleted from the graph.
|
void |
nodeInserted(V n)
Used to notify when a node is inserted into the graph.
|
public IBiDirectionalGraphDataSource<V> gds
public IncSCCAlg(IGraphDataSource<V> graphDataSource)
public void edgeInserted(V source, V target)
IGraphObserver
edgeInserted
in interface IGraphObserver<V>
source
- the source of the edgetarget
- the target of the edgepublic void edgeDeleted(V source, V target)
IGraphObserver
edgeDeleted
in interface IGraphObserver<V>
source
- the source of the edgetarget
- the target of the edgepublic void nodeInserted(V n)
IGraphObserver
nodeInserted
in interface IGraphObserver<V>
n
- the nodepublic void nodeDeleted(V n)
IGraphObserver
nodeDeleted
in interface IGraphObserver<V>
n
- the nodepublic void attachObserver(ITcObserver<V> to)
ITcDataSource
attachObserver
in interface ITcDataSource<V>
to
- the observer objectpublic void detachObserver(ITcObserver<V> to)
ITcDataSource
detachObserver
in interface ITcDataSource<V>
to
- the observer objectpublic java.util.Set<V> getAllReachableTargets(V source)
ITcDataSource
getAllReachableTargets
in interface ITcDataSource<V>
source
- the source nodepublic java.util.Set<V> getAllReachableSources(V target)
ITcDataSource
getAllReachableSources
in interface ITcDataSource<V>
target
- the target nodepublic boolean isReachable(V source, V target)
ITcDataSource
isReachable
in interface ITcDataSource<V>
source
- the source nodetarget
- the target nodepublic java.util.List<V> getReachabilityPath(V source, V target)
ITcDataSource
List
contains the nodes along the path
(this means that there is an edge in the graph between two consecutive nodes), including the source and target nodes.
A self loop (one edge) is indicated with the source node being present two times in the returned List
.
Note that the paths are not maintained incrementally and in worst case the complexity of the path construction is O(|V|+|E|)
(one depth-first graph traversal). There is no guarantee that the given path is the shortest one between the given two nodes.getReachabilityPath
in interface ITcDataSource<V>
source
- the source nodetarget
- the target nodepublic boolean checkTcRelation(DRedTcRelation<V> tc)
public void dispose()
ITcDataSource
dispose
in interface ITcDataSource<V>
public boolean isIsolated(V node)
public IGraphPathFinder<V> getPathFinder()
ITcDataSource
IGraphPathFinder
can be used to retrieve paths between nodes using transitive reachability.getPathFinder
in interface ITcDataSource<V>