Алгоритм раскраски графа (точный) — страница 8

  • Просмотров 3906
  • Скачиваний 89
  • Размер файла 133
    Кб

ON_BN_CLICKED(IDC_STATIC1, OnStatic1) ON_WM_LBUTTONDOWN() ON_BN_CLICKED(IDC_BUTTON2, OnButton2) ON_BN_CLICKED(IDC_BUTTON3, OnButton3) ON_BN_CLICKED(IDC_BUTTON4, OnButton4) ON_BN_CLICKED(IDC_BUTTON5, OnButton5) ON_BN_CLICKED(IDC_BUTTON6, OnButton6) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CKursovojDlg message handlers BOOL CKursovojDlg::OnInitDialog() { CDialog::OnInitDialog(); // Add "About..." menu item to system menu. // IDM_ABOUTBOX must be in the system command range. ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX); ASSERT(IDM_ABOUTBOX < 0xF000); CMenu* pSysMenu = GetSystemMenu(FALSE); if (pSysMenu != NULL) { CString strAboutMenu; strAboutMenu.LoadString(IDS_ABOUTBOX); if

(!strAboutMenu.IsEmpty()) { pSysMenu->AppendMenu(MF_SEPARATOR); pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu); } } // Set the icon for this dialog. The framework does this automatically // when the application's main window is not a dialog SetIcon(m_hIcon, TRUE);// Set big icon SetIcon(m_hIcon, FALSE);// Set small icon // TODO: Add extra initialization here return TRUE; // return TRUE unless you set the focus to a control } //------------------------------------------------------------------------------------------ void CKursovojDlg::ud(void) { int q; int min,buf; for (int u=0 ; u<masskol*2; u++) for (int i=1 ; i<mass[u][0] ; i++) { min=i; for (int j=i+1 ; j<mass[u][0]+1 ; j++) if (mass[u][j]<mass[u][min]) min=j; if (i!=min) { buf= mass[u][i];

mass[u][i] = mass[u][min]; mass[u][min]= buf; } } for (int i=0 ; i<masskol*2 ; i++) for (int y=0 ; y<masskol*2 ; y++) if (i!=y) { q=0; if ((mass[i][0]==mass[y][0])&&(mass[i][0]>0)) for (int k=1; k<mass[y][0]+1; k++) if (mass[i][k]==mass[y][k]) q++; if (q==mass[y][0]) { mass[y][0]=-1; } } for (i=0 ; i<masskol*2 ; i++) for (int y=0 ; y<masskol*2 ; y++) if (i!=y) { q=0; if ((mass[i][0]+1)==mass[y][0]) for (int j=1; j<mass[i][0]+1; j++) for (int k=1; k<mass[y][0]+1; k++) if (mass[i][j]==mass[y][k]) q++; if (q==mass[i][0]) { mass[y][0]=-1; } } } //------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------ void

CKursovojDlg::perre(void) { int q; for (int i=0 ; i<masskol*2 ; i++) { q=0; for (int j=1; j<mass[i][0]+1; j++) for (int k=1; k<mass[i][0]+1; k++) if (j!=k) if (mass[i][j]==mass[i][k]) q=k; if (q!=0) { for ( j=1; j<mass[i][0]+1; j++) if (j>=q) mass[i][j]=mass[i][j+1]; mass[i][0]=mass[i][0]-1; } } } //------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------ void CKursovojDlg::peremf(int st1) { int k; masskol=2; for (int i=2 ; i<kolv+1 ; i++) { k=umnf[i][0]; for (int s=1; s<k; s++) for (int ki=0 ; ki<masskol ; ki++) for (int j=0; j<100; j++) mass[masskol*s+ki][j]=mass[ki][j]; for (s=0 ; s<k; s++) for (int j=0; j<masskol; j++)

if (mass[masskol*s+j][0]>0) { mass[masskol*s+j][0]=mass[masskol*s+j][0]+1; mass[masskol*s+j][mass[masskol*s+j][0]]=umnf[i][s+1]; } k=masskol; masskol=1000; perre(); ud(); masskol=k*umnf[i][0]; } masskol=1000; perre(); ud(); } //------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------ void CKursovojDlg::perem(int st1) { int k=0; masskol=0; for (int i=0 ; i<1000 ; i++) if (mass[i][0]!=0) masskol++; for ( i=0 ; i<masskol ; i++) for (int j=0; j<100; j++) mass[masskol+i][j]=mass[i][j]; for (int j=0 ; j<masskol ; j++) { if (mass[j][0]>0){ mass[j][0]=mass[j][0]+1; mass[j][mass[j][0]]=umn[st1].x1;} if (mass[masskol+j][0]>0){

mass[masskol+j][0]=mass[masskol+j][0]+1; mass[masskol+j][mass[masskol+j][0]]=umn[st1].x2;} } perre(); ud(); } //------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------ void CKursovojDlg::provf(void) { int min,buf; for (int u=0 ; u<kolv+1; u++) for (int i=1 ; i<umnf[u][0] ; i++) { min=i; for (int j=i+1 ; j<umnf[u][0]+1 ; j++) if (umnf[u][j]<umnf[u][min]) min=j; if (i!=min) { buf= umnf[u][i]; umnf[u][i] = umnf[u][min]; umnf[u][min]= buf; } } int k; for (int i=1; i<kolv+1 ; i++) for (int j=1; j<kolv+1 ; j++) if (i!=j) if (umnf[i][0]==umnf[j][0]) { k=0; for (int t=1 ; t<umnf[i][0]+1 ; t++) if(umnf[i][t]==umnf[j][t]) k++; if