Class DRedAlg<V>
- java.lang.Object
-
- org.eclipse.viatra.query.runtime.base.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>
public class DRedAlg<V> extends java.lang.Object implements IGraphObserver<V>, ITcDataSource<V>
This class is the optimized implementation of the DRED algorithm.
-
-
Constructor Summary
Constructors Constructor Description DRedAlg(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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidattachObserver(ITcObserver<V> to)Attach a transitive closure relation observer.voiddetachObserver(ITcObserver<V> to)Detach a transitive closure relation observer.voiddispose()Call this method to properly dispose the data structures of a transitive closure algorithm.voidedgeDeleted(V source, V target)Used to notify when an edge is deleted from the graph.voidedgeInserted(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 returnedIGraphPathFindercan be used to retrieve paths between nodes using transitive reachability.DRedTcRelation<V>getTcRelation()booleanisReachable(V source, V target)Returns true if the target node is reachable from the source node.voidnodeDeleted(V n)Used to notify when a node is deleted from the graph.voidnodeInserted(V n)Used to notify when a node is inserted into the graph.protected voidnotifyTcObservers(java.util.Set<Tuple<V>> tuples, int dir)voidsetTcRelation(DRedTcRelation<V> tc)
-
-
-
Constructor Detail
-
DRedAlg
public DRedAlg(IGraphDataSource<V> gds)
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
public DRedAlg(IGraphDataSource<V> gds, DRedTcRelation<V> tc)
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 Detail
-
edgeInserted
public void edgeInserted(V source, V target)
Description copied from interface:IGraphObserverUsed to notify when an edge is inserted into the graph.- Specified by:
edgeInsertedin interfaceIGraphObserver<V>- Parameters:
source- the source of the edgetarget- the target of the edge
-
edgeDeleted
public void edgeDeleted(V source, V target)
Description copied from interface:IGraphObserverUsed to notify when an edge is deleted from the graph.- Specified by:
edgeDeletedin interfaceIGraphObserver<V>- Parameters:
source- the source of the edgetarget- the target of the edge
-
nodeInserted
public void nodeInserted(V n)
Description copied from interface:IGraphObserverUsed to notify when a node is inserted into the graph.- Specified by:
nodeInsertedin interfaceIGraphObserver<V>- Parameters:
n- the node
-
nodeDeleted
public void nodeDeleted(V n)
Description copied from interface:IGraphObserverUsed to notify when a node is deleted from the graph.- Specified by:
nodeDeletedin interfaceIGraphObserver<V>- Parameters:
n- the node
-
getTcRelation
public DRedTcRelation<V> getTcRelation()
-
setTcRelation
public void setTcRelation(DRedTcRelation<V> tc)
-
isReachable
public boolean isReachable(V source, V target)
Description copied from interface:ITcDataSourceReturns true if the target node is reachable from the source node.- Specified by:
isReachablein interfaceITcDataSource<V>- Parameters:
source- the source nodetarget- the target node- Returns:
- true if target is reachable from source, false otherwise
-
attachObserver
public void attachObserver(ITcObserver<V> to)
Description copied from interface:ITcDataSourceAttach a transitive closure relation observer.- Specified by:
attachObserverin interfaceITcDataSource<V>- Parameters:
to- the observer object
-
detachObserver
public void detachObserver(ITcObserver<V> to)
Description copied from interface:ITcDataSourceDetach a transitive closure relation observer.- Specified by:
detachObserverin interfaceITcDataSource<V>- Parameters:
to- the observer object
-
getAllReachableTargets
public java.util.Set<V> getAllReachableTargets(V source)
Description copied from interface:ITcDataSourceReturns all nodes which are reachable from the source node.- Specified by:
getAllReachableTargetsin interfaceITcDataSource<V>- Parameters:
source- the source node- Returns:
- the set of target nodes
-
getAllReachableSources
public java.util.Set<V> getAllReachableSources(V target)
Description copied from interface:ITcDataSourceReturns all nodes from which the target node is reachable.- Specified by:
getAllReachableSourcesin interfaceITcDataSource<V>- Parameters:
target- the target node- Returns:
- the set of source nodes
-
dispose
public void dispose()
Description copied from interface:ITcDataSourceCall this method to properly dispose the data structures of a transitive closure algorithm.- Specified by:
disposein interfaceITcDataSource<V>
-
getPathFinder
public IGraphPathFinder<V> getPathFinder()
Description copied from interface:ITcDataSourceThe returnedIGraphPathFindercan be used to retrieve paths between nodes using transitive reachability.- Specified by:
getPathFinderin interfaceITcDataSource<V>- Returns:
- a path finder for the graph.
-
-