demo/graph_orientation.cc
changeset 1919 9704601de87f
parent 1901 723b2b81d900
child 1956 a055123339d5
equal deleted inserted replaced
3:1edec8381b2e 4:7af1f5e82504
    68   ListGraph::NodeMap<int> level(g,0);
    68   ListGraph::NodeMap<int> level(g,0);
    69   
    69   
    70   ListGraph::NodeMap<int> def(g); //deficiency of the nodes
    70   ListGraph::NodeMap<int> def(g); //deficiency of the nodes
    71   def = subMap(f,InDegMap<ListGraph>(g));
    71   def = subMap(f,InDegMap<ListGraph>(g));
    72   
    72   
    73   IterableBoolNodeMap<ListGraph> active(g,false);
    73   IterableBoolMap<ListGraph, Node> active(g,false);
    74   for(NodeIt n(g);n!=INVALID;++n) active[n]=(def[n]>0);
    74   for(NodeIt n(g);n!=INVALID;++n) active[n]=(def[n]>0);
    75   
    75   
    76   ListGraph::EdgeMap<bool> rev(g,false); // rev[e]==true <=> e is be 
    76   ListGraph::EdgeMap<bool> rev(g,false); // rev[e]==true <=> e is be 
    77                                          //                  reversed
    77                                          //                  reversed
    78 
    78 
    79   int nodeNum=countNodes(g);
    79   int nodeNum=countNodes(g);
    80   
    80   
    81   Node act;
    81   Node act;
    82   while((act=IterableBoolNodeMap<ListGraph>::TrueIt(active))!=INVALID) {
    82   while((act=IterableBoolMap<ListGraph, Node>::TrueIt(active))!=INVALID) {
    83     std::cout << "Process node " << label[act]
    83     std::cout << "Process node " << label[act]
    84 	      << " (def=" << def[act]
    84 	      << " (def=" << def[act]
    85 	      << " lev=" << level[act] << "): ";
    85 	      << " lev=" << level[act] << "): ";
    86     OutEdgeIt e(g,act);
    86     OutEdgeIt e(g,act);
    87     while(e!=INVALID && level[g.target(e)]>=level[act]) ++e;
    87     while(e!=INVALID && level[g.target(e)]>=level[act]) ++e;