Advertisement
Guest User

Untitled

a guest
Jan 16th, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.65 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdlib>
  3.  
  4. using namespace std;
  5. class Grafo{
  6. private:
  7. int Topo;
  8. int Vertices[100];
  9. int Arestas[100];
  10. public:
  11. Grafo();
  12. void InserirVertice(int i);
  13. //int InserirAresta();
  14. void getVertices();
  15. void IncrementaTopo();
  16. };
  17.  
  18. Grafo::Grafo(){
  19. Topo=0;
  20. for(int c=0;c<100;c++){
  21. Vertices[c]=0;
  22. Arestas[c]=0;
  23. }
  24. }
  25.  
  26. void Grafo::InserirVertice(int i){
  27. for(int c=0;c<100;c++){
  28. if(Vertices[c]==i){
  29. cout<<"ERRO"<<endl;
  30. break;
  31. }
  32. }
  33. Grafo obj;
  34. Vertices[Topo]=i;
  35. IncrementaTopo();
  36. cout<<"Topo:"<<Topo<<endl;
  37. }
  38.  
  39.  
  40.  
  41. /*int Grafo::InserirAresta(int i, int j){
  42.  
  43. }*/
  44.  
  45. void Grafo::getVertices(){
  46. for(int c=0;c<100;c++){
  47. cout<<Vertices[c]<<" ";
  48. }
  49. }
  50.  
  51. void Grafo::IncrementaTopo(){
  52. Topo++;
  53. }
  54.  
  55. int main(int argc, char** argv){
  56. int Decisao, ValorVertice;
  57. Grafo obj;
  58. while(Decisao!=0){
  59. cout<<endl<<"1 - Inserir vertice"<<endl;
  60. cout<<"2 - Inserir aresta"<<endl;
  61. cout<<"3 - Remover vertice"<<endl;
  62. cout<<"4 - Remover aresta"<<endl;
  63. cout<<"5 - Calcular componentes conexos(Godman)"<<endl;
  64. cout<<"6 - Verificar se o grafo e Euriliano"<<endl;
  65. cout<<"7 - Encontrar ciclo Euriliano (Fleury)"<<endl;
  66. cout<<"8 - Realizar busca em profundidade"<<endl;
  67. cout<<"9 - Realizar busca em largura"<<endl;
  68. cout<<"10 - Encontrar caminho de custo minimo (Dijkstra)"<<endl;
  69. cout<<"11 - Abrir/Salvar grafo"<<endl;
  70. cout<<endl<<"Escolha uma das opcoes acima: ";
  71. cin>> Decisao;
  72. switch(Decisao){
  73. case 1:
  74. cout<<"Insira um vertice: ";
  75. cin>>ValorVertice;
  76. obj.InserirVertice(ValorVertice);
  77. obj.getVertices();
  78. break;
  79. }
  80. }
  81.  
  82. return 0;
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement