demo/maps_summary.cc
changeset 2195 f47faf6913ab
child 2209 d3425607d41a
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/demo/maps_summary.cc	Mon Sep 04 19:48:09 2006 +0000
     1.3 @@ -0,0 +1,53 @@
     1.4 +/* -*- C++ -*-
     1.5 + *
     1.6 + * This file is a part of LEMON, a generic C++ optimization library
     1.7 + *
     1.8 + * Copyright (C) 2003-2006
     1.9 + * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
    1.10 + * (Egervary Research Group on Combinatorial Optimization, EGRES).
    1.11 + *
    1.12 + * Permission to use, modify and distribute this software is granted
    1.13 + * provided that this copyright notice appears in all copies. For
    1.14 + * precise terms see the accompanying LICENSE file.
    1.15 + *
    1.16 + * This software is provided "AS IS" with no warranty of any kind,
    1.17 + * express or implied, and with no claim as to its suitability for any
    1.18 + * purpose.
    1.19 + *
    1.20 + */
    1.21 +
    1.22 +///\ingroup demos
    1.23 +///\file maps_summary demo program
    1.24 +///\brief Introduction to LEMON maps
    1.25 +///
    1.26 +/// \include maps_summary.cc
    1.27 +
    1.28 +#include <iostream>
    1.29 +#include <lemon/list_graph.h>
    1.30 +
    1.31 +using namespace lemon;
    1.32 +
    1.33 +
    1.34 +template < typename GRAPH, typename MAP >
    1.35 +typename MAP::Value  summary( GRAPH& gr, MAP& m )
    1.36 +{
    1.37 +  typename MAP::Value  summ = typename MAP::Value();
    1.38 +  
    1.39 +  for( typename GRAPH::NodeIt  n(gr); n != lemon::INVALID; ++n )
    1.40 +    summ += m[n];
    1.41 +
    1.42 +  return summ;
    1.43 +}
    1.44 +
    1.45 +
    1.46 +int  main( int argc, char *argv[] )
    1.47 +{
    1.48 +  ListGraph  gr;
    1.49 +  ListGraph::NodeMap<double>  value(gr, 0.0);
    1.50 +
    1.51 +  //TODO: build a graph  
    1.52 +  
    1.53 +  std::cout << "The summary of assigned values is " << summary(gr,value) << std::endl;
    1.54 +
    1.55 +  return 0;
    1.56 +}