Class GenericDag<E,V>

java.lang.Object
org.aksw.commons.util.algebra.GenericDag<E,V>

public class GenericDag<E,V> extends Object
  • Field Details

    • exprOps

      protected ExprOps<E,V> exprOps
    • isBlocker

      protected ExprFilter<E> isBlocker
    • exprFactorizer

      protected GenericFactorizer<E,V> exprFactorizer
    • nextVar

      protected Supplier<V> nextVar
    • varToExpr

      protected com.google.common.collect.BiMap<V,E> varToExpr
    • roots

      protected Set<E> roots
  • Constructor Details

  • Method Details

    • subDag

      public GenericDag<E,V> subDag(Collection<E> roots)
      Create a dag which only contains expressions reachable from the given roots
    • applyVarTransform

      public GenericDag<E,V> applyVarTransform(Function<V,V> remap)
    • cloneObject

      public GenericDag<E,V> cloneObject()
      Create a copy of this dag. Caution: The nextVar supplier of the clone is presently shared with the origin instance.
    • getExprOps

      public ExprOps<E,V> getExprOps()
    • factorize

      public E factorize(E expr)
      Factorize the argument expression against the state of this object. Adds all sub expression to the varToExpr map.
    • addRoot

      public E addRoot(E expr)
      Call factorize(Object) and add the result as a new root
    • getExprFactorizer

      public GenericFactorizer<E,V> getExprFactorizer()
    • getVarToExpr

      public com.google.common.collect.BiMap<V,E> getVarToExpr()
    • getRoots

      public Set<E> getRoots()
    • getExpr

      public E getExpr(V var)
    • getVar

      public V getVar(E expr)
    • remove

      public E remove(V var)
    • getChildToParent

      public com.google.common.collect.Multimap<V,V> getChildToParent()
    • getVarsWithMultipleParents

      public Set<V> getVarsWithMultipleParents()
    • collapse

      public void collapse()
      Return a new DAG where nodes with just a single parent are collapsed
    • collapse

      protected void collapse(E expr, com.google.common.collect.Multimap<V,V> mm)
      Merge and remove all non-root nodes having only a single parent into the parent.
    • expand

      public 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. Does not cause any change in the dag.
    • getSortedDependencies

      public static <E,V> Map<V,E> getSortedDependencies(GenericDag<E,V> dag)
    • getSortedDependencies

      public 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. 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

      public static <E,V> void getSortedDependencies(GenericDag<E,V> dag, E node, Map<V,E> acc)
    • getUndefinedVars

      public static <E,V> Set<V> getUndefinedVars(GenericDag<E,V> dag)
    • getUndefinedVars

      public 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 dag
    • getCoreDefinitions

      public static <E,V> Set<E> getCoreDefinitions(GenericDag<E,V> dag)
    • getCoreDefinitions

      public 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. This is the set of expressions that mention variables in the set of
      invalid reference
      #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)