COIN-OR::LEMON - Graph Library

Ticket #402: test-lemon-map-default_value.cpp

File test-lemon-map-default_value.cpp, 965 bytes (added by Charles Wilcox, 14 years ago)

Test .cpp file to demonstrate my observed behavior, and my expected behavior.

Line 
1#include <lemon/list_graph.h> // ListDigraph
2
3#include <iostream> // cout, endl
4
5int main( int argc, char* argv[] )
6{
7  lemon::ListDigraph digraph;
8  digraph.addNode();
9  digraph.addNode();
10
11  const int initial_map_value = -1;
12  lemon::ListDigraph::NodeMap< int > node_to_value_map( digraph,
13                                                        initial_map_value );
14
15  digraph.addNode();
16  digraph.addNode();
17
18  for( lemon::ListDigraph::NodeIt iter( digraph );
19       iter != lemon::INVALID; ++iter )
20  {
21    const int expected_map_value = initial_map_value;
22    const bool b_matched = node_to_value_map[ iter ] == expected_map_value;
23    std::cout << "For Digraph Node ID: " << digraph.id( iter ) << ", "
24              << "the expected map value is: " << expected_map_value << ", "
25              << ( b_matched ? "and " : "but " )
26              << "the observed map value is: " << node_to_value_map[ iter ]
27              << "." << std::endl;
28  }
29
30  return 0;
31}