Advertisement
Guest User

Untitled

a guest
Dec 20th, 2014
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.31 KB | None | 0 0
  1. #ifndef AdjList_H_
  2. #define AdjList_H_
  3.  
  4. #include <iostream>
  5. #include <cstdlib>
  6. #include <string>
  7. #include <vector>
  8. using namespace std;
  9.  
  10. class Edge;
  11.  
  12. struct Node
  13. {
  14. public:
  15.     string id;
  16.     vector<Edge*>* adj;
  17.     int distance;
  18.     Node* prev;
  19.     Node(string name){
  20.         this->id = name;
  21.         adj = new vector<Edge*>;
  22.         prev = NULL;
  23.     }
  24.     ~Node(){};
  25. };
  26.  
  27. class Edge{
  28. public:
  29.     Edge(Node* current, Node* next, int weight);
  30.     ~Edge();
  31. private:
  32.     Node* current; //first node
  33.     Node* next; //next node
  34.     Edge* adj; //pointing to first edge in the adj list
  35.     int weight;
  36. };
  37.  
  38. Edge::Edge(Node* current, Node* next, int weight){
  39.     current = current;
  40.     next = next;
  41.     weight = weight;
  42. }
  43.  
  44. Edge::~Edge(){}
  45.  
  46. class Graph{
  47. public:
  48.     Graph(vector<string> a);
  49.     ~Graph();
  50.     const int getNumOfNodes();
  51.     const int returnEdges();
  52.     void insertEdge(string name1, string name2, int weight);
  53. private:
  54.     int numOfNodes;
  55.     vector <Edge*> edges;
  56.     vector <Node*> vertices;
  57. };
  58.  
  59. Graph::Graph(vector<string>a){
  60.     while(a.size() != 0){
  61.         Node* temp = new Node(a.back());
  62.         a.pop_back();
  63.         vertices.push_back(temp);
  64.     }
  65. }
  66.  
  67. const int Graph::getNumOfNodes(){
  68.     return numOfNodes;
  69. }
  70.  
  71. const int Graph::returnEdges(){
  72.     return edges.size();
  73. }
  74.  
  75. void Graph::insertEdge(string name1, string name2, int weight){
  76.  
  77. }
  78.  
  79. Graph::~Graph()
  80. {
  81. }
  82.  
  83. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement