Class EfficientTreeUtils


  • public class EfficientTreeUtils
    extends java.lang.Object
    • Constructor Detail

      • EfficientTreeUtils

        public EfficientTreeUtils()
    • Method Detail

      • isConsistent

        public static boolean isConsistent​(EfficientTree tree)
        Returns:
        whether the tree is consistent.
      • getParent

        public static int getParent​(EfficientTree tree,
                                    int node)
        Returns the parent of node. Do not call if node is the root. Notice that this is an expensive operation; avoid if possible.
        Parameters:
        node -
        Returns:
        The parent of node.
      • removeChild

        public static void removeChild​(EfficientTree tree,
                                       int parent,
                                       int child)
        Remove a child of a node. Only call when the child has no children itself. Note that activity names may be left behind outside of the tree.
        Parameters:
        parent -
        child -
      • replaceNodeWithTau

        public static void replaceNodeWithTau​(EfficientTree tree,
                                              int node)
        Replace a node and all of its children by a single tau.
        Parameters:
        tree -
        node -
      • isParentOf

        public static boolean isParentOf​(EfficientTree tree,
                                         int parent,
                                         int child)
        Parameters:
        parent -
        child -
        Returns:
        Whether the child is a direct or indirect child of parent.
      • getChildWith

        public static int getChildWith​(EfficientTree tree,
                                       int parent,
                                       int grandChild)
        Parameters:
        parent -
        grandChild -
        Returns:
        The child of parent that contains grandChild. If grandChild is not a child of parent, will return -1.
      • getChildNumberWith

        public static int getChildNumberWith​(EfficientTree tree,
                                             int parent,
                                             int grandChild)
        Parameters:
        parent -
        grandChild -
        Returns:
        The number of the child within parent that contains grandChild. If grandChild is not a child of parent, will return -1.
      • getLowestCommonParent

        public static int getLowestCommonParent​(EfficientTree tree,
                                                int nodeA,
                                                int nodeB)
        Parameters:
        tree -
        nodeA -
        nodeB -
        Returns:
        The node that is a parent of both nodeA and nodeB, or is nodeA or nodeB itself.
      • getAllNodes

        public static java.lang.Iterable<java.lang.Integer> getAllNodes​(EfficientTree tree)
      • getAllNodes

        public static java.lang.Iterable<java.lang.Integer> getAllNodes​(EfficientTree tree,
                                                                        int child)
      • getAllActivityLeaves

        public static java.lang.Iterable<java.lang.Integer> getAllActivityLeaves​(EfficientTree tree)
      • getAllActivityLeaves

        public static java.lang.Iterable<java.lang.Integer> getAllActivityLeaves​(EfficientTree tree,
                                                                                 int child)