本文整理汇总了C++中graph_access::getX方法的典型用法代码示例。如果您正苦于以下问题:C++ graph_access::getX方法的具体用法?C++ graph_access::getX怎么用?C++ graph_access::getX使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类graph_access
的用法示例。
在下文中一共展示了graph_access::getX方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: run_maxent_optimization_internal
void local_optimizer::run_maxent_optimization_internal( const Config & config, graph_access & G ) {
if(G.number_of_edges() == 0) return;
std::vector< coord_t > new_coord(G.number_of_nodes());
CoordType alpha = config.maxent_alpha;
int iterations = config.maxent_inner_iterations;
CoordType q = config.q;
std::vector<CoordType> distances(G.number_of_edges(),0);
configure_distances( config, G, distances);
for( int i = 0; i < config.maxent_outer_iterations; i++) {
CoordType norm_coords = 0;
CoordType norm_diff = 0;
do {
forall_nodes_parallel(G, node) {
CoordType rho_i = 0; // assume graph is connected?
if(G.getNodeDegree(node) == 0) continue;
forall_out_edges(G, e, node) {
CoordType distance = distances[e];
rho_i += 1/(distance*distance);
} endfor
rho_i = 1/rho_i;
CoordType S_x = 0;
CoordType S_y = 0;
CoordType n_S_x = 0;
CoordType n_S_y = 0;
forall_out_edges(G, e, node) {
NodeID target = G.getEdgeTarget(e);
CoordType diffX = G.getX(node) - G.getX(target);
CoordType diffY = G.getY(node) - G.getY(target);
CoordType dist_square = diffX*diffX+diffY*diffY;
CoordType distance = distances[e];
CoordType dist = sqrt(dist_square);
CoordType scaled_distance = distance/dist;
CoordType squared_distance = distance*distance;
S_x += (G.getX(target) + scaled_distance*diffX)/(squared_distance);
S_y += (G.getY(target) + scaled_distance*diffY)/(squared_distance);
CoordType dist_q = pow(dist, q+2);
n_S_x -= diffX/dist_q;
n_S_y -= diffY/dist_q;
} endfor
S_x *= rho_i;
S_y *= rho_i;
forall_nodes(G, target) {
if( node == target ) continue;
CoordType diffX = G.getX(node) - G.getX(target);
CoordType diffY = G.getY(node) - G.getY(target);
CoordType dist_square = diffX*diffX+diffY*diffY;
CoordType dist = sqrt(dist_square);
CoordType dist_q = pow(dist, q+2);
n_S_x += diffX/dist_q;
n_S_y += diffY/dist_q;
} endfor
CoordType mult_factor = alpha*rho_i;
n_S_x *= mult_factor;
n_S_y *= mult_factor;
new_coord[node].x = S_x + sgn(q)*n_S_x;
new_coord[node].y = S_y + sgn(q)*n_S_y;
} endfor