COIN-OR::LEMON - Graph Library

Ignore:
Timestamp:
04/05/04 19:10:25 (16 years ago)
Author:
marci
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@422
Message:

ez mar kafa

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/work/marci/iterator_bfs_demo.cc

    r301 r304  
    2121  EdgeNameMap(Graph& _graph, NodeNameMap& _node_name_map) :
    2222    graph(_graph), node_name_map(_node_name_map) { }
    23   string get(typename Graph::Edge e) const {
     23  string operator[](typename Graph::Edge e) const {
    2424    return
    25       (node_name_map.get(graph.tail(e))+"->"+node_name_map.get(graph.head(e)));
     25      (node_name_map[graph.tail(e)]+"->"+node_name_map[graph.head(e)]);
    2626  }
    2727};
     
    9696    cout << "bfs and dfs iterator demo on the directed graph" << endl;
    9797    for(GW::NodeIt n(gw); gw.valid(n); gw.next(n)) {
    98       cout << node_name.get(n) << ": ";
     98      cout << node_name[n] << ": ";
    9999      cout << "out edges: ";
    100100      for(GW::OutEdgeIt e(gw, n); gw.valid(e); gw.next(e))
    101         cout << edge_name.get(e) << " ";
     101        cout << edge_name[e] << " ";
    102102      cout << "in edges: ";
    103103      for(GW::InEdgeIt e(gw, n); gw.valid(e); gw.next(e))
    104         cout << edge_name.get(e) << " ";
     104        cout << edge_name[e] << " ";
    105105      cout << endl;
    106106    }
     
    112112      //cout << "edge: ";
    113113      if (gw.valid(bfs)) {
    114         cout << edge_name.get(bfs) << /*endl*/", " <<
    115           node_name.get(gw.aNode(bfs)) <<
    116           (bfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") <<
    117           node_name.get(gw.bNode(bfs)) <<
     114        cout << edge_name[bfs] << /*endl*/", " <<
     115          node_name[gw.aNode(bfs)] <<
     116          (bfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") <<
     117          node_name[gw.bNode(bfs)] <<
    118118          (bfs.isBNodeNewlyReached() ? ": is newly reached." :
    119119           ": is not newly reached.");
    120120      } else {
    121121        cout << "invalid" << /*endl*/", " <<
    122           node_name.get(bfs.aNode()) <<
     122          node_name[bfs.aNode()] <<
    123123          (bfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") <<
    124124         
     
    146146      //cout << "edge: ";
    147147      if (gw.valid(dfs)) {
    148         cout << edge_name.get(dfs) << /*endl*/", " <<
    149           node_name.get(gw.aNode(dfs)) <<
    150           (dfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") <<
    151           node_name.get(gw.bNode(dfs)) <<
     148        cout << edge_name[dfs] << /*endl*/", " <<
     149          node_name[gw.aNode(dfs)] <<
     150          (dfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") <<
     151          node_name[gw.bNode(dfs)] <<
    152152          (dfs.isBNodeNewlyReached() ? ": is newly reached." :
    153153           ": is not newly reached.");
    154154      } else {
    155155        cout << "invalid" << /*endl*/", " <<
    156           node_name.get(dfs.aNode()) <<
     156          node_name[dfs.aNode()] <<
    157157          (dfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") <<
    158158         
     
    172172    cout << "bfs and dfs iterator demo on the reversed directed graph" << endl;
    173173    for(GW::NodeIt n(gw); gw.valid(n); gw.next(n)) {
    174       cout << node_name.get(n) << ": ";
     174      cout << node_name[n] << ": ";
    175175      cout << "out edges: ";
    176176      for(GW::OutEdgeIt e(gw, n); gw.valid(e); gw.next(e))
    177         cout << edge_name.get(e) << " ";
     177        cout << edge_name[e] << " ";
    178178      cout << "in edges: ";
    179179      for(GW::InEdgeIt e(gw, n); gw.valid(e); gw.next(e))
    180         cout << edge_name.get(e) << " ";
     180        cout << edge_name[e] << " ";
    181181      cout << endl;
    182182    }
     
    188188      //cout << "edge: ";
    189189      if (gw.valid(bfs)) {
    190         cout << edge_name.get(bfs) << /*endl*/", " <<
    191           node_name.get(gw.aNode(bfs)) <<
    192           (bfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") <<
    193           node_name.get(gw.bNode(bfs)) <<
     190        cout << edge_name[bfs] << /*endl*/", " <<
     191          node_name[gw.aNode(bfs)] <<
     192          (bfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") <<
     193          node_name[gw.bNode(bfs)] <<
    194194          (bfs.isBNodeNewlyReached() ? ": is newly reached." :
    195195           ": is not newly reached.");
    196196      } else {
    197197        cout << "invalid" << /*endl*/", " <<
    198           node_name.get(bfs.aNode()) <<
     198          node_name[bfs.aNode()] <<
    199199          (bfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") <<
    200200         
     
    222222      //cout << "edge: ";
    223223      if (gw.valid(dfs)) {
    224         cout << edge_name.get(dfs) << /*endl*/", " <<
    225           node_name.get(gw.aNode(dfs)) <<
    226           (dfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") <<
    227           node_name.get(gw.bNode(dfs)) <<
     224        cout << edge_name[dfs] << /*endl*/", " <<
     225          node_name[gw.aNode(dfs)] <<
     226          (dfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") <<
     227          node_name[gw.bNode(dfs)] <<
    228228          (dfs.isBNodeNewlyReached() ? ": is newly reached." :
    229229           ": is not newly reached.");
    230230      } else {
    231231        cout << "invalid" << /*endl*/", " <<
    232           node_name.get(dfs.aNode()) <<
     232          node_name[dfs.aNode()] <<
    233233          (dfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") <<
    234234         
     
    248248    cout << "bfs and dfs iterator demo on the undirected graph" << endl;
    249249    for(GW::NodeIt n(gw); gw.valid(n); gw.next(n)) {
    250       cout << node_name.get(n) << ": ";
     250      cout << node_name[n] << ": ";
    251251      cout << "out edges: ";
    252252      for(GW::OutEdgeIt e(gw, n); gw.valid(e); gw.next(e))
    253         cout << edge_name.get(e) << " ";
     253        cout << edge_name[e] << " ";
    254254      cout << "in edges: ";
    255255      for(GW::InEdgeIt e(gw, n); gw.valid(e); gw.next(e))
    256         cout << edge_name.get(e) << " ";
     256        cout << edge_name[e] << " ";
    257257      cout << endl;
    258258    }
     
    268268      //cout << "edge: ";
    269269      if (gw.valid(GW::OutEdgeIt(bfs))) {
    270         cout << edge_name.get(GW::OutEdgeIt(bfs)) << /*endl*/", " <<
    271           node_name.get(gw.aNode(bfs)) <<
    272           (bfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") <<
    273           node_name.get(gw.bNode(bfs)) <<
     270        cout << edge_name[GW::OutEdgeIt(bfs)] << /*endl*/", " <<
     271          node_name[gw.aNode(bfs)] <<
     272          (bfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") <<
     273          node_name[gw.bNode(bfs)] <<
    274274          (bfs.isBNodeNewlyReached() ? ": is newly reached." :
    275275           ": is not newly reached.");
    276276      } else {
    277277        cout << "invalid" << /*endl*/", " <<
    278           node_name.get(bfs.aNode()) <<
     278          node_name[bfs.aNode()] <<
    279279          (bfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") <<
    280280         
     
    302302      //cout << "edge: ";
    303303      if (gw.valid(GW::OutEdgeIt(dfs))) {
    304         cout << edge_name.get(GW::OutEdgeIt(dfs)) << /*endl*/", " <<
    305           node_name.get(gw.aNode(dfs)) <<
    306           (dfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") <<
    307           node_name.get(gw.bNode(dfs)) <<
     304        cout << edge_name[GW::OutEdgeIt(dfs)] << /*endl*/", " <<
     305          node_name[gw.aNode(dfs)] <<
     306          (dfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") <<
     307          node_name[gw.bNode(dfs)] <<
    308308          (dfs.isBNodeNewlyReached() ? ": is newly reached." :
    309309           ": is not newly reached.");
    310310      } else {
    311311        cout << "invalid" << /*endl*/", " <<
    312           node_name.get(dfs.aNode()) <<
     312          node_name[dfs.aNode()] <<
    313313          (dfs.isANodeExamined() ? ": is examined, " : ": is not examined, ") <<
    314314         
Note: See TracChangeset for help on using the changeset viewer.