Advertisement
Bazze

Graph.h

May 10th, 2011
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.12 KB | None | 0 0
  1. /*
  2.  *  Graph.h
  3.  *  Inlรคmning 3B
  4.  *
  5.  *  Created by Sebastian Norling on 2011-04-26.
  6.  *  Copyright 2011 Sebastian Norling. All rights reserved.
  7.  *
  8.  */
  9.  
  10. #ifndef GRAPH_H
  11. #define GRAPH_H
  12.  
  13. #include <string>
  14.  
  15. using namespace std;
  16.  
  17. class Graph
  18. {
  19. private:
  20.     string* cities;
  21.     int** relations;
  22.    
  23.     int nrOfNodes;
  24.    
  25.     void clear();
  26.     void copy(const Graph& g);
  27.     void initRelations(int n);
  28.    
  29.     int getCityPos(string city) const;
  30.    
  31.     int getNextNodeToVisit(int distance[], bool visited[]) const;
  32.     void readCitiesFromFile(string filename);
  33.     void readRelationsFromFile(string filename);
  34.    
  35. public:
  36.     Graph();
  37.     Graph(string cities[], int n);
  38.     Graph(const Graph& g);
  39.     virtual ~Graph();
  40.    
  41.     Graph &operator=(const Graph& g);
  42.    
  43.     void addEdge(string from, string to, int distance);
  44.     bool removeEdge(string from, string to);
  45.     bool hasEdge(string from, string to) const;
  46.    
  47.     int shortestPath(string from, string to) const;
  48.     void printShortestPath(string from, string to) const;
  49.    
  50.     int getNumberOfNodes() const;
  51.    
  52.     void printAllRelations() const;
  53.  
  54.     void readFromFile(string citiesFile, string relationsFile);
  55. };
  56.  
  57. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement