Exemplo n.º 1
0
 int LayTenDinh(Canh canh, int bd)
 {
     if (canh.DiemDau.Ten == bd.ToString())
     {
         return(int.Parse(canh.DiemCuoi.Ten));
     }
     return(int.Parse(canh.DiemDau.Ten));
 }
Exemplo n.º 2
0
        //vẽ cạnh trong tập cạnh
        private void VeCanh(Canh canh)
        {
            var dDau  = canh.DiemDau;
            var dCuoi = canh.DiemCuoi;
            var color = dCuoi.Color;

            using (Graphics g = form.CreateGraphics())
            {
                g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
                using (Pen p = new Pen(color, 2))
                {
                    g.DrawLine(p, dDau.Center, dCuoi.Center);
                }
            }
        }
Exemplo n.º 3
0
        //thêm cạnh vào tập cạnh từ ht a ht b
        public void ThemCanh(Canh canh)
        {
            if (!tapCanh.Contains(canh))
            {
                tapCanh.Add(canh);
                NewArr();
                canh.DiemDau.Color  = Color.Blue;
                canh.DiemCuoi.Color = Color.Blue;
            }
            else
            {
                canh.DiemCuoi.Color = Color.Blue;
                canh.DiemDau.Color  = Color.Blue;
            }

            form.Invalidate();
        }
Exemplo n.º 4
0
        List <Canh> LayCanhTuHinh(Hinh dothi, int ten, List <Canh> cacCanhKe)
        {
            var cacCanhKeDinhMoi = new List <Canh>();

            foreach (var item in dothi.tapCanh)
            {
                if (item.DiemDau.Ten == ten.ToString() || item.DiemCuoi.Ten == ten.ToString())
                {
                    var canh = new Canh();
                    canh = item;
                    if (!cacCanhKe.Contains(canh))
                    {
                        cacCanhKeDinhMoi.Add(canh);
                    }
                }
            }
            return(cacCanhKeDinhMoi);
        }
Exemplo n.º 5
0
        //vẽ hình tròn từ sự kiện click
        void a_Click(object sender, EventArgs e)
        {
            var ht = sender as HinhTron;

            ht.Color = Color.Red;

            if (lastedClick == null)
            {
                lastedClick = ht;
                return;
            }
            if (ht.Equals(lastedClick))
            {
                return;
            }
            var canh = new Canh(lastedClick, ht);

            ThemCanh(canh);
            lastedClick = null;
        }
Exemplo n.º 6
0
        public void DuyetDinh(int dinh, Hinh hinh, int[] dinhDaDuyet)
        {
            var dD = LayHinhTron(dinh);

            hinh.tapDinh.Add(dD);
            dinhDaDuyet[dinh] = -1;
            for (int i = 0; i < arr.GetLength(0); i++)
            {
                if (arr[dinh, i] == 1)
                {
                    var dCuoi = LayHinhTron(i);
                    var canh  = new Canh(dD, dCuoi);
                    if (!hinh.tapCanh.Contains(canh))
                    {
                        hinh.tapCanh.Add(new Canh(dD, dCuoi));
                    }
                    if (dinhDaDuyet[i] == 0)
                    {
                        DuyetDinh(i, hinh, dinhDaDuyet);
                    }
                }
            }
        }