1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
|
using namespace std;
static int index = 0;
class neighbor
{
public:
int dest ;
int weight;
neighbor( int d= 0, int w= 0);
};
template<typename T>
class vertexInfo
{
public:
enum vertexColor { white , grey , black } ;
typename map< T, int>:: iterator vtxMapLoc;
set<neighbor> edges;
vertexInfo()
{
//Default constructor
}
vertexInfo( const map<T, int> :: iterator& iter)
{
// constructor with iterator pointing to a vertex in map
}
int intDegree;
int outDegree;
};
template <typename T>
class graph
{
private:
typename map< T, int > :: iterator iter;
map <T,int> vtxMap;
vector<vertexInfo<T> > vInfo;
int numVertices;
int numedges;
stack<int> availStack;
int getvInfoIndex(graph<T>& , const T& v);
public:
void addEdge( graph<T>& , const T& , const T& , int );
set<T> get_Neighbor( graph<T>& , const T& v) ;
void show(graph<T>& );
};
template <typename T>
void graph<T> :: addEdge ( graph<T> & g, const T& v1 , const T& v2, int w)
{
pair <map <char, int> :: iterator, bool> ret ;
ret = g.vtxMap.insert(pair <char, int >( v1, index));
if( ret.second)
{
index++;
g.vInfo.push_back(index));--> Error ( so added constructor)
}
ret = g.vtxMap.insert(pair <char, int >(v2 , index));
if( ret.second)
{
index++;
g.vInfo.push_back(index);--> Error ( so added constructor)
}
}
|