本文整理汇总了C++中Digraph::V方法的典型用法代码示例。如果您正苦于以下问题:C++ Digraph::V方法的具体用法?C++ Digraph::V怎么用?C++ Digraph::V使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Digraph
的用法示例。
在下文中一共展示了Digraph::V方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: order
/* @brief construct a SCC with a graph and compute
* strongly connected component
* @param dg Digraph
*/
SCC::SCC(const Digraph &dg){
//initialize private menber
marked = vector<bool>(dg.V(),false);
__id = vector<int>(dg.V());
__count = 0;
for(int i=0; i<dg.V(); ++i){
__id[i] = i;
}
//dg's reverse graph
const Digraph rdg = dg.reverse();
//rdg's order
DFSOrder order(rdg);
//reverse order of dg's reverse graph
deque<int> reverseOrder = order.reverseOrder();
//depth first searh in reverseOrder
__count = 0;
int num = reverseOrder.size();
for(int i=0; i<num; ++i){
int v = reverseOrder[i];
if( !marked[v] ){
dfs(dg,v);
//search one strongly connected component
++__count;
}
}
}
示例2:
DirectedDFS::DirectedDFS(const Digraph &dg, const std::vector<int> &sources){
marked = vector<bool>(dg.V(), false);
edgeTo = vector<int>(dg.V());
srcs = set<int>(sources.begin(), sources.end());
for(size_t i=0; i<sources.size(); ++i){
if( !marked[ sources[i] ] ){
dfs(dg, sources[i] );
}
}
}