fork download
  1. #include <iostream>
  2. #include <vector>
  3.  
  4. using namespace std;
  5.  
  6. struct node
  7. {
  8. vector <int> edge;
  9. vector <int> price;
  10.  
  11. bool visited, end_of_graph;
  12. int parent;
  13.  
  14. node()
  15. {
  16. visited=false;
  17. end_of_graph=false;
  18. parent=-1;
  19. }
  20.  
  21. void add(int n)
  22. {
  23. edge.push_back(n);
  24. }
  25. void cost(int n)
  26. {
  27. price.push_back(n);
  28. }
  29. void set_as_end()
  30. {
  31. end_of_graph==true;
  32. }
  33.  
  34. };
  35. int main()
  36. {
  37. vector <node> graph;
  38.  
  39. for(int x=0; x<5; x++)
  40. graph.push_back(node());
  41.  
  42. //adding edges
  43.  
  44. graph[0].add(1); graph[0].cost(4);
  45. graph[0].add(2); graph[0].cost(1);
  46. graph[0].add(3); graph[0].cost(4);
  47.  
  48. graph[1].add(3); graph[1].cost(1);
  49.  
  50. graph[2].add(1); graph[2].cost(1);
  51. graph[2].add(3); graph[2].cost(5);
  52.  
  53. graph[3].set_as_end();
  54.  
  55. vector <int> lista;
  56.  
  57. return 0;
  58. }
  59.  
Success #stdin #stdout 0s 3028KB
stdin
Standard input is empty
stdout
Standard output is empty