本文整理汇总了C++中graph_access::setEdgeWeight方法的典型用法代码示例。如果您正苦于以下问题:C++ graph_access::setEdgeWeight方法的具体用法?C++ graph_access::setEdgeWeight怎么用?C++ graph_access::setEdgeWeight使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类graph_access
的用法示例。
在下文中一共展示了graph_access::setEdgeWeight方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: extract_block
void graph_extractor::extract_block(graph_access & G,
graph_access & extracted_block,
PartitionID block,
std::vector<NodeID> & mapping) {
// build reverse mapping
std::vector<NodeID> reverse_mapping;
NodeID nodes = 0;
NodeID dummy_node = G.number_of_nodes() + 1;
forall_nodes(G, node) {
if(G.getPartitionIndex(node) == block) {
reverse_mapping.push_back(nodes++);
} else {
reverse_mapping.push_back(dummy_node);
}
} endfor
extracted_block.start_construction(nodes, G.number_of_edges());
forall_nodes(G, node) {
if(G.getPartitionIndex(node) == block) {
NodeID new_node = extracted_block.new_node();
mapping.push_back(node);
extracted_block.setNodeWeight( new_node, G.getNodeWeight(node));
forall_out_edges(G, e, node) {
NodeID target = G.getEdgeTarget(e);
if( G.getPartitionIndex( target ) == block ) {
EdgeID new_edge = extracted_block.new_edge(new_node, reverse_mapping[target]);
extracted_block.setEdgeWeight(new_edge, G.getEdgeWeight(e));
}
} endfor
}