src/work/marci/bipartite_graphs.h
changeset 540 405ccc3105e1
parent 455 14a1d11ddf21
equal deleted inserted replaced
0:35bb5c1688bd 1:1c747ac5feb6
    33 	}
    33 	}
    34       }
    34       }
    35     }
    35     }
    36     return true;
    36     return true;
    37   }
    37   }
       
    38 
       
    39   /// experimental topsort, 
       
    40   /// I think the final version will work as an iterator
       
    41   template<typename Graph> 
       
    42   void topSort(Graph& g, std::list<typename Graph::Node>& l) {
       
    43     l.clear();
       
    44     typedef typename Graph::template NodeMap<bool> ReachedMap;
       
    45     ReachedMap reached(g/*, false*/);
       
    46     DfsIterator<Graph, ReachedMap> dfs(g, reached);
       
    47     FOR_EACH_LOC(typename Graph::NodeIt, n, g) {
       
    48       if (!reached[n]) {
       
    49 	dfs.pushAndSetReached(n);
       
    50 	while (!bfs.finished()) {
       
    51 	  if (bfs.isANodeExamined()) {
       
    52 	    l.push_back(bfs.aNode());
       
    53 	  }
       
    54 	  ++bfs;
       
    55 	}
       
    56       }
       
    57     }
       
    58   }
    38 }
    59 }
    39 #endif //HUGO_BIPARTITE_GRAPHS_H
    60 #endif //HUGO_BIPARTITE_GRAPHS_H