public void swap(Canh a, Canh b) { Canh temp = new Canh(a.getX(), a.getY()); a.setX(b.getX()); a.sety(b.getY()); a.setTenCanh(b.getTenCanh()); b.setX(temp.getX()); b.sety(temp.getY()); b.setTenCanh(temp.getTenCanh()); }
public bool kTraTaoDinhCap3(Canh canh) { int demXuatHienX = 0; int demXuatHienY = 0; for (int i = 0; i < dsChonDuong.Count; i++) { if (dsChonDuong[i].getX() == canh.getX() || dsChonDuong[i].getY() == canh.getX()) { demXuatHienX++; } if (dsChonDuong[i].getX() == canh.getY() || dsChonDuong[i].getY() == canh.getY()) { demXuatHienY++; } } if (demXuatHienX == 2 || demXuatHienY == 2) { MessageBox.Show("Cạnh " + canh.getTenCanh() + " có tạo thành 1 đỉnh cấp 3 !"); return(true); } return(false); }
private void btnTimDuong_Click(object sender, EventArgs e) { if (i == dsChonDuong.Count) { MessageBox.Show("KẾT THÚC TÌM ĐƯỜNG"); btnTimDuong.Enabled = false; return; } Canh canh = dsChonDuong[i]; noiDiem(canh.getX().getDiem(), canh.getY().getDiem()); MessageBox.Show(listView1.Items[i].SubItems[1].Text); i++; btnTimDuong.Focus(); }
public bool ktraDoanChuTrinhThieu(Canh c1, Canh c2, Canh c3) { List <Diem> ds = new List <Diem>(); ds.Add(c1.getX()); if (ds.Contains(c1.getY()) == false) { ds.Add(c1.getY()); } if (ds.Contains(c2.getX()) == false) { ds.Add(c2.getX()); } if (ds.Contains(c2.getY()) == false) { ds.Add(c2.getY()); } if (ds.Contains(c3.getX()) == false) { ds.Add(c3.getX()); } if (ds.Contains(c3.getY()) == false) { ds.Add(c3.getY()); } if (ds.Count > 3) { return(false);//ko tạo chu trinh thieu } return(true); }