COIN-OR::LEMON - Graph Library

Changeset 19:3151a1026db9 in lemon-0.x for src/work/marci_graph_demo.cc


Ignore:
Timestamp:
01/20/04 18:39:13 (17 years ago)
Author:
marci
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@32
Message:

* empty log message *

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/work/marci_graph_demo.cc

    r12 r19  
    44
    55#include <marci_list_graph.hh>
    6 #include <marci_graph_traits.hh>
    76#include <marci_property_vector.hh>
    87#include <marci_bfs.hh>
     
    1312int main (int, char*[])
    1413{
    15   typedef graph_traits<list_graph>::node_iterator node_iterator;
    16   typedef graph_traits<list_graph>::edge_iterator edge_iterator;
    17   typedef graph_traits<list_graph>::each_node_iterator each_node_iterator;
    18   typedef graph_traits<list_graph>::each_edge_iterator each_edge_iterator;
    19   typedef graph_traits<list_graph>::out_edge_iterator out_edge_iterator;
    20   typedef graph_traits<list_graph>::in_edge_iterator in_edge_iterator;
    21   typedef graph_traits<list_graph>::sym_edge_iterator sym_edge_iterator;
    22 
     14  typedef list_graph::node_iterator node_iterator;
     15  typedef list_graph::edge_iterator edge_iterator;
     16  typedef list_graph::each_node_iterator each_node_iterator;
     17  typedef list_graph::each_edge_iterator each_edge_iterator;
     18  typedef list_graph::out_edge_iterator out_edge_iterator;
     19  typedef list_graph::in_edge_iterator in_edge_iterator;
     20  typedef list_graph::sym_edge_iterator sym_edge_iterator;
    2321  list_graph G;
    2422  std::vector<node_iterator> vector_of_node_iterators;
     
    3230  std::cout << "number of nodes: " << number_of(G.first_node()) << std::endl;
    3331
    34   for(each_node_iterator i=G.first_node(); i.is_valid(); ++i) {
     32  for(each_node_iterator i=G.first_node(); i.valid(); ++i) {
    3533    std::cout << "node " << G.id(i) << std::endl;
    3634    std::cout << " outdegree (out_edge_iterator): " << number_of(G.first_out_edge(i)) << " ";
    37     for(out_edge_iterator j=G.first_out_edge(i); j.is_valid(); ++j) {
     35    for(out_edge_iterator j=G.first_out_edge(i); j.valid(); ++j) {
    3836      std::cout << "(" << G.id(G.tail(j)) << "--" << G.id(j) << "->" << G.id(G.head(j)) << ") ";
    3937    }
     
    4139
    4240    std::cout<< " ";
    43     for(out_edge_iterator j=G.first_out_edge(i); j.is_valid(); ++j) {
     41    for(out_edge_iterator j=G.first_out_edge(i); j.valid(); ++j) {
    4442      std::cout << G.a_node(j) << "->" << G.b_node(j) << " "; }
    4543    std::cout<<std::endl;
    4644
    4745    std::cout << " indegree: (in_edge_oterator) " << number_of(G.first_in_edge(i)) << " ";
    48     for(in_edge_iterator j=G.first_in_edge(i); j.is_valid(); ++j) {
     46    for(in_edge_iterator j=G.first_in_edge(i); j.valid(); ++j) {
    4947      std::cout << j << " "; }
    5048    std::cout << std::endl;
    5149
    5250    std::cout<< " ";
    53     for(in_edge_iterator j=G.first_in_edge(i); j.is_valid(); ++j) {
     51    for(in_edge_iterator j=G.first_in_edge(i); j.valid(); ++j) {
    5452      std::cout << G.a_node(j) << "->" << G.b_node(j) << " "; }
    5553    std::cout<<std::endl;
    5654
    5755    std::cout << " degree: (sym_edge_iterator) " << number_of(G.first_sym_edge(i)) << " ";
    58     for(sym_edge_iterator j=G.first_sym_edge(i); j.is_valid(); ++j) {
     56    for(sym_edge_iterator j=G.first_sym_edge(i); j.valid(); ++j) {
    5957      std::cout << j << " "; }
    6058    std::cout<<std::endl;
    6159
    6260    std::cout<< " ";
    63     for(sym_edge_iterator j=G.first_sym_edge(i); j.is_valid(); ++j) {
     61    for(sym_edge_iterator j=G.first_sym_edge(i); j.valid(); ++j) {
    6462      std::cout << G.a_node(j) << "->" << G.b_node(j) << " "; }
    6563    std::cout<<std::endl;
     
    6765
    6866  std::cout << "all edges: ";
    69   for(each_edge_iterator i=G.first_edge(); i.is_valid(); ++i) {
     67  for(each_edge_iterator i=G.first_edge(); i.valid(); ++i) {
    7068    std::cout << i << " ";
    7169  }
     
    8381  my_property_vector.put(vector_of_node_iterators[7], 1978);
    8482  std::cout << "some node property values..." << std::endl;
    85   for(each_node_iterator i=G.first_node(); i.is_valid(); ++i) {
     83  for(each_node_iterator i=G.first_node(); i.valid(); ++i) {
    8684    std::cout << my_property_vector.get(i) << std::endl;
    8785  }
     
    8987  int _ii=1;
    9088  edge_property_vector<list_graph, int> my_edge_property(G);
    91   for(each_edge_iterator i=G.first_edge(); i.is_valid(); ++i) {
     89  for(each_edge_iterator i=G.first_edge(); i.valid(); ++i) {
    9290    my_edge_property.put(i, _i);
    9391    _i*=_ii; ++_ii;
     
    9593
    9694  std::cout << "node and edge property values on the tails and heads of edges..." << std::endl;
    97   for(each_edge_iterator j=G.first_edge(); j.is_valid(); ++j) {
     95  for(each_edge_iterator j=G.first_edge(); j.valid(); ++j) {
    9896    std::cout << my_property_vector.get(G.tail(j)) << "--" << my_edge_property.get(j) << "-->" << my_property_vector.get(G.head(j)) << " ";
    9997  }
     
    102100  //std::cout << "the same for inedges of the nodes..." << std::endl;
    103101  //k=0;
    104   //for(each_node_iterator i=G.first_node(); i.is_valid(); ++i) {
    105   //  for(in_edge_iterator j=G.first_in_edge(i); j.is_valid(); ++j) {
     102  //for(each_node_iterator i=G.first_node(); i.valid(); ++i) {
     103  //  for(in_edge_iterator j=G.first_in_edge(i); j.valid(); ++j) {
    106104  //    std::cout << my_property_vector.get(G.tail(j)) << "-->" << my_property_vector.get(G.head(j)) << " ";
    107105  //  }
     
    113111  bfs_test.run();
    114112  std::cout << "reached: ";
    115   for(each_node_iterator i=G.first_node(); i.is_valid(); ++i) {
     113  for(each_node_iterator i=G.first_node(); i.valid(); ++i) {
    116114    std::cout << bfs_test.reached.get(i) << " ";
    117115  }
    118116  std::cout<<std::endl;
    119117  std::cout << "dist: ";
    120   for(each_node_iterator i=G.first_node(); i.is_valid(); ++i) {
     118  for(each_node_iterator i=G.first_node(); i.valid(); ++i) {
    121119    std::cout << bfs_test.dist.get(i) << " ";
    122120  }
     
    168166  std::cout << "on directed graph graph" << std::endl; //<< flow_test;
    169167  std::cout << "names and capacity values" << std::endl;
    170   for(each_node_iterator i=flow_test.first_node(); i.is_valid(); ++i) {
     168  for(each_node_iterator i=flow_test.first_node(); i.valid(); ++i) {
    171169    std::cout << node_name.get(i) << ": ";
    172170    std::cout << "out edges: ";
    173     for(out_edge_iterator j=flow_test.first_out_edge(i); j.is_valid(); ++j)
     171    for(out_edge_iterator j=flow_test.first_out_edge(i); j.valid(); ++j)
    174172      std::cout << node_name.get(flow_test.tail(j)) << "-"<< cap.get(j) << "->" << node_name.get(flow_test.head(j)) << " ";
    175173    std::cout << "in edges: ";
    176     for(in_edge_iterator j=flow_test.first_in_edge(i); j.is_valid(); ++j)
     174    for(in_edge_iterator j=flow_test.first_in_edge(i); j.valid(); ++j)
    177175      std::cout << node_name.get(flow_test.tail(j)) << "-"<< cap.get(j) << "->" << node_name.get(flow_test.head(j)) << " ";
    178176    std::cout << std::endl;
     
    180178
    181179 
    182   //for(each_node_iterator i=flow_test.first_node(); i.is_valid(); ++i) {
     180  //for(each_node_iterator i=flow_test.first_node(); i.valid(); ++i) {
    183181  //  std::cout << i << " ";
    184182  //}
Note: See TracChangeset for help on using the changeset viewer.