Class DRedAlg<V>
java.lang.Object
tools.refinery.interpreter.rete.itc.alg.dred.DRedAlg<V>
- Type Parameters:
V
- the type parameter of the nodes in the graph data source
- All Implemented Interfaces:
IGraphObserver<V>
,ITcDataSource<V>
This class is the optimized implementation of the DRED algorithm.
-
Constructor Summary
ConstructorsConstructorDescriptionDRedAlg
(IGraphDataSource<V> gds) Constructs a new DRED algorithm and initializes the transitive closure relation with the given graph data source.DRedAlg
(IGraphDataSource<V> gds, DRedTcRelation<V> tc) Constructs a new DRED algorithm and initializes the transitive closure relation with the given relation. -
Method Summary
Modifier and TypeMethodDescriptionvoid
attachObserver
(ITcObserver<V> to) Attach a transitive closure relation observer.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.getAllReachableSources
(V target) Returns all nodes from which the target node is reachable.getAllReachableTargets
(V source) Returns all nodes which are reachable from the source node.The returnedIGraphPathFinder
can be used to retrieve paths between nodes using transitive reachability.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.protected void
notifyTcObservers
(Set<Tuple<V>> tuples, int dir) void
setTcRelation
(DRedTcRelation<V> tc)
-
Constructor Details
-
DRedAlg
Constructs a new DRED algorithm and initializes the transitive closure relation with the given graph data source. Attach itself on the graph data source as an observer.- Parameters:
gds
- the graph data source instance
-
DRedAlg
Constructs a new DRED algorithm and initializes the transitive closure relation with the given relation. Attach itself on the graph data source as an observer.- Parameters:
gds
- the graph data source instancetc
- the transitive closure instance
-
-
Method Details
-
edgeInserted
Description copied from interface:IGraphObserver
Used to notify when an edge is inserted into the graph.- Specified by:
edgeInserted
in interfaceIGraphObserver<V>
- Parameters:
source
- the source of the edgetarget
- the target of the edge
-
edgeDeleted
Description copied from interface:IGraphObserver
Used to notify when an edge is deleted from the graph.- Specified by:
edgeDeleted
in interfaceIGraphObserver<V>
- Parameters:
source
- the source of the edgetarget
- the target of the edge
-
nodeInserted
Description copied from interface:IGraphObserver
Used to notify when a node is inserted into the graph.- Specified by:
nodeInserted
in interfaceIGraphObserver<V>
- Parameters:
n
- the node
-
nodeDeleted
Description copied from interface:IGraphObserver
Used to notify when a node is deleted from the graph.- Specified by:
nodeDeleted
in interfaceIGraphObserver<V>
- Parameters:
n
- the node
-
getTcRelation
-
setTcRelation
-
isReachable
Description copied from interface:ITcDataSource
Returns true if the target node is reachable from the source node.- Specified by:
isReachable
in interfaceITcDataSource<V>
- Parameters:
source
- the source nodetarget
- the target node- Returns:
- true if target is reachable from source, false otherwise
-
attachObserver
Description copied from interface:ITcDataSource
Attach a transitive closure relation observer.- Specified by:
attachObserver
in interfaceITcDataSource<V>
- Parameters:
to
- the observer object
-
detachObserver
Description copied from interface:ITcDataSource
Detach a transitive closure relation observer.- Specified by:
detachObserver
in interfaceITcDataSource<V>
- Parameters:
to
- the observer object
-
getAllReachableTargets
Description copied from interface:ITcDataSource
Returns all nodes which are reachable from the source node.- Specified by:
getAllReachableTargets
in interfaceITcDataSource<V>
- Parameters:
source
- the source node- Returns:
- the set of target nodes
-
getAllReachableSources
Description copied from interface:ITcDataSource
Returns all nodes from which the target node is reachable.- Specified by:
getAllReachableSources
in interfaceITcDataSource<V>
- Parameters:
target
- the target node- Returns:
- the set of source nodes
-
notifyTcObservers
-
dispose
public void dispose()Description copied from interface:ITcDataSource
Call this method to properly dispose the data structures of a transitive closure algorithm.- Specified by:
dispose
in interfaceITcDataSource<V>
-
getPathFinder
Description copied from interface:ITcDataSource
The returnedIGraphPathFinder
can be used to retrieve paths between nodes using transitive reachability.- Specified by:
getPathFinder
in interfaceITcDataSource<V>
- Returns:
- a path finder for the graph.
-