alpar@2195: /* -*- C++ -*- alpar@2195: * alpar@2195: * This file is a part of LEMON, a generic C++ optimization library alpar@2195: * alpar@2195: * Copyright (C) 2003-2006 alpar@2195: * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport alpar@2195: * (Egervary Research Group on Combinatorial Optimization, EGRES). alpar@2195: * alpar@2195: * Permission to use, modify and distribute this software is granted alpar@2195: * provided that this copyright notice appears in all copies. For alpar@2195: * precise terms see the accompanying LICENSE file. alpar@2195: * alpar@2195: * This software is provided "AS IS" with no warranty of any kind, alpar@2195: * express or implied, and with no claim as to its suitability for any alpar@2195: * purpose. alpar@2195: * alpar@2195: */ alpar@2195: alpar@2195: ///\ingroup demos alpar@2350: ///\file alpar@2350: ///\brief An introduction to LEMON maps alpar@2195: /// alpar@2195: /// \include maps_summary.cc alpar@2195: alpar@2195: #include alpar@2195: #include alpar@2195: alpar@2195: using namespace lemon; alpar@2195: alpar@2195: alpar@2195: template < typename GRAPH, typename MAP > alpar@2195: typename MAP::Value summary( GRAPH& gr, MAP& m ) alpar@2195: { alpar@2195: typename MAP::Value summ = typename MAP::Value(); alpar@2195: alpar@2195: for( typename GRAPH::NodeIt n(gr); n != lemon::INVALID; ++n ) alpar@2195: summ += m[n]; alpar@2195: alpar@2195: return summ; alpar@2195: } alpar@2195: alpar@2195: alpar@2209: int main() alpar@2195: { alpar@2195: ListGraph gr; alpar@2195: ListGraph::NodeMap value(gr, 0.0); alpar@2195: alpar@2195: //TODO: build a graph alpar@2195: alpar@2195: std::cout << "The summary of assigned values is " << summary(gr,value) << std::endl; alpar@2195: alpar@2195: return 0; alpar@2195: }