COIN-OR::LEMON - Graph Library

source: lemon-0.x/demo/hello_lemon.cc @ 1520:c2c76e4598f6

Last change on this file since 1520:c2c76e4598f6 was 1520:c2c76e4598f6, checked in by Mihaly Barasz, 15 years ago

getstart: hello_lemon.cc moved to a separate file in demo/

File size: 654 bytes
Line 
1#include <iostream>
2#include <lemon/list_graph.h>
3
4int main()
5{
6  typedef lemon::ListGraph Graph;
7  typedef Graph::EdgeIt EdgeIt;
8  typedef Graph::NodeIt NodeIt;
9  using lemon::INVALID;
10
11  Graph g;
12 
13  for (int i = 0; i < 3; i++)
14    g.addNode();
15 
16  for (NodeIt i(g); i!=INVALID; ++i)
17    for (NodeIt j(g); j!=INVALID; ++j)
18      if (i != j) g.addEdge(i, j);
19
20  std::cout << "Nodes:";
21  for (NodeIt i(g); i!=INVALID; ++i)
22    std::cout << " " << g.id(i);
23  std::cout << std::endl;
24
25  std::cout << "Edges:";
26  for (EdgeIt i(g); i!=INVALID; ++i)
27    std::cout << " (" << g.id(g.source(i)) << "," << g.id(g.target(i)) << ")";
28  std::cout << std::endl;
29}
Note: See TracBrowser for help on using the repository browser.