diff -r eaf16c8f6fef -r f47faf6913ab demo/maps_summary.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/demo/maps_summary.cc Mon Sep 04 19:48:09 2006 +0000 @@ -0,0 +1,53 @@ +/* -*- C++ -*- + * + * This file is a part of LEMON, a generic C++ optimization library + * + * Copyright (C) 2003-2006 + * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport + * (Egervary Research Group on Combinatorial Optimization, EGRES). + * + * Permission to use, modify and distribute this software is granted + * provided that this copyright notice appears in all copies. For + * precise terms see the accompanying LICENSE file. + * + * This software is provided "AS IS" with no warranty of any kind, + * express or implied, and with no claim as to its suitability for any + * purpose. + * + */ + +///\ingroup demos +///\file maps_summary demo program +///\brief Introduction to LEMON maps +/// +/// \include maps_summary.cc + +#include +#include + +using namespace lemon; + + +template < typename GRAPH, typename MAP > +typename MAP::Value summary( GRAPH& gr, MAP& m ) +{ + typename MAP::Value summ = typename MAP::Value(); + + for( typename GRAPH::NodeIt n(gr); n != lemon::INVALID; ++n ) + summ += m[n]; + + return summ; +} + + +int main( int argc, char *argv[] ) +{ + ListGraph gr; + ListGraph::NodeMap value(gr, 0.0); + + //TODO: build a graph + + std::cout << "The summary of assigned values is " << summary(gr,value) << std::endl; + + return 0; +}