00001 #ifndef __GRAPH_H__ 00002 #define __GRAPH_H__ 00003 00004 #pragma once 00005 00006 #include <iostream> 00007 #include <fstream> 00008 #include <vector> 00009 00010 class Graph; 00011 00017 std::ostream& operator<< (std::ostream& out, const Graph & graph); 00018 00024 std::istream& operator>> (std::istream& out, const Graph & graph); 00025 00026 class Graph { 00027 00028 private: 00029 unsigned int n; 00030 00031 std::vector< std::vector<int> > neighbours; 00032 std::vector< std::vector<int> > transposed_neighbours; 00033 00034 public: 00039 inline Graph(unsigned int n) : 00040 n(n) 00041 { 00042 neighbours.resize(n); 00043 transposed_neighbours.resize(n); 00044 } 00045 00050 inline unsigned int get_n() const { 00051 return n; 00052 } 00053 00059 inline std::vector<int> & get_neighbours(int nod) { 00060 return neighbours[nod]; 00061 } 00062 00067 inline std::vector<int> & get_transposed_neighbours(int nod) { 00068 return transposed_neighbours[nod]; 00069 } 00070 00071 friend std::ostream& operator<< (std::ostream& out, Graph & graph); 00072 friend std::istream& operator>> (std::istream& in, Graph & graph); 00073 }; 00074 00075 #endif 00076