예제 #1
0
        public NArrayTreeNode GetNode(String tt)  //YHB:this mehtod returns the GraphNode object with given value
        {
            NArrayTreeNode returnNode = null;

            foreach (NArrayTreeNode item in treeNodes)
            {
                if (item.data == tt)
                {
                    returnNode = item;
                }
            }

            return(returnNode);
        }
예제 #2
0
        public void postOrderTravMethod(NArrayTreeNode root)
        {//post-order traversal method for N-arry tree
            if (root != null)
            {
                if (root.childrens != null)
                {
                    foreach (NArrayTreeNode item in root.childrens)
                    {
                        postOrderTravMethod(item);
                    }
                }
                //Visit the node by Printing the node data
            }

            postOrderTrav.Add(root.data);
        }
예제 #3
0
        public int postOrderAggregation(NArrayTreeNode root)
        {//this method aggregates variables at any sub-tree of the N-arry tree given the root of the sub-tree or tree
            int returnValue = 0;


            if (root == null)
            {
                return(returnValue = 0);
            }

            if (root.childrens == null)
            {//Here write code to search the variable with given dimension
             //if childrens are null, it means it is leap nodes in component hierarchy. so, variables associated with the component in computational domain are searched to get the
             // required dimension variables. Once the variable is found, its value is assigned to the root.value otherwise it is assigned as zero.

                /* int[] masDim = new int[] { 1, 0, 0, 0, 0, 0, 0 };
                 * foreach (var item in root.variableDimension)
                 * {
                 *   if (compareDimensions(item, masDim))
                 *   {
                 *       root.value = root.value+0; //need to write code to take the same dimension varialbe value
                 *   }
                 *
                 * } */
                returnValue = root.value;
            }
            else
            {
                foreach (NArrayTreeNode item in root.childrens)
                {
                    root.value = root.value + postOrderAggregation(item);
                }
            }

            return(returnValue = root.value);
        }