COIN-OR::LEMON - Graph Library

Changeset 8:cd54905012bc in lemon-0.x for src/work/bfsdemo2.cc


Ignore:
Timestamp:
12/16/03 19:17:51 (20 years ago)
Author:
Alpar Juttner
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@21
Message:

-New test: bfsdemo2.cc added

  • Graph class has a NodeMap? and an EdgeMap? member class
  • default_bfs_T uning the above Maps is added
  • a (property)map must provide a member function SetG() to attach the map to a graph
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/work/bfsdemo2.cc

    r6 r8  
    1616  TestGraph::NodeIterator tn,n2;
    1717 
    18   for(int i=1;i<=5000;i++)
     18  cout << "Create nodes\n";
     19
     20  for(int i=1;i<=500;i++)
    1921    {
    2022      *(tn=G.AddNode())=i;
     
    2224    }
    2325 
     26  cout << "Create Edges\n";
     27 
    2428  for(TestGraph::NodeIterator n(G);n.isValid();++n)
    25     for(TestGraph::NodeIterator m(G);m.isValid();++m)
     29    for(TestGraph::NodeIterator m(G);m.isValid();++m) if(n!=m)
    2630      if(gcd(*n,*m)>1) G.AddEdge(n,m);
    2731 
     32 
     33  cout << "Run BFS\n";
     34
    2835  Bfs<default_bfs_T<TestGraph> > bfs;
    2936
     
    3340
    3441  for(TestGraph::NodeIterator n(G);n.isValid();++n)
    35     cout << Get(bfs.tree_map,n).From() << "->" << Get(bfs.tree_map,n).To()
    36         << '\n';
     42    if((*n)!=2)
     43      cout << (Get(bfs.dist_map,n)) << '\n';
    3744
     45  for(TestGraph::NodeIterator n(G);n.isValid();++n)
     46    if(Get(bfs.dist_map,n))
     47      cout << *(Get(bfs.tree_map,n).From()) << "->"
     48           << *(Get(bfs.tree_map,n).To())
     49           << '\n';
    3850}
Note: See TracChangeset for help on using the changeset viewer.