//#undef __FUNCT__ //#define __FUNCT__ "LowStretchSpanningTreeHelper" void LowStretchSpanningTreeHelper(graph_t& g,const int root,const float alpha, graph_t& h)//,int perm[]) { int n,i,j,k; std::vector<int> size,x,y; std::vector<std::vector<int> > idx; int ierr; // PetscFunctionBegin; weight_map_t edge_weight_g = get(edge_weight_t(),g); // VertexWeight vertex_weight_h = get(vertex_weight_t(),h); n = num_vertices(g); if (n > 2) { ierr = StarDecomp(g,root,1.0/3.0,alpha,k,size,idx,x,y); j = 0; for (i=1;i<=k;i++) { graph_t& g1 = g.create_subgraph(idx[i].begin(),idx[i].end()); graph_t& h1 = h.create_subgraph(idx[i].begin(),idx[i].end()); LowStretchSpanningTreeHelper(g1,g1.global_to_local(g.local_to_global(x[i-1])),alpha,h1);//,perm+j); j += size[i]; } graph_t& g1 = g.create_subgraph(idx[0].begin(),idx[0].end()); graph_t& h1 = h.create_subgraph(idx[0].begin(),idx[0].end()); LowStretchSpanningTreeHelper(g1,g1.global_to_local(g.local_to_global(root)),alpha,h1);//,perm+j); for (i=0;i<k;i++) { float w = get(edge_weight_g,edge(x[i],y[i],g).first); add_edge(x[i],y[i],w,h); // put(vertex_weight_h,x[i],get(vertex_weight_h,x[i])+w); // put(vertex_weight_h,y[i],get(vertex_weight_h,y[i])+w); } } else if (n == 2) { graph_traits<graph_t>::edge_descriptor e = *(out_edges(root,g).first); int t = target(e,g); float w = get(edge_weight_g,e); add_edge(root,t,w,h); // put(vertex_weight_h,root,get(vertex_weight_h,root)+w); // put(vertex_weight_h,t,get(vertex_weight_h,t)+w); // perm[0] = g.local_to_global(t); // perm[1] = g.local_to_global(root); } else /* n == 1 */ { // perm[0] = g.local_to_global(root); } //return 0; }
size_t biconnected_components(graph_t& g, vector<graph_t*>& bicomponents) { map< edge_descriptor_t, unsigned > bicomponent_edges; vector<vertex_discripter_t> articulation_points; articulation_points.reserve(num_vertices(g)); int n = biconnected_components(g, make_assoc_property_map(bicomponent_edges), back_inserter(articulation_points) ).first; int o = bicomponents.size(); for (int i=0; i<n; i++) bicomponents.push_back( &(g.create_subgraph()) ); graph_traits<graph_t>::edge_iterator e, e_end; for (tie(e, e_end) = edges(g); e != e_end; ++e) { add_vertex_once( source(*e,g), *bicomponents[o+bicomponent_edges[*e]] ); add_vertex_once( target(*e,g), *bicomponents[o+bicomponent_edges[*e]] ); } // cout << "Graph #" << ... << " : " << get(graph_name, g); // cout << " |V|=" << num_vertices(g) << endl; // cout << " |Component|=" << bicomponents.size() << endl; vector<vertex_discripter_t>::iterator v,v_end; cout << "Art.pts.\tComponents\n"; // cout << articulation_points.size() << endl; for (v=articulation_points.begin(), v_end=articulation_points.end(); v != v_end; v++) { cout << get(&vertex_properties::id, g, *v) << "\t\t"; for (int i=0; i<n; i++) if ((bicomponents[o+i]->find_vertex(*v)).second) cout << ' ' << o+i << ' '; cout << endl; } return n; }