Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <windows.h>
- #include "grafneorientat.h"
- #include <string.h>
- using namespace std;
- void introducere()
- {
- cout<<"=|===================================================================================================================|="<<endl;
- cout<<"=|= =|="<<endl;
- cout<<"=|= TEZA LA INFORMATICA =|="<<endl;
- cout<<"=|= -CLASA A XI-E- =|="<<endl;
- cout<<"=|= =|="<<endl;
- cout<<"=|= PROIECT REALIZAT DE :FARCAS VLAD SI ICHIM OCTAVIAN =|="<<endl;
- cout<<"=|= =|="<<endl;
- cout<<"=|= TEMA PROIECTULUI : GRAFURI NEORIENTATE =|="<<endl;
- cout<<"=|= =|="<<endl;
- cout<<"=|= PROFESOR : IVASC CORNELIA =|="<<endl;
- }
- void meniu()
- {
- cout<<"=|= =|="<<endl;
- cout<<"=|= =|="<<endl;
- cout<<"=|= MENIU =|="<<endl;
- cout<<"=|= =|="<<endl;
- cout<<"=|= CITIRE / AFISARE =|="<<endl;
- cout<<"=|= =|="<<endl;
- cout<<"=|= 1.FUNCTIE PENTRU CITIREA UNUI GRAF.VETI CITI N,M SI MAI APOI M PERECHI DE FORMA (X,Y) REPREZENTAN =|="<<endl;
- cout<<"=|= NUMARUL DE NODURI , NUMARUL DE MUCHII SI RESPECTIV PERECHILE DE NODURI INTRE CARE EXISTA MUCHIE =|="<<endl;
- cout<<"=|= 2.FUNCTIE PENTRU AFISAREA UNUI GRAF.FUNCTIA VA AFISA MATRICEA DE ADIACENTA A GRAFULUI. =|="<<endl;
- cout<<"=|= =|="<<endl;
- cout<<"=|= ADAUGARE/STERGERE/VERIFICARE MUCHII =|="<<endl;
- cout<<"=|= =|="<<endl;
- cout<<"=|= VETI CITI OPERATIA APOI X SI Y IAR FUNCTIA VA =|="<<endl;
- cout<<"=|= =|="<<endl;
- cout<<"=|= 3.ADAUGA MUCHIE INTRE X SI Y RESPECTIV Y SI X. =|="<<endl;
- cout<<"=|= 4.STERGE MUCHIA DINTRE X SI Y RESPECTIV Y SI X. =|="<<endl;
- cout<<"=|= 5.VA AFISA MESAJUL 'DA' DACA EXISTA MUCHIE INTRE X SI Y SAU 'NU' IN CAZ CONTRAR. =|="<<endl;
- cout<<"=|= =|="<<endl;
- cout<<"=|= DFS/BFS =|="<<endl;
- cout<<"=|= =|="<<endl;
- cout<<"=|= 6.FUNCTIA VA AFISA VARFURILE VIZITATE IN URMA PARCURGERII IN ADANCIME(DFS). =|="<<endl;
- cout<<"=|= 7.FUNCTIA VA AFISA VARFURILE VIZITATE IN URMA PARCURGERII IN LATIME(BFS). =|="<<endl;
- cout<<"=|= =|="<<endl;
- cout<<"=|= VERIFICARE PROPRIETATI GRAF =|="<<endl;
- cout<<"=|= =|="<<endl;
- cout<<"=|= 8.VERIFICARE GRAF COMPLET.FUNCTIA VA AFISA 'DA' DACA GRAFUL ESTE COMPLET SI 'NU' IN CAZ CONTRAR. =|="<<endl;
- cout<<"=|= 9.VERIFICARE GRAF BIPARTIT.FUNCTIA VA AFISA 'DA' SI DOUA MULTIMI CARE FORMEAZA PARTITIA VARFURILOR SI =|="<<endl;
- cout<<"=|= 'NU' IN CAZ CONTRAR. =|="<<endl;
- cout<<"=|= 10.VERIFICARE GRAF CONEX.FUNCTIA VA AFISA MESAJUL 'DA' DACA GRAFUL ESTE CONEX SI 'NU' IN CAZ CONTRAR =|="<<endl;
- cout<<"=|= 11.VERIFICARE GRAF EULERIAN.FUNCTIA VA AFISA MESAJUL 'DA' URMAT DE UN VARFURILE UNUI CICLU EULERIAN SI =|="<<endl;
- cout<<"=|= 'NU' IN CAZ CONTRAR. =|="<<endl;
- cout<<"=|= 12.VERIFICARE GRAF PARTIAL.VETI CITI 2 GRAFURI IAR FUNCTIA VA AFISA MESAJUL 'DA' DACA PRIMUL GRAF ESTE =|="<<endl;
- cout<<"=|= GRAF PARTIAL AL CELUI DE-AL DOILEA GRAF SI NU IN CAZ CONTRAR. =|="<<endl;
- cout<<"=|= =|="<<endl;
- cout<<"=|= ALTE FUNCTII =|="<<endl;
- cout<<"=|= =|="<<endl;
- cout<<"=|= 13.NUMAR DE NODURI.FUNCTIA VA AFISA NUMARUL DE NODURI AL GRAFULUI. =|="<<endl;
- cout<<"=|= 14.GRAD NOD.VETI CITI OPERATIA APOI UN NOD X APARTINAND GRAFULUI IAR FUNCTIA VA AFISA GRADUL ACESTUIA. =|="<<endl;
- cout<<"=|= 15.COMPONENTE CONEXTE.FUNCTIA VA AFISA NUMARUL DE COMPONENTE CONEXE RESPECTIV ACESTEA. =|="<<endl;
- cout<<"=|= 16.NUMAR NODURI IZOLATE.FUNCTIA VA AFISA NUMARUL DE NODURI IZOLATE. =|="<<endl;
- cout<<"=|= 17.VERIFICARE CICLU EULERIAN.VETI CITI N APOI N NUMERE REPREZENTAND UN SIR DE NUMERE.FUNCTIA VA AFISA =|="<<endl;
- cout<<"=|= MESAJUL 'DA' DACA SIRUL POATE REPREZENTA UN CICLU EULERIAN SI 'NU' IN CAZ CONTRAR. =|="<<endl;
- cout<<"=|= 18.AFISARE GRADE NODURI.FUNCTIA VA AFISA FIECARE NOD AL GRAFULUI URMAT DE GRADUL SAU. =|="<<endl;
- cout<<"=|= 19.AFISARE MATRICE DRUMURI.FUNCTIA VA AFISA MATRICEA DRUMURILOR CORESPUNZATOARE GRAFULUI. =|="<<endl;
- cout<<"=|= 20.AFISARE LANT MINIM DE LA NODUL X LA NODUL Y.FUNCTIA VA AFISA LUNGIMEA LANTULUI URMAT =|="<<endl;
- cout<<"=|= DE NODURILE CARE IL FORMEAZA =|="<<endl;
- cout<<"=|= =|="<<endl;
- }
- void altele()
- {
- cout<<"=|= =|="<<endl;
- cout<<"=|= COMENZI AJUTATOARE =|="<<endl;
- cout<<"=|= =|="<<endl;
- cout<<"=|= 'menu' PENTRU A AFISA DIN NOU MENIUL =|="<<endl;
- cout<<"=|= 'exit' PENTRU A IESI DIN APLICATIE =|="<<endl;
- }
- void goodbye()
- {
- cout<<"=|===================================================================================================================|="<<endl;
- }
- void comanda_gresita()
- {
- cout<<"=|= NU EXISTA ACEASTA COMANDA , MAI INCEARCA =|="<<endl;
- }
- void menu()
- {
- GN G(3),Graf,G2,G1,G3;
- int rasp,op,x,y,v[100],mr;
- char comand[10];
- HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
- SetConsoleTextAttribute(hConsole, 2);
- bool ok=1;
- int nr;
- introducere();
- meniu();
- altele();
- while(ok)
- {
- SetConsoleTextAttribute(hConsole, 2);
- cout<<"=|= CITESTE COMANDA : =|="<<endl;
- cout<<"=> ";
- SetConsoleTextAttribute(hConsole, 12);
- cin>>comand;
- SetConsoleTextAttribute(hConsole, 2);
- if(strcmp(comand,"menu")==0)
- {
- SetConsoleTextAttribute(hConsole, 2);
- meniu();
- }
- else if(strcmp(comand,"exit")==0)
- {
- SetConsoleTextAttribute(hConsole, 2);
- goodbye();
- ok=0;
- }
- else
- {
- nr=atol(comand);
- switch(nr)
- {
- case 1 :
- cout<<"=|= CITESTE N M SI APOI M PERECHI DE FORMA X Y =|="<<endl;
- SetConsoleTextAttribute(hConsole, 7);
- cin>>G1;
- break;
- case 2:
- if(G1.numar_noduri()==0)
- cout<<"GRAFUL NU EXISTA / NU ARE UN NUMAR DE NODURI DEFINIT"<<endl;
- else
- {
- cout<<"=|= MATRICEA DE ADIACENTA A GRAFULUI ESTE : =|="<<endl;
- SetConsoleTextAttribute(hConsole, 5);
- cout<<G1;
- }
- break;
- case 3:
- cout<<"=|= CITESTE X SI Y INSEMNAND NODURILE INTRE CARE VREI SA FACI O MUCHIE : =|="<<endl;
- cout<<"=> ";
- SetConsoleTextAttribute(hConsole, 3);
- cin>>x>>y;
- G1.set_muchie(x,y);
- break;
- case 4:
- cout<<"=|= CITESTE X SI Y INSEMNAND NODURILE INTRE CARE VREI SA STERGI MUCHIA : =|="<<endl;
- cout<<"=> ";
- SetConsoleTextAttribute(hConsole, 3);
- cin>>x>>y;
- G1.delete_muchie(x,y);
- break;
- case 5:
- cout<<"=|= CITESTE X SI Y INSEMNAND NODURILE INTRE CARE VREI SA VEZI DACA ESTE MUCHIE : =|="<<endl;
- cout<<"=> ";
- SetConsoleTextAttribute(hConsole, 3);
- cin>>x>>y;
- if(G1.verif_muchie(x,y))
- {
- SetConsoleTextAttribute(hConsole, 9);
- cout<<"DA"<<endl;
- }
- else
- {
- SetConsoleTextAttribute(hConsole, 4);
- cout<<"NU"<<endl;
- }
- break;
- case 6:
- cout<<"=|= PARCURGEREA NODURILOR IN ADANCIME DIN NODUL 1 : =|="<<endl;
- SetConsoleTextAttribute(hConsole, 9);
- G1.DFS(1);
- cout<<endl;
- break;
- case 7:
- cout<<"=|= PARCURGEREA NODURILOR IN LATIME DIN NODUL 1 : =|="<<endl;
- SetConsoleTextAttribute(hConsole, 9);
- G1.BFS(1);
- break;
- case 8:
- if(G1.graf_complet())
- {
- SetConsoleTextAttribute(hConsole, 9);
- cout<<"GRAFUL ESTE COMPLET"<<endl;
- }
- else
- {
- SetConsoleTextAttribute(hConsole, 4);
- cout<<"GRAFUL NU ESTE COMPLET"<<endl;
- }
- break;
- case 9:
- SetConsoleTextAttribute(hConsole, 7);
- G1.bipartit();
- break;
- case 10:
- if(G1.conex())
- {
- SetConsoleTextAttribute(hConsole, 9);
- cout<<"DA,GRAFUL ESTE CONEX"<<endl;
- }
- else
- {
- SetConsoleTextAttribute(hConsole, 4);
- cout<<"NU,GRAFUL NU ESTE CONEX"<<endl;
- }
- break;
- case 11:
- if(G1.euler())
- {
- SetConsoleTextAttribute(hConsole, 9);
- cout<<"DA"<<endl;
- G1.ciclu_eulerian(1);
- cout<<endl;
- }
- else
- {
- SetConsoleTextAttribute(hConsole, 4);
- cout<<"NU"<<endl;
- }
- break;
- case 12:
- cin>>G2>>G3;
- if(G2<G3)
- {
- SetConsoleTextAttribute(hConsole, 9);
- cout<<"DA,PRIMUL GRAF ESTE GRAF PARTIAL AL CELUI DE-AL DOILEA GRAF"<<endl;
- }
- else
- {
- SetConsoleTextAttribute(hConsole, 4);
- cout<<"NU,PRIMUL GRAF NU ESTE GRAF PARTIAL AL CELUI DE-AL DOILEA GRAF"<<endl;
- }
- break;
- case 13:
- SetConsoleTextAttribute(hConsole, 12);
- cout<<"GRAFUL ARE "<<G1.numar_noduri()<<" NODURI"<<endl;
- break;
- case 14:
- cin>>x;
- SetConsoleTextAttribute(hConsole, 13);
- cout<<"GRADUL NODULUI "<<x<<" ESTE "<<G1.grad(x)<<endl;
- break;
- case 15:
- G1.componente_conexe();
- break;
- case 16:
- SetConsoleTextAttribute(hConsole, 13);
- cout<<"NUMARUL NODURILOR IZOLATE DIN GRAF ESTE "<<G1.numar_noduri_izolate()<<endl;
- break;
- case 17:
- cin>>mr;
- for(int i=1; i<=mr; i++)
- cin>>v[i];
- if(G1.verif_ciclu_eulerian(v,mr))
- {
- SetConsoleTextAttribute(hConsole, 9);
- cout<<"DA,SIRUL REPREZINTA UN CICLU EULERIAN AL GRAFULUI CITIT"<<endl;
- }
- else
- {
- SetConsoleTextAttribute(hConsole, 4);
- cout<<"NU,SIRUL NU REPREZINTA UN CICLU EULERIAN AL GRAFULUI CITIT"<<endl;
- }
- break;
- case 18:
- SetConsoleTextAttribute(hConsole, 5);
- G1.afis_grade();
- break;
- case 19:
- SetConsoleTextAttribute(hConsole, 9);
- G1.mark_zero();
- G1.copiere();
- G1.generare_matrice_drumuri();
- G1.afisare_matrice_drumuri();
- break;
- case 20:
- SetConsoleTextAttribute(hConsole, 12);
- cin>>x>>y;
- G1.lant_minim(x,y);
- default:
- comanda_gresita();
- }
- }
- }
- }
- int main()
- {
- menu();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement