本文整理汇总了C++中graph_access::start_construction方法的典型用法代码示例。如果您正苦于以下问题:C++ graph_access::start_construction方法的具体用法?C++ graph_access::start_construction怎么用?C++ graph_access::start_construction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类graph_access
的用法示例。
在下文中一共展示了graph_access::start_construction方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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
}
示例2: contract
// for documentation see technical reports of christian schulz
void contraction::contract(const PartitionConfig & partition_config,
graph_access & G,
graph_access & coarser,
const Matching & edge_matching,
const CoarseMapping & coarse_mapping,
const NodeID & no_of_coarse_vertices,
const NodePermutationMap & permutation) const {
if(partition_config.combine) {
coarser.resizeSecondPartitionIndex(no_of_coarse_vertices);
}
std::vector<NodeID> new_edge_targets(G.number_of_edges());
forall_edges(G, e) {
new_edge_targets[e] = coarse_mapping[G.getEdgeTarget(e)];
} endfor
std::vector<EdgeID> edge_positions(no_of_coarse_vertices, UNDEFINED_EDGE);
//we dont know the number of edges jet, so we use the old number for
//construction of the coarser graph and then resize the field according
//to the number of edges we really got
coarser.start_construction(no_of_coarse_vertices, G.number_of_edges());
NodeID cur_no_vertices = 0;
forall_nodes(G, n) {
NodeID node = permutation[n];
//we look only at the coarser nodes
if(coarse_mapping[node] != cur_no_vertices)
continue;
NodeID coarseNode = coarser.new_node();
coarser.setNodeWeight(coarseNode, G.getNodeWeight(node));
if(partition_config.combine) {
coarser.setSecondPartitionIndex(coarseNode, G.getSecondPartitionIndex(node));
}
// do something with all outgoing edges (in auxillary graph)
forall_out_edges(G, e, node) {
visit_edge(G, coarser, edge_positions, coarseNode, e, new_edge_targets);
} endfor