When I will add edge( A, B, 1). It should be stored as ( A , 0) , ( B , 1 ) in map ( T, key ) vtxMap. when I will add edge ( B , C , 6 ), it should be stored as ( C , 2 ) ( only C bcoz , B has already stored. )
Now , vInfo is vector , in which key of map(T, key)vtxMap has stored. So it's field will be vInfo[0] = 0 , vInfo[1] = 1 , vInfo[2] = 2 etc...
Now this each vInfo field is pointing to some member functions like edges(), inDegree() , outDegree(), distance() , vtxMapLoc ( it is iterator) It means vInfo[0] will point to above functions then vInfo[1] will point all above functions.
So when I want to access these functions I will access like vInfo[0].inDegree() or vInfo[1].inDegree()
In this when I will access vInfo[0].vtxMapLoc it will point to map(T,key) vtxmap's 1st entry i.e ( A, 0 )
vInfo[1].vtxMapLoc it will point to map(T,key) vtxMap's 2nd entry i.e. ( B, 1)
I problem :
For that following code has written but i am not able to do mapping of vInfo[0].vtxMapLoc to ( A, 0 ) How to do that ?? I tried this way : (*g.vInfo[index].vtxMapLoc) = vtxMap[index]; but got error as " no match for operator = "
II problem
vInfo[i].edges() stores destination vertex of edge with weight. It means for edge ( A , B , 3) it will store 1 ( for B bcoz its Index in vInfo is 1 ) with wight 3. i.e. ( 1, 3 )
for edge ( B , c , 6) it will store 2 ( C's index in vInfo is 2 ) with 6 i.e. ( 2, 6 ) Now in book it is written like set<neighbor> edges , How can it be a set ?? I need to store two int values , so how it can be set ?? Can't it be a Map ?? I am confused, can anyone help me ??
Line 41: getvInfoIndex() doesn't need to take a graph<T> reference as a parameter. That's what this is for.
Lines 43-45: Same comment as above.
Rather than storing a map<T,int> and vector<vertexInfo<T>> in graph, why not store the data like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
template <typenameT>
class vertexInfo<T> {
public:
T data;
set <neighbor<T> > edges;
// vertextInfos compare on their data
booloperator<(const vertextInfo<T> & right) const { return data < right.data}
...
};
template <typename T>
class graph {
private:
set <vertextInfo<T> > nodes;
}