Inheritance: IGraph
        public ForceDirectedGraphForm()
        {
            InitializeComponent();

            this.DoubleBuffered = true;
            this.Width = (width + 1) * 20;
            this.Height = (height + 1) * 20 + 100;
            this.MaximumSize = new Size(this.Width, this.Height);
            this.MaximizeBox = false;

            tbStiffness.Text = "81.76";
            tbRepulsion.Text = "40000.0";
            tbDamping.Text = "0.5";
            panelTop = 0;
            panelBottom = pDrawPanel.Size.Height;
            panelLeft = 0;
            panelRight = pDrawPanel.Size.Width;
            
            m_fdgBoxes = new Dictionary<Node, GridBox>();
            m_fdgLines = new Dictionary<Edge, GridLine>();
            m_fdgGraph = new Graph();
            m_fdgPhysics = new ForceDirected2D(m_fdgGraph,81.76f,40000.0f, 0.5f);
            m_fdgRenderer = new Renderer(this, m_fdgPhysics);
           

            pDrawPanel.Paint += new PaintEventHandler(DrawPanel_Paint);

            timer.Interval = 30;
            timer.Elapsed += new System.Timers.ElapsedEventHandler(timer_Elapsed);
            timer.Start();

        }
Ejemplo n.º 2
0
        public void Merge(Graph iMergeGraph)
        {
            foreach (Node n in iMergeGraph.nodes)
            {
                Node mergeNode = new Node(m_nextNodeId.ToString(), n.Data);
                AddNode(mergeNode);
                m_nextNodeId++;
                mergeNode.Data.origID=n.ID;
            }

            foreach (Edge e in iMergeGraph.edges)
            {
                Node fromNode = nodes.Find(delegate(Node n)
                {
                    if (e.Source.ID == n.Data.origID)
                    {
                        return true;
                    }
                    return false;
                });

                Node toNode = nodes.Find(delegate(Node n)
                {
                    if (e.Target.ID == n.Data.origID)
                    {
                        return true;
                    }
                    return false;
                });

                Edge tNewEdge = AddEdge(new Edge(m_nextEdgeId.ToString(), fromNode, toNode, e.Data));
                m_nextEdgeId++;
            }
        }