当前位置: 首页>>代码示例>>C++>>正文


C++ graph_t::root方法代码示例

本文整理汇总了C++中graph_t::root方法的典型用法代码示例。如果您正苦于以下问题:C++ graph_t::root方法的具体用法?C++ graph_t::root怎么用?C++ graph_t::root使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在graph_t的用法示例。


在下文中一共展示了graph_t::root方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: StarDecomp

//#undef __FUNCT__  
//#define __FUNCT__ "LowStretchSpanningTreeHelper"
int StarDecomp(graph_t g,const int root,const float delta,const float epsilon,
	       int& k,std::vector<int>& size,std::vector<std::vector<int> >& idx,
	       std::vector<int>& x,std::vector<int>& y)
{
    int n,m,edgesLeft;
    //PetscErrorCode ierr;
    //ShortestPathPriorityQueue pq;
//    float radius;

    std::vector<int> centerIdx;
    


    //PQNode node;

//  PetscFunctionBegin;

    //printf("going to into ball cut segment\n");

    graph_t& root_graph = g.is_root() ? g : g.root();
    weight_map_t edge_weight_g = get(edge_weight,root_graph);  // actually all property maps are same! so don't worry!
    f_edges_t f_edges_g = get(edge_index, g);
    vert_dist_t root_dist = get(vertex_distance, g);
    n = num_vertices(g);
    m = num_edges(g);
    edgesLeft = m;

//    std::vector<int> 
//    std::vector<int> pred(n,-1);
    //std::vector<int> succ[n]; 
    std::vector<int>::iterator i;
//    float dist[n];
//    std::vector<bool> taken(n,false);

    // running dijkstra
    float radius;
    std::vector<vertex_descriptor> ordered_nodes(n);
    int cntr = 0;
    //std::vector<float> root_dist(n);
    std::vector<int> pred(n, -1);
    std::vector<int> color_map(n, WHITE);
    //int num_root_edges = g.is_root() ? num_edges(g) : num_edges(g.root());
    //printf("num_root_edges: %d\n", num_root_edges);
    //std::vector<bool> fedges(num_root_edges);// turns out edge_index not local fedges(m, false);
    p_comp_min_class comp(&root_dist);
    identity_property_map ident;
    PropertyMinQueue pq(n, comp, ident);
    root_dist[root] = 0.0;
    pred[root] = root;
    pq.push(root);
    //printf("about to go to dijkstra while loop\n");
    while(!pq.empty())
    {
	//printf("top of while\n");
	vertex_descriptor u = pq.top();
	pq.pop();
	color_map[u] = BLACK;
	// put the edge that got us to u into fedges
	vertex_descriptor pred_u = pred[u];
	//radius = root_dist[u];
	ordered_nodes[cntr++] = u;
	if (pred_u != u)
	{
	    edge_descriptor e = edge(pred_u, u, g).first;
	    put(f_edges_g, e, true);
	}
	//printf("after fedges\n");
	adjacency_it i, i_end;
	for (tie(i, i_end) = adjacent_vertices(u, g); i != i_end; i++)
	{
	    vertex_descriptor v = *i;
	    if (color_map[v] == WHITE)
	    {
		//printf("before pred[v]\n");
		pred[v] = u;
		//printf("before edge_weight_g; pred_u: %d, u: %d\n", pred_u, u);
		root_dist[v] = root_dist[u] + 1.0/get(edge_weight_g, g.local_to_global(edge(u,v, g).first));
		//printf("before color_map\n");
		color_map[v] = GREY;
		pq.push(v);
	    }
	    else if (color_map[v] == GREY)
	    {
		float new_dist = root_dist[u] + 1.0/get(edge_weight_g, g.local_to_global(edge(u, v, g).first));
		if (new_dist < root_dist[v])
		{
		    root_dist[v] = new_dist;
		    pred[v] = u;
		    pq.update(v);
		}
	    }
	}
    }

    //printf("did dijkstra\n");

    radius = root_dist[ordered_nodes.back()];
    float min_radius = delta*radius;
//.........这里部分代码省略.........
开发者ID:jiecchen,项目名称:LapSolver,代码行数:101,代码来源:lowstretch2.cpp


注:本文中的graph_t::root方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。