Exemplo n.º 1
0
        /// <summary>
        /// Funkce vraci strom, obsahujici pouze jednu uroven a to uroven listu
        /// </summary>
        /// <returns>Strom s jednotlivymi listy</returns>
        public TreeGraph <T> GetTreeLeaves()
        {
            TreeGraph <T> tree = this;

            while (tree.GetChild(0).GetChild(0) != null)
            {
                tree = tree.GetChild(0);
            }

            tree = tree.GetChild(0);

            return(tree);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Funkce prida dalsi dcerinny prvek
        /// </summary>
        /// <param name="keys">Klice pro dcerinny prvek</param>
        public void AddChild(T keys)
        {
            childs[lastChild] = new TreeGraph <T>(childs.Length, keys);

            if (lastChild > 0)
            {
                childs[lastChild].leftNeighboure      = childs[lastChild - 1];
                childs[lastChild - 1].rightNeighboure = childs[lastChild];
            }

            if (leftNeighboure != null && lastChild == 0)
            {
                TreeGraph <T> previousNode = leftNeighboure.GetChild(leftNeighboure.childs.Length - 1);

                previousNode.rightNeighboure     = childs[lastChild];
                childs[lastChild].leftNeighboure = previousNode;
            }

            lastChild++;
        }