本文整理汇总了C++中sgraph::remove_edge_field方法的典型用法代码示例。如果您正苦于以下问题:C++ sgraph::remove_edge_field方法的具体用法?C++ sgraph::remove_edge_field怎么用?C++ sgraph::remove_edge_field使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sgraph
的用法示例。
在下文中一共展示了sgraph::remove_edge_field方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: execute
virtual void execute(sgraph& output,
const std::vector<sgraph*>& parents) {
output.remove_edge_field(field, groupa, groupb);
}
示例2: triple_apply_kcore
//.........这里部分代码省略.........
edge_direction::ANY_EDGE);
g.replace_vertex_field(degrees, DEGREE_COLUMN);
// Initialize fields
long vertices_left = g.num_vertices();
std::atomic<long> num_vertices_changed;
const size_t core_idx = g.get_vertex_field_id(CORE_ID_COLUMN);
const size_t degree_idx = g.get_vertex_field_id(DEGREE_COLUMN);
const size_t v_deleted_idx= g.get_vertex_field_id(DELETED_COLUMN);
const size_t e_deleted_idx= g.get_edge_field_id(DELETED_COLUMN);
// Triple apply
sgraph_compute::triple_apply_fn_type apply_fn =
[&](sgraph_compute::edge_scope& scope) {
auto& source = scope.source();
auto& target = scope.target();
auto& edge = scope.edge();
scope.lock_vertices();
// edge is not deleted
if (!edge[e_deleted_idx]) {
// check source degree
if (!source[v_deleted_idx] && source[degree_idx] <= CURRENT_K) {
source[core_idx] = CURRENT_K;
source[v_deleted_idx] = 1;
num_vertices_changed++;
}
// check target degree
if (!target[v_deleted_idx] && target[degree_idx] <= CURRENT_K) {
target[core_idx] = CURRENT_K;
target[v_deleted_idx] = 1;
num_vertices_changed ++;
}
// delete the edge if either side is deleted
if (source[v_deleted_idx] || target[v_deleted_idx]) {
edge[e_deleted_idx] = 1;
--source[degree_idx];
--target[degree_idx];
// We need to check again if the deletion of this edge
// causing either source or target vertex to be deleted.
if (!source[v_deleted_idx] && source[degree_idx] <= CURRENT_K) {
source[core_idx] = CURRENT_K;
source[v_deleted_idx] = 1;
num_vertices_changed++;
}
// check target degree
if (!target[v_deleted_idx] && target[degree_idx] <= CURRENT_K) {
target[core_idx] = CURRENT_K;
target[v_deleted_idx] = 1;
num_vertices_changed++;
}
}
}
scope.unlock_vertices();
};
for (CURRENT_K = KMIN; CURRENT_K < KMAX; ++CURRENT_K) {
while (true) {
if(cppipc::must_cancel()) {
log_and_throw(std::string("Toolkit cancelled by user."));
}
num_vertices_changed = 0;
sgraph_compute::triple_apply(g, apply_fn, {CORE_ID_COLUMN, DEGREE_COLUMN, DELETED_COLUMN}, {DELETED_COLUMN});
if (num_vertices_changed == 0)
break;
vertices_left -= num_vertices_changed;
if (CURRENT_K == 0 || num_vertices_changed == 0 || vertices_left == 0) {
// we are done with the current core.
break;
}
ASSERT_GT(vertices_left, 0);
}
logprogress_stream << "Finish computing core " << CURRENT_K << "\t Vertices left: "
<< vertices_left << std::endl;
if (vertices_left == 0) {
break;
}
} // end of kcore iterations
auto final_core_ids = sgraph_compute::vertex_apply(
g,
degrees,
flex_type_enum::INTEGER,
[&](const std::vector<flexible_type>& vdata, const flexible_type& actual_degree) -> flexible_type {
if (!vdata[v_deleted_idx]) {
// active vertices gets KMAX
return flexible_type(KMAX);
} else if (actual_degree == 0) {
// singleton degree gets KMIN
return flexible_type(KMIN);
} else {
return vdata[core_idx];
}
});
g.replace_vertex_field(final_core_ids, CORE_ID_COLUMN);
// cleanup
g.remove_vertex_field(DEGREE_COLUMN);
g.remove_vertex_field(DELETED_COLUMN);
g.remove_edge_field(DELETED_COLUMN);
}