Beispiel #1
0
        private static void CorrectValues(DirectedNode Graph, int LastID)
        {
            SortedList <int, DirectedNode> nums = new SortedList <int, DirectedNode>();

            DirectedNode.FlatTree(Graph, ref nums);
            DirectedNode.Correction(nums[LastID]);
        }
Beispiel #2
0
        public static void FlatTree(DirectedNode G, ref SortedList <int, DirectedNode> Srt)
        {
            List <DirectedNode> .Enumerator enumerator = new List <DirectedNode> .Enumerator();

            Srt[G.ID] = G;
            try {
                enumerator = G.Children.GetEnumerator();
                while (enumerator.MoveNext())
                {
                    DirectedNode.FlatTree(enumerator.Current, ref Srt);
                }
            } finally {
                ((IDisposable)enumerator).Dispose();
            }
        }
Beispiel #3
0
        public static void ComputeMeshCounts(DirectedNode Graph, int AddFaces = 0)
        {
            Graph.Value = 4;
            List <DirectedNode> leafs = Graph.GetLeafs();

            leafs[0].Value = 3;
            DirectedNode.Accumulate(Graph, leafs[0].ID, AddFaces);
            DirectedNode.CorrectValues(Graph, leafs[0].ID);
            leafs[0].Value = 3;
            SortedList <int, DirectedNode> nums = new SortedList <int, DirectedNode>();

            DirectedNode.FlatTree(Graph, ref nums);
            int count = checked (nums.Count - 1);

            for (int i = 0; i <= count; i = checked (i + 1))
            {
                DirectedNode item = nums[nums.Keys[i]];
                item.Value = item.Value + (double)AddFaces;
            }
        }
Beispiel #4
0
        public static void OptimizeSplits(DirectedNode Graph, int MinimalValue, bool Minimize, ref double[] CollapseValues)
        {
            List <DirectedNode> .Enumerator enumerator = new List <DirectedNode> .Enumerator();

            SortedList <int, DirectedNode> nums = new SortedList <int, DirectedNode>();

            DirectedNode.FlatTree(Graph, ref nums);
            List <DirectedNode> directedNodes = new List <DirectedNode>(nums.Values);

            double[]       numArray = new double[checked (checked (directedNodes.Count - 1) + 1)];
            DirectedNode[] item     = new DirectedNode[checked (checked (directedNodes.Count - 1) + 1)];
            double         num      = double.MaxValue;
            int            count    = checked (directedNodes.Count - 1);

            for (int i = 0; i <= count; i = checked (i + 1))
            {
                item[directedNodes[i].ID] = directedNodes[i];
                num = Math.Min(num, directedNodes[i].Value);
            }
            double[] value     = new double[checked (checked (directedNodes.Count - 1) + 1)];
            double[] value1    = new double[checked (checked (directedNodes.Count - 1) + 1)];
            double[] numArray1 = new double[checked (checked (directedNodes.Count - 1) + 1)];
            int      length    = checked ((int)item.Length - 1);

            for (int j = 0; j <= length; j = checked (j + 1))
            {
                value[j]     = item[j].Value;
                value1[j]    = -1;
                numArray1[j] = -1;
            }
            double[] numArray2 = new double[checked (checked ((int)value.Length - 1) + 1)];
            int[]    numArray3 = new int[checked (checked ((int)value.Length - 1) + 1)];
            int      length1   = checked ((int)value.Length - 1);

            for (int k = 0; k <= length1; k = checked (k + 1))
            {
                numArray[k]  = value[k];
                numArray2[k] = value[k];
                numArray3[k] = k;
            }
            CollapseValues = numArray;
            Array.Sort <double, int>(numArray2, numArray3);
            if (!Minimize)
            {
                int num1 = checked ((int)value.Length - 1);
                for (int l = 0; l <= num1; l = checked (l + 1))
                {
                    value[l]      = Math.Round(value[l] / num);
                    item[l].Value = value[l];
                }
            }
            else
            {
                int length2 = checked ((int)value.Length - 1);
                for (int m = 0; m <= length2; m = checked (m + 1))
                {
                    value[m]      = 1;
                    item[m].Value = value[m];
                }
            }
            int num2 = checked ((int)numArray3.Length - 1);

            for (int n = 0; n <= num2; n = checked (n + 1))
            {
                int          num3         = numArray3[n];
                DirectedNode directedNode = item[num3];
                if (num3 != 0)
                {
                    DirectedNode item1 = directedNode.Parents[0];
                    if (value1[num3] != -1 & numArray1[num3] != -1)
                    {
                        item[num3].Value = value1[directedNode.ID] + numArray1[directedNode.ID];
                        value[num3]      = item[num3].Value;
                    }
                    if (value1[item1.ID] == -1)
                    {
                        value1[item1.ID] = directedNode.Value;
                    }
                    else if (numArray1[item1.ID] == -1)
                    {
                        numArray1[item1.ID] = directedNode.Value;
                    }
                }
                else
                {
                    directedNode.Value = value[directedNode.Children[0].ID] + value[directedNode.Children[1].ID];
                }
            }
            try {
                enumerator = directedNodes.GetEnumerator();
                while (enumerator.MoveNext())
                {
                    DirectedNode current = enumerator.Current;
                    current.Value = current.Value * (double)MinimalValue;
                }
            } finally {
                ((IDisposable)enumerator).Dispose();
            }
        }