Package org.aksw.commons.util.algebra
Class GenericDag<E,V>
java.lang.Object
org.aksw.commons.util.algebra.GenericDag<E,V>
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionGenericDag(ExprOps<E, V> exprOps, Supplier<V> nextVar, ExprFilter<E> isBlocker) -
Method Summary
Modifier and TypeMethodDescriptionCallfactorize(Object)and add the result as a new rootGenericDag<E,V> applyVarTransform(Function<V, V> remap) GenericDag<E,V> Create a copy of this dag.voidcollapse()Return a new DAG where nodes with just a single parent are collapsedprotected voidMerge and remove all non-root nodes having only a single parent into the parent.static <E,V> com.google.common.graph.SuccessorsFunction<E> createSuccessorFunction(GenericDag<E, V> dag) Successor function for use with guava's traverserstatic <E,V> void depthFirstTraverse(GenericDag<E, V> dag, E parent, int childIdx, E child, ExprFilter<E> isBlocked, Consumer<E> visitor) static <E,V> E expand(GenericDag<E, V> dag, E root) Recursively expand a given expression against the dag by means of substituting variables with available definitions from the dag.Factorize the argument expression against the state of this object.static <E,V> Set<E> getCoreDefinitions(GenericDag<E, V> dag) static <E,V> Set<E> getCoreDefinitions(GenericDag<E, V> dag, Collection<E> roots) Return the set of definitions where at least 1 mentioned variable does not have a definition.getRoots()static <E,V> Map<V, E> getSortedDependencies(GenericDag<E, V> dag) static <E,V> void getSortedDependencies(GenericDag<E, V> dag, E node, Map<V, E> acc) static <E,V> Map<V, E> getSortedDependencies(GenericDag<E, V> dag, Collection<E> roots) For the given set of roots return an ordered set of expression such that if any expression y depends on x then x comes earlier in the list.static <E,V> Set<V> getUndefinedVars(GenericDag<E, V> dag) static <E,V> Set<V> getUndefinedVars(GenericDag<E, V> dag, Collection<E> roots) Return the set of variables that do not have a definition in the dagGenericDag<E,V> subDag(Collection<E> roots) Create a dag which only contains expressions reachable from the given roots
-
Field Details
-
exprOps
-
isBlocker
-
exprFactorizer
-
nextVar
-
varToExpr
-
roots
-
-
Constructor Details
-
GenericDag
-
-
Method Details
-
subDag
Create a dag which only contains expressions reachable from the given roots -
applyVarTransform
-
cloneObject
Create a copy of this dag. Caution: The nextVar supplier of the clone is presently shared with the origin instance. -
getExprOps
-
factorize
Factorize the argument expression against the state of this object. Adds all sub expression to the varToExpr map. -
addRoot
Callfactorize(Object)and add the result as a new root -
getExprFactorizer
-
getVarToExpr
-
getRoots
-
getExpr
-
getVar
-
remove
-
getChildToParent
-
getVarsWithMultipleParents
-
collapse
public void collapse()Return a new DAG where nodes with just a single parent are collapsed -
collapse
Merge and remove all non-root nodes having only a single parent into the parent. -
expand
Recursively expand a given expression against the dag by means of substituting variables with available definitions from the dag. Does not cause any change in the dag. -
getSortedDependencies
-
getSortedDependencies
For the given set of roots return an ordered set of expression such that if any expression y depends on x then x comes earlier in the list. TODO Clarify whether roots that are variables need to be added or not... // Root nodes that are variables but do not have a definition are added as (root, null) entries. -
getSortedDependencies
-
getUndefinedVars
-
getUndefinedVars
Return the set of variables that do not have a definition in the dag -
getCoreDefinitions
-
getCoreDefinitions
Return the set of definitions where at least 1 mentioned variable does not have a definition. This is the set of expressions that mention variables in the set of#getUndefinedVars(GenericDag, Set) -
createSuccessorFunction
public static <E,V> com.google.common.graph.SuccessorsFunction<E> createSuccessorFunction(GenericDag<E, V> dag) Successor function for use with guava's traverser -
depthFirstTraverse
public static <E,V> void depthFirstTraverse(GenericDag<E, V> dag, E parent, int childIdx, E child, ExprFilter<E> isBlocked, Consumer<E> visitor)
-