本文整理汇总了C++中graph::number_of_nodes方法的典型用法代码示例。如果您正苦于以下问题:C++ graph::number_of_nodes方法的具体用法?C++ graph::number_of_nodes怎么用?C++ graph::number_of_nodes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类graph
的用法示例。
在下文中一共展示了graph::number_of_nodes方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: check
int mincut::check (graph& G)
{
if (!set_vars_executed)
{
return(GTL_ERROR);
}
if ((G.number_of_nodes() <= 1) || (!G.is_connected()) || (G.is_directed()))
{
return(GTL_ERROR);
}
return GTL_OK;
}
示例2:
__GTL_BEGIN_NAMESPACE
pathfinder::pathfinder (const graph& G, edge st, node s)
{
node t = s.opposite (st);
dfs_num.init (G, 0);
low_num.init (G);
tree.init (G, list<edge>());
back.init (G, list<edge>());
forward.init (G, list<edge>());
//
// There is a problem with node/edge maps of iterators with Visual C++
// which I don´t fully understand at the moment. Anyway the init for the
// maps below is only needed to allocate memory, which is done anyway, when
// values are assigned to it.
//
#ifndef __GTL_MSVCC
to_low.init (G);
to_father.init (G);
pos.init (G);
#endif
used.init (G,0);
act_dfs_num = 1;
new_nodes = G.number_of_nodes();
is_biconn = true;
//
// Do DFS with biconnectivity extensions.
//
dfs_num[t] = act_dfs_num++;
low_num[t] = dfs_num[t];
new_nodes--;
dfs_sub (s, t);
if (new_nodes != 0) {
is_biconn = false;
}
used[t] = used[s] = 1;
}
示例3: init_handler
void topsort::init_handler (graph& G)
{
top_numbers.init (G, 0);
act_top_num = G.number_of_nodes();
}
示例4: run
int dijkstra::run(graph& G)
{
init(G);
less_dist prd(&dist, &mark);
bin_heap<node, less_dist> node_heap(prd, G.number_of_nodes());
mark[s] = grey;
dist[s] = 0.0;
node_heap.push(s);
while (!node_heap.is_empty())
{
// debug:
// node_heap.print_data_container();
node cur_node = node_heap.top();
node_heap.pop();
// debug:
// node_heap.print_data_container();
mark[cur_node] = white;
if (cur_node == t)
{
// if @a t is set through #target we are ready
return GTL_OK;
}
node::adj_edges_iterator adj_edge_it;
node::adj_edges_iterator adj_edges_end = cur_node.adj_edges_end();
for (adj_edge_it = cur_node.adj_edges_begin();
adj_edge_it != adj_edges_end;
++adj_edge_it)
{
node op_node = (*adj_edge_it).opposite(cur_node);
if (mark[op_node] == black)
{
mark[op_node] = grey;
dist[op_node] = dist[cur_node] + weight[*adj_edge_it];
node_heap.push(op_node);
// debug:
// node_heap.print_data_container();
if (preds_set)
{
pred[op_node] = *adj_edge_it;
}
}
else if (mark[op_node] == grey)
{
if (dist[op_node] > dist[cur_node] + weight[*adj_edge_it])
{
dist[op_node] = dist[cur_node] + weight[*adj_edge_it];
node_heap.changeKey(op_node);
// debug:
// node_heap.print_data_container();
if (preds_set)
{
pred[op_node] = *adj_edge_it;
}
}
}
else // (mark[op_node] == white)
{
// nothing to do: shortest distance to op_node is already
// computed
}
}
}
return GTL_OK;
}