[Lemon-user] Template Class of LEMON Graphs
Peter A. Kolski
Peter.Kolski at physik.tu-berlin.de
Fri Nov 16 13:56:57 CET 2012
Dear LEMON Users,
I want to write a class, which does e.g. some calculations on given graphs (ListDigraph, FullDigraph or own derived LEMON-graphes). Now I have to write implementations for each graph type, which could be avoided via templates.
Unfortunatly I am not very experienced with templates. How does a template access functions of the graph or even the NodeMaps, if a template doesn't know the type beforehand?
I added a simple sample code to show my problem.
I hope this is not a too complicated issue.
Thank you very much
Peter
template < typename DGR> class outputClass {
public:
DGR &mGraph;
DGR::NodeMap<int> mMap;
outputClass( const DGR &graph)
: mGraph(graph), mMap(graph){};
void output(){
for (DGR::NodeIt n( mGraph ); n!=INVALID; ++n) {
std::cout << "value: " << mMap[ n ] << endl;
}
}
};
int main( void ){
ListDigraph g;
outputClass<ListDigraph> out( g );
out.output();
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lemon.cs.elte.hu/pipermail/lemon-user/attachments/20121116/afd43407/attachment.html>
More information about the Lemon-user
mailing list