示例#1
0
        private void setPos(int v, int p, ref List <Vector> X, ref TreeAlgo <Object> GA)
        {
            bottom = Math.Min(bottom, (int)X[v][1]);

            int max_w = G.adj[v][0];
            int prev  = -1;

            foreach (var to in G.adj_list(v))
            {
                if (max_w == p && to != p)
                {
                    max_w = to;
                }

                if (to != p && GA.weight(max_w) < GA.weight(to))
                {
                    max_w = to;
                }
            }

            foreach (var to in G.adj_list(v))
            {
                if (to != p && to != max_w)
                {
                    X[to][0] = (prev == -1) ? X[v][0] : (right[prev] + delta);
                    X[to][1] = X[v][1] - delta;

                    prev = to;

                    setPos(to, v, ref X, ref GA);

                    right[v] = Math.Max(right[v], right[to]);
                }
            }

            if (max_w != p)
            {
                X[max_w][0] = (prev == -1) ? (X[v][0] + delta) :
                              (right[prev] + delta);
                X[max_w][1] = X[v][1];

                setPos(max_w, v, ref X, ref GA);
            }
            else
            {
                right[v] = (int)X[v][0];
            }

            if (p != -1)
            {
                right[p] = Math.Max(right[p], right[v]);
            }
        }
示例#2
0
        public List <Vector> system_config(int root = -1, int p_root = -1)
        {
            this.root   = root;
            this.p_root = p_root;

            List <Vector> X = new List <Vector>();

            for (int i = 0; i < G.V; i++)
            {
                X.Add(new Vector(0, 0));
            }

            c   = new double[G.V];
            i   = new double[G.V];
            inc = new double[G.V];
            d   = 200.0;

            GA = new TreeAlgo <Object>(G);
            if (root == -1)
            {
                root = GA.center();
            }

            GA.dfs(root, p_root);

            c[root] = 0;
            i[root] = 2 * Math.PI;

            compute_inc();
            foreach (var s in G.adj_list(root))
            {
                dfs(s, root);
            }

            for (int v = 0; v < G.V; v++)
            {
                double h = d * GA.height(v);
                X[v] = new Vector(h * Math.Cos(c[v]), h * Math.Sin(c[v]));
            }

            layout.getRect(ref X, ref lt, ref rb);
            for (int i = 0; i < X.Count; i++)
            {
                X[i] = layout.getCoord(X[i], lt, rb);
            }

            return(X);
        }
示例#3
0
        public List <Vector> system_config(Graph <Object> G, int root = -1, int p_root = -1)
        {
            init(root, p_root); // for safety!!!
            this.G = G;

            List <Vector> X = new List <Vector>();

            for (int i = 0; i < G.V; i++)
            {
                X.Add(new Vector(0, 0));
            }

            TreeAlgo <Object> GA = new TreeAlgo <Object>(G);

            if (root == -1)
            {
                root = GA.center();
            }

            GA.dfs(root, p_root);

            right = new int[G.V];
            for (int i = 0; i < G.V; i++)
            {
                right[i] = 0;
            }

            X[root] = new Vector(sx == INF ? 0 : sx, sy == INF ? 0 : sy);


            if (G.V > 1)
            {
                setPos(root, p_root, ref X, ref GA);
            }
            else
            {
                right[root] = (int)X[root][0];
            }

            return(X);
        }
示例#4
0
文件: HV.cs 项目: wtf42/VSGraphVis
        public List<Vector> system_config(Graph<Object> G, int root = -1, int p_root = -1)
        {
            init(root, p_root); // for safety!!!
            this.G = G;

            List<Vector> X = new List<Vector>();
            for (int i = 0; i < G.V; i++)
                X.Add(new Vector(0,0));

            TreeAlgo<Object> GA = new TreeAlgo<Object>(G);
            if (root == -1)
                root = GA.center();

            GA.dfs(root, p_root);

            right = new int[G.V];
            for (int i = 0; i < G.V; i++)
                right[i] = 0;

            X[root] = new Vector(sx == INF ? 0 : sx, sy == INF ? 0 : sy);

            if (G.V > 1)
            {
                setPos(root, p_root, ref X, ref GA);
            }
            else
            {
                right[root] = (int)X[root][0];
            }

            return X;
        }
示例#5
0
文件: HV.cs 项目: wtf42/VSGraphVis
        private void setPos(int v, int p, ref List<Vector> X, ref TreeAlgo<Object> GA)
        {
            bottom = Math.Min(bottom, (int)X[v][1]);

            int max_w = G.adj[v][0];
            int prev = -1;

            foreach(var to in G.adj_list(v))
            {
                if (max_w == p && to != p) max_w = to;

                if (to != p && GA.weight(max_w) < GA.weight(to))
                    max_w = to;
            }

            foreach(var to in G.adj_list(v))
            {
                if (to != p && to != max_w)
                {
                    X[to][0] = (prev == -1) ? X[v][0] : (right[prev] + delta);
                    X[to][1] = X[v][1] - delta;

                    prev = to;

                    setPos(to, v, ref X, ref GA);

                    right[v] = Math.Max(right[v], right[to]);
                }
            }

            if (max_w != p)
            {
                X[max_w][0] = (prev == -1) ? (X[v][0] + delta) :
                                            (right[prev] + delta);
                X[max_w][1] = X[v][1];

                setPos(max_w, v, ref X, ref GA);
            }
            else right[v] = (int)X[v][0];

            if (p != -1) right[p] = Math.Max(right[p], right[v]);
        }
示例#6
0
        public List<Vector> system_config(int root = -1, int p_root = -1)
        {
            this.root = root;
            this.p_root = p_root;

            List<Vector> X = new List<Vector>();
            for (int i = 0; i < G.V; i++)
                X.Add(new Vector(0, 0));

            c   = new double[G.V];
            i   = new double[G.V];
            inc = new double[G.V];
            d = 200.0;

            GA = new TreeAlgo<Object>(G);
            if (root == -1)
                root = GA.center();

            GA.dfs(root, p_root);

            c[root] = 0;
            i[root] = 2 * Math.PI;

            compute_inc();
            foreach(var s in G.adj_list(root))
                dfs(s, root);

            for (int v = 0; v < G.V; v++)
            {
                double h = d * GA.height(v);
                X[v] = new Vector(h * Math.Cos(c[v]), h * Math.Sin(c[v]));
            }

            layout.getRect(ref X, ref lt, ref rb);
            for (int i = 0; i < X.Count; i++)
                X[i] = layout.getCoord(X[i], lt, rb);

            return X;
        }