本文整理汇总了C++中vertex_type::data方法的典型用法代码示例。如果您正苦于以下问题:C++ vertex_type::data方法的具体用法?C++ vertex_type::data怎么用?C++ vertex_type::data使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vertex_type
的用法示例。
在下文中一共展示了vertex_type::data方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: apply
/**
* \brief If the distance is smaller then update
*/
void apply(icontext_type& context, vertex_type& vertex,
const graphlab::empty& empty) {
changed = false;
if(vertex.data().dist > min_dist) {
changed = true;
vertex.data().dist = min_dist;
}
}
示例2: apply
// Change the vertex data if any of its neighbors have a lower data value.
void apply(icontext_type& context, vertex_type& vertex, const gather_type& total) {
// mark if values differ to determine which edges to scatter on.
if (message_value < vertex.data()) {
changed = true;
vertex.data() = message_value;
} else {
changed = false;
}
}
示例3: apply
void apply(icontext_type& context, vertex_type& vertex,
const gather_type& total)
{
changed = false;
if (vertex.data().color > total.color) {
changed = true;
vertex.data().color = total.color;
}
}
示例4: scatter
/**
* \brief The scatter function just signal adjacent pages
*/
void scatter(icontext_type& context, const vertex_type& vertex,
edge_type& edge) const {
const vertex_type other = get_other_vertex(edge, vertex);
distance_type newd = vertex.data().dist + edge.data().dist;
if (other.data().dist > newd) {
const min_distance_type msg(newd);
context.signal(other, msg);
}
} // end of scatter
示例5: apply
void apply(icontext_type& context, vertex_type& vertex, const gather_type &total) {
vertex_data_type new_label = most_common(total);
if (new_label != vertex.data()) {
vertex.data() = new_label;
changed = true;
} else {
changed = false;
}
}
示例6: scatter
// Scatter to scatter_edges edges with the new message value.
void scatter(icontext_type& context, const vertex_type& vertex, edge_type& edge) const {
bool isEdgeSource = (vertex.id() == edge.source().id());
bool hasSameData = isEdgeSource ? (vertex.data() == edge.target().data()) : (vertex.data() == edge.source().data()) ;
if (!hasSameData) {
min_combiner combiner;
combiner.value = message_value;
context.signal(isEdgeSource ? edge.target() : edge.source(), combiner);
}
}
示例7: apply
void apply(icontext_type& context, vertex_type& vertex,
const gather_type& total)
{
converged = true;
double new_pagerank = 0.15 + 0.85 * total.pagerank;
double delta = fabs(vertex.data().pagerank - new_pagerank);
vertex.data().pagerank = new_pagerank;
if (delta > EPS) {
converged = false;
}
}
示例8: apply
void apply(icontext_type& context, vertex_type& vertex, const gather_type& total)
{
cout << "apply(), vid=" << vertex.id() << endl;
cout << "total=" << total << endl;
// reset incoming messages
vertex.data().multiplied_incoming_messages.clear();
// iterate over message targets
for (set<vertex_id_type>::const_iterator target_it=total.message_targets.begin(); target_it!=total.message_targets.end(); ++target_it)
{
vertex_id_type target_id=*target_it;
// iterate over message sources (and the betas)
for (map<vertex_id_type, VectorXd>::const_iterator source_it=total.message_source_betas.begin(); source_it!=total.message_source_betas.end(); ++source_it)
{
vertex_id_type source_id=source_it->first;
// we dont need to consider the kernel matrix of a edge with itself since this is always omitted in the message scheduling
if (source_id==target_id)
continue;
cout << "adding message from " << source_id << " to " << vertex.id() << " to construct message from " << vertex.id() << " to " << target_id << endl;
// extract K and beta for incoming message
MatrixXd K=vertex.data().kernel_dict[pair<vertex_id_type, vertex_id_type>(target_id,source_id)];
VectorXd beta=source_it->second;
// if beta has zero rows, it is initialised to constant with unit norm (first iteration)
if (!beta.rows())
{
beta=VectorXd::Constant(K.cols(), 1.0);
beta=beta/beta.norm();
}
cout << "K_" << vertex.id() << "^(" << target_id << "," << source_id << "):" << endl << K << endl;
cout << "times" << endl;
cout << "beta_(" << source_id << "," << vertex.id() << "):" << endl << beta << endl;
// for a fixed source and target node, compute incoming kernelbp message
VectorXd message=K*beta;
cout << "message: " << message << endl;
// multiply all messages together
if (vertex.data().multiplied_incoming_messages.find(target_id)==vertex.data().multiplied_incoming_messages.end())
vertex.data().multiplied_incoming_messages[target_id]=message;
else
{
cout << "old message product: " << vertex.data().multiplied_incoming_messages[target_id] << endl;
vertex.data().multiplied_incoming_messages[target_id]=vertex.data().multiplied_incoming_messages[target_id].cwiseProduct(message);
}
cout << "new message product: " << vertex.data().multiplied_incoming_messages[target_id] << endl;
}
}
}
示例9: apply
void apply(icontext_type& context, vertex_type& vertex, const gather_type &total) {
if (context.iteration() == 0) {
vertex.data().neighbors = total.get();
} else {
size_t d = vertex.data().neighbors.size();
size_t t = last_msg;
// Due to rounding errors, the results is sometimes not exactly
// 0.0 even when it should be. Explicitly set LCC to 0 if that
// is the case, other calculate it as tri / (degree * (degree - 1))
double lcc = (d < 2 || t == 0) ? 0.0 : double(t) / (d * (d - 1));
vertex.data().clustering_coef = lcc;
}
}
示例10: apply
/* Use the total rank of adjacent pages to update this page */
void apply(icontext_type& context, vertex_type& vertex,
const double& total) {
//printf("Entered apply on node %d value %lg\n", vertex.id(), total);
vertex_data & user = vertex.data();
assert(mi.x_offset >=0 || mi.y_offset >= 0);
assert(mi.r_offset >=0);
/* perform orthogonalization of current vector */
if (mi.orthogonalization){
for (int i=mi.mat_offset; i< mi.vec_offset; i++){
vertex.data().pvec[mi.vec_offset] -= alphas.pvec[i-mi.mat_offset] * vertex.data().pvec[i];
}
return;
}
double val = total;
//assert(total != 0 || mi.y_offset >= 0);
//store previous value for convergence detection
if (mi.prev_offset >= 0)
user.pvec[mi.prev_offset ] = user.pvec[mi.r_offset];
assert(mi.x_offset >=0 || mi.y_offset>=0);
if (mi.A_offset && mi.x_offset >= 0){
if (info.is_square() && mi.use_diag)// add the diagonal term
val += (/*mi.c**/ (user.A_ii+ regularization) * user.pvec[mi.x_offset]);
//printf("node %d added diag term: %lg\n", vertex.id(), user.A_ii);
val *= mi.c;
}
/***** COMPUTE r = c*I*x *****/
else if (!mi.A_offset && mi.x_offset >= 0){
val = mi.c*user.pvec[mi.x_offset];
}
/**** COMPUTE r+= d*y (optional) ***/
if (mi.y_offset>= 0){
val += mi.d*user.pvec[mi.y_offset];
}
/***** compute r = (... ) / div */
if (mi.div_offset >= 0){
val /= user.pvec[mi.div_offset];
}
user.pvec[mi.r_offset] = val;
//printf("Exit apply on node %d value %lg\n", vertex.id(), val);
}
示例11: gather
/** The gather function computes XtX and Xy */
gather_type gather(icontext_type& context, const vertex_type& vertex,
edge_type& edge) const {
if(edge.data().role == edge_data::TRAIN) {
const vertex_type other_vertex = get_other_vertex(edge, vertex);
return gather_type(other_vertex.data().factor, edge.data().obs);
} else return gather_type();
} // end of gather function
示例12: aggregate
void aggregate(icontext_type& context, const vertex_type& vertex){
if (!marked) {
marked = true;
saedb::IAggregator* active_node = context.getAggregator("active_node");
float t = vertex.data();
active_node->reduce(&t);
}
}
示例13: scatter_edges
edge_dir_type scatter_edges(icontext_type& context, const vertex_type& vertex) const {
if( vertex.data().changed == 1 ) {
return OUT_EDGES;
}
else {
return NO_EDGES;
}
}
示例14: scatter
void scatter(icontext_type& context, const vertex_type& vertex,
edge_type& edge) const {
const vertex_type other = edge.target();
pagerank_type value = vertex.data().pagerank / vertex.num_out_edges();
assert(other.id() != vertex.id());
const sum_pagerank_type msg(value);
context.signal(other, msg);
}
示例15: scatter
void scatter(icontext_type& context, const vertex_type& vertex,
edge_type& edge) const
{
const vertex_type other = edge.target();
distance_type newd = vertex.data().dist + edge.data().dist;
const min_distance_type msg(newd);
context.signal(other, msg);
}