Class InfoTree


  • public class InfoTree
    extends Object
    Stores all needed information about a single tree in several indeces.
    Author:
    Mateusz Pawlik
    • Constructor Detail

      • InfoTree

        public InfoTree​(LblTree aInputTree,
                        LabelDictionary aLd)
        Creates an InfoTree object, gathers all information about aInputTree and stores in indexes. aInputTree is not needed any more. Remember to pass the same LabelDictionary object to both trees which are compared.
        Parameters:
        aInputTree - an LblTree object
        aLd - a LabelDictionary object
    • Method Detail

      • toIntArray

        static int[] toIntArray​(List<Integer> integers)
        Transforms a list of Integer objects to an array of primitive int values.
        Parameters:
        integers -
        Returns:
      • getSize

        public int getSize()
        Returns the size of the tree.
        Returns:
      • ifNodeOfType

        public boolean ifNodeOfType​(int postorder,
                                    int type)
      • getNodeTypeArray

        public boolean[] getNodeTypeArray​(int type)
      • getInfo

        public int getInfo​(int infoCode,
                           int nodesPostorder)
        For given infoCode and postorder of a node returns requested information of that node.
        Parameters:
        infoCode -
        nodesPostorder - postorder of a node
        Returns:
        a value of requested information
      • getInfoArray

        public int[] getInfoArray​(int infoCode)
        For given infoCode returns an info array (index array)
        Parameters:
        infoCode -
        Returns:
        array with requested index
      • getNodeRelSubtrees

        public int[] getNodeRelSubtrees​(int pathType,
                                        int nodePostorder)
        Returns relevant subtrees for given node. Assuming that child v of given node belongs to given path, all children of given node are returned but node v.
        Parameters:
        pathType -
        nodePostorder - postorder of a node
        Returns:
        an array with relevant subtrees of a given node
      • getPath

        public int[] getPath​(int pathType)
        Returns an array representation of a given path's type.
        Parameters:
        pathType -
        Returns:
        an array with a requested path
      • getCurrentNode

        public int getCurrentNode()
        Returns the postorder of current root node.
        Returns:
      • setCurrentNode

        public void setCurrentNode​(int postorder)
        Sets postorder of the current node in the recursion.
        Parameters:
        postorder -
      • gatherInfo

        private int gatherInfo​(LblTree aT,
                               int postorder)
        Gathers information of a given tree in corresponding arrays. At this point the given tree is traversed once, but there is a loop over current nodes children to assign them their parents.
        Parameters:
        aT -
        postorder -
        Returns:
      • postTraversalProcessing

        private void postTraversalProcessing()
        Gathers information, that couldn't be collected while tree traversal.
      • isSwitched

        public boolean isSwitched()
      • setSwitched

        public void setSwitched​(boolean value)