Exemple #1
0
    public static void Main(string[] args)
    {
        hierarchy = new Network();
        root = hierarchy.CreateVertex();
        root.Tag = NodeType.Root;
        c[root] = Color.Orange;

        // Assign node types and estimates
        for (int i = 0; i<individuals; i++)
        {
            Vertex aggregate = hierarchy.CreateVertex();
            hierarchy.CreateEdge(root, aggregate, EdgeType.DirectedAB);
            c[aggregate] = Color.Black;
            Aggregates.Add(aggregate);
            aggregate.Tag = NodeType.Aggregate;

            Vertex individual = hierarchy.CreateVertex();
            individual.Tag = NodeType.Individual;

            Variance[individual] = r.NextDouble();
            c[individual] = Color.FromArgb(255 - (int) (255d  * Variance[individual]), (int) (255d * Variance[individual]), 0);

            hierarchy.CreateEdge(aggregate, individual, EdgeType.DirectedAB);
            Individuals.Add(individual);

        }

        Application.Init();
        slider = new ConsensusHierarchy.TemperatureWindow();
        slider.Show();
        System.Threading.ThreadPool.QueueUserWorkItem( delegate(object o) {
            FruchtermanReingoldLayout layout = new FruchtermanReingoldLayout(15);
            NETGen.Visualization.NetworkVisualizer.Start(hierarchy, layout, c, 800, 600);
            layout.DoLayoutAsync();

            Logger.ShowInfos = false;

            while(true)
            {
                Change();
                c.RecomputeColors(new Func<Vertex,Color>(v => {
                    if (((NodeType)v.Tag) == NodeType.Aggregate)
                    {
                        if(v.OutDegree==0)
                            return Color.White;
                        else
                            return Color.Black;
                    }
                    else
                        return c[v];
                }));

                c.RecomputeColors(new Func<Edge,Color>(e => {
                    if (((NodeType)e.Target.Tag) == NodeType.Aggregate && e.Target.OutDegree==0)
                            return Color.White;
                    else
                        return c.DefaultEdgeColor;
                }));
                NetworkVisualizer.Layout.DoLayout();
            }
        });
        Application.Run();
    }
Exemple #2
0
    public static void Main(string[] args)
    {
        hierarchy = new Network();
        root      = hierarchy.CreateVertex();
        root.Tag  = NodeType.Root;
        c[root]   = Color.Orange;


        // Assign node types and estimates
        for (int i = 0; i < individuals; i++)
        {
            Vertex aggregate = hierarchy.CreateVertex();
            hierarchy.CreateEdge(root, aggregate, EdgeType.DirectedAB);
            c[aggregate] = Color.Black;
            Aggregates.Add(aggregate);
            aggregate.Tag = NodeType.Aggregate;

            Vertex individual = hierarchy.CreateVertex();
            individual.Tag = NodeType.Individual;

            Variance[individual] = r.NextDouble();
            c[individual]        = Color.FromArgb(255 - (int)(255d * Variance[individual]), (int)(255d * Variance[individual]), 0);

            hierarchy.CreateEdge(aggregate, individual, EdgeType.DirectedAB);
            Individuals.Add(individual);
        }

        Application.Init();
        slider = new ConsensusHierarchy.TemperatureWindow();
        slider.Show();
        System.Threading.ThreadPool.QueueUserWorkItem(delegate(object o) {
            FruchtermanReingoldLayout layout = new FruchtermanReingoldLayout(15);
            NETGen.Visualization.NetworkVisualizer.Start(hierarchy, layout, c, 800, 600);
            layout.DoLayoutAsync();

            Logger.ShowInfos = false;

            while (true)
            {
                Change();
                c.RecomputeColors(new Func <Vertex, Color>(v => {
                    if (((NodeType)v.Tag) == NodeType.Aggregate)
                    {
                        if (v.OutDegree == 0)
                        {
                            return(Color.White);
                        }
                        else
                        {
                            return(Color.Black);
                        }
                    }
                    else
                    {
                        return(c[v]);
                    }
                }));

                c.RecomputeColors(new Func <Edge, Color>(e => {
                    if (((NodeType)e.Target.Tag) == NodeType.Aggregate && e.Target.OutDegree == 0)
                    {
                        return(Color.White);
                    }
                    else
                    {
                        return(c.DefaultEdgeColor);
                    }
                }));
                NetworkVisualizer.Layout.DoLayout();
            }
        });
        Application.Run();
    }