Exemple #1
0
        private void pictureBox1_MouseUp(object sender, MouseEventArgs e)
        {
            {
                if (draw_Arc == true && start != null)
                {
                    int len = Statistic.list.length();
                    end = Statistic.list.search(e.X, e.Y, len);
                    if (againA == 0)      //不在相同位置重画边
                    {
                        if (start == end) //不在一个顶点画边
                        {
                            againA = 1;
                        }
                        for (int i = 0; i < ArcCount; i++)
                        {
                            if (start == Statistic.arcnode[i].start && end == Statistic.arcnode[i].end)
                            {
                                againA = 1;
                                break;
                            }
                        }
                    }
                    if (againA == 0)
                    {
                        /*if (end != null)
                         *  textBox1.Text += end.name + "\r\n";
                         * else
                         *  textBox1.Text += "null" + "\r\n";
                         */
                        if (end != null)
                        {
                            Arcs arc = new Arcs(ArcCount + 1, "e" + ArcCount.ToString(), start, end);
                            arc.paper = pictureBox1;
                            Statistic.arcnode[ArcCount] = arc;
                            ArcCount++;

                            arc.draw(Color.Black);
                            start.draw(Color.Black);
                            Statistic.AdjMatrix[start.NO, end.NO] = 1;
                            Statistic.AdjMatrix[end.NO, start.NO] = 1;
                        }
                    }
                    againA = 0;
                }
            }
        }
Exemple #2
0
        public Graph(Arcs[] a, LinkVertex l, int an, int vn)
        {
            Arcs pre = null;
            Arcs a1;

            for (int i = 0; i < arcs.Length; i++)
            {
                for (Vertex v = l.start; v != null; v = v.next_adjcent)
                {
                    if (a[i] != null && a[i].start == v)
                    {
                        if (v.first == null)
                        {
                            v.first = a[i];
                        }
                        else
                        {
                            a1 = v.first;
                            while (a1 != null)
                            {
                                pre = a1;
                                a1  = a1.next_arcs;
                            }
                            if (pre != null)
                            {
                                pre.next_arcs = a[i];
                            }
                        }
                    }
                }
            }
            vertexnum = l.length();
            arcnum    = an;
            Adjlist   = l;
            arcs      = a;
        }