本文整理汇总了C++中GraphT::initializeSearch方法的典型用法代码示例。如果您正苦于以下问题:C++ GraphT::initializeSearch方法的具体用法?C++ GraphT::initializeSearch怎么用?C++ GraphT::initializeSearch使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GraphT
的用法示例。
在下文中一共展示了GraphT::initializeSearch方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: result
ArticulationResult<GraphT>
find_articulation_vertices(GraphT& g) {
g.initializeSearch();
ArticulationResult<GraphT> result(g);
auto pEarly = bind(&ArticulationResult<GraphT>::processEarly, ref(result), _1);
auto pLate = bind(&ArticulationResult<GraphT>::processLate, ref(result), _1);
auto pEdge = bind(&ArticulationResult<GraphT>::processEdge, ref(result), _1, _2);
g.dfs("v1", pEarly, pLate, pEdge);
return result;
}
示例2: while
void
dijkstra(GraphT& g, typename GraphT::Vertex& start) {
using Vertex = typename GraphT::Vertex;
g.initializeSearch();
unordered_map<Vertex*, bool> intree;
int weight;
int dist;
Vertex* v = &start;
v->distance = 0;
while (!intree[v]) {
intree[v] = true;
for (auto& e : v->edges) {
auto w = e.w;
weight = e.weight;
if (w->distance > weight + v->distance) {
w->distance = weight + v->distance;
w->parent = v;
}
}
dist = MAX_INT;
for (auto& x : g) {
if (!intree[&x] && (dist > x.distance)) {
dist = x.distance;
v = &x;
}
}
}
}