author | kpeter |
Sun, 05 Oct 2008 13:46:07 +0000 | |
changeset 2621 | 814ba94d9989 |
parent 2391 | 14a343be7a5a |
permissions | -rw-r--r-- |
alpar@2195 | 1 |
/* -*- C++ -*- |
alpar@2195 | 2 |
* |
alpar@2195 | 3 |
* This file is a part of LEMON, a generic C++ optimization library |
alpar@2195 | 4 |
* |
alpar@2553 | 5 |
* Copyright (C) 2003-2008 |
alpar@2195 | 6 |
* Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport |
alpar@2195 | 7 |
* (Egervary Research Group on Combinatorial Optimization, EGRES). |
alpar@2195 | 8 |
* |
alpar@2195 | 9 |
* Permission to use, modify and distribute this software is granted |
alpar@2195 | 10 |
* provided that this copyright notice appears in all copies. For |
alpar@2195 | 11 |
* precise terms see the accompanying LICENSE file. |
alpar@2195 | 12 |
* |
alpar@2195 | 13 |
* This software is provided "AS IS" with no warranty of any kind, |
alpar@2195 | 14 |
* express or implied, and with no claim as to its suitability for any |
alpar@2195 | 15 |
* purpose. |
alpar@2195 | 16 |
* |
alpar@2195 | 17 |
*/ |
alpar@2195 | 18 |
|
alpar@2195 | 19 |
///\ingroup demos |
alpar@2350 | 20 |
///\file |
alpar@2350 | 21 |
///\brief An introduction to LEMON maps |
alpar@2195 | 22 |
/// |
alpar@2195 | 23 |
/// \include maps_summary.cc |
alpar@2195 | 24 |
|
alpar@2195 | 25 |
#include <iostream> |
alpar@2195 | 26 |
#include <lemon/list_graph.h> |
alpar@2195 | 27 |
|
alpar@2195 | 28 |
using namespace lemon; |
alpar@2195 | 29 |
|
alpar@2195 | 30 |
|
alpar@2195 | 31 |
template < typename GRAPH, typename MAP > |
alpar@2195 | 32 |
typename MAP::Value summary( GRAPH& gr, MAP& m ) |
alpar@2195 | 33 |
{ |
alpar@2195 | 34 |
typename MAP::Value summ = typename MAP::Value(); |
alpar@2195 | 35 |
|
alpar@2195 | 36 |
for( typename GRAPH::NodeIt n(gr); n != lemon::INVALID; ++n ) |
alpar@2195 | 37 |
summ += m[n]; |
alpar@2195 | 38 |
|
alpar@2195 | 39 |
return summ; |
alpar@2195 | 40 |
} |
alpar@2195 | 41 |
|
alpar@2195 | 42 |
|
alpar@2209 | 43 |
int main() |
alpar@2195 | 44 |
{ |
alpar@2195 | 45 |
ListGraph gr; |
alpar@2195 | 46 |
ListGraph::NodeMap<double> value(gr, 0.0); |
alpar@2195 | 47 |
|
alpar@2195 | 48 |
//TODO: build a graph |
alpar@2195 | 49 |
|
alpar@2195 | 50 |
std::cout << "The summary of assigned values is " << summary(gr,value) << std::endl; |
alpar@2195 | 51 |
|
alpar@2195 | 52 |
return 0; |
alpar@2195 | 53 |
} |