template <typename PointT> bool pcl::registration::ELCH<PointT>::initCompute () { /*if (!PCLBase<PointT>::initCompute ()) { PCL_ERROR ("[pcl::registration:ELCH::initCompute] Init failed.\n"); return (false); }*/ //TODO if (loop_end_ == 0) { PCL_ERROR ("[pcl::registration::ELCH::initCompute] no end of loop defined!\n"); deinitCompute (); return (false); } //compute transformation if it's not given if (compute_loop_) { PointCloudPtr meta_start (new PointCloud); PointCloudPtr meta_end (new PointCloud); *meta_start = *(*loop_graph_)[loop_start_].cloud; *meta_end = *(*loop_graph_)[loop_end_].cloud; typename boost::graph_traits<LoopGraph>::adjacency_iterator si, si_end; for (boost::tuples::tie (si, si_end) = adjacent_vertices (loop_start_, *loop_graph_); si != si_end; si++) *meta_start += *(*loop_graph_)[*si].cloud; for (boost::tuples::tie (si, si_end) = adjacent_vertices (loop_end_, *loop_graph_); si != si_end; si++) *meta_end += *(*loop_graph_)[*si].cloud; //TODO use real pose instead of centroid //Eigen::Vector4f pose_start; //pcl::compute3DCentroid (*(*loop_graph_)[loop_start_].cloud, pose_start); //Eigen::Vector4f pose_end; //pcl::compute3DCentroid (*(*loop_graph_)[loop_end_].cloud, pose_end); PointCloudPtr tmp (new PointCloud); //Eigen::Vector4f diff = pose_start - pose_end; //Eigen::Translation3f translation (diff.head (3)); //Eigen::Affine3f trans = translation * Eigen::Quaternionf::Identity (); //pcl::transformPointCloud (*(*loop_graph_)[loop_end_].cloud, *tmp, trans); reg_->setInputTarget (meta_start); reg_->setInputCloud (meta_end); reg_->align (*tmp); loop_transform_ = reg_->getFinalTransformation (); //TODO hack //loop_transform_ *= trans.matrix (); } return (true); }
static void getForwardReach(const NGHolder &g, u32 top, map<s32, CharReach> &look) { ue2::flat_set<NFAVertex> curr, next; // Consider only successors of start with the required top. for (const auto &e : out_edges_range(g.start, g)) { NFAVertex v = target(e, g); if (v == g.startDs) { continue; } if (g[e].top == top) { curr.insert(v); } } for (u32 i = 0; i < MAX_FWD_LEN; i++) { if (curr.empty() || contains(curr, g.accept) || contains(curr, g.acceptEod)) { break; } next.clear(); CharReach cr; for (auto v : curr) { assert(!is_special(v, g)); cr |= g[v].char_reach; insert(&next, adjacent_vertices(v, g)); } assert(cr.any()); look[i] |= cr; curr.swap(next); } }
inline std::pair< typename DIRECTED_GRAPH::adjacency_iterator, typename DIRECTED_GRAPH::adjacency_iterator > adjacent_vertices(typename DIRECTED_GRAPH::vertex_descriptor v, DIRECTED_GRAPH const& g) { return adjacent_vertices(v, g.impl()); }
int tree_dec_lospre_introduce(T_t &T, typename boost::graph_traits<T_t>::vertex_descriptor t, const G_t &G) { typedef typename boost::graph_traits<T_t>::adjacency_iterator adjacency_iter_t; adjacency_iter_t c, c_end; assignment_list_lospre_t::iterator ai; boost::tie(c, c_end) = adjacent_vertices(t, T); assignment_list_lospre_t &alist2 = T[t].assignments; assignment_list_lospre_t &alist = T[*c].assignments; if(alist.size() > size_t(options.max_allocs_per_node) / 2) { alist.clear(); return(-1); } std::set<unsigned short> new_inst; std::set_difference(T[t].bag.begin(), T[t].bag.end(), T[*c].bag.begin(), T[*c].bag.end(), std::inserter(new_inst, new_inst.end())); unsigned short int i = *(new_inst.begin()); for(ai = alist.begin(); ai != alist.end(); ++ai) { ai->local.insert(i); ai->global[i] = false; alist2.push_back(*ai); ai->global[i] = true; alist2.push_back(*ai); } alist.clear(); return(0); }
void smallest_last_vertex_ordering(const VertexListGraph& G, Order order, Degree degree, Marker marker, BucketSorter& degree_buckets) { typedef typename boost::graph_traits<VertexListGraph> GraphTraits; typedef typename GraphTraits::vertex_descriptor Vertex; //typedef typename GraphTraits::size_type size_type; typedef std::size_t size_type; const size_type num = num_vertices(G); typename GraphTraits::vertex_iterator v, vend; for (boost::tie(v, vend) = vertices(G); v != vend; ++v) { put(marker, *v, num); put(degree, *v, out_degree(*v, G)); degree_buckets.push(*v); } size_type minimum_degree = 0; size_type current_order = num - 1; while ( 1 ) { typedef typename BucketSorter::stack MDStack; MDStack minimum_degree_stack = degree_buckets[minimum_degree]; while (minimum_degree_stack.empty()) minimum_degree_stack = degree_buckets[++minimum_degree]; Vertex node = minimum_degree_stack.top(); put(order, current_order, node); if ( current_order == 0 ) //find all vertices break; minimum_degree_stack.pop(); put(marker, node, 0); //node has been ordered. typename GraphTraits::adjacency_iterator v, vend; for (boost::tie(v,vend) = adjacent_vertices(node, G); v != vend; ++v) if ( get(marker,*v) > current_order ) { //*v is unordered vertex put(marker, *v, current_order); //mark the columns adjacent to node //delete *v from the bucket sorter degree_buckets.remove(*v); //It is possible minimum degree goes down //Here we keep tracking it. put(degree, *v, get(degree, *v) - 1); BOOST_USING_STD_MIN(); minimum_degree = min BOOST_PREVENT_MACRO_SUBSTITUTION(minimum_degree, get(degree, *v)); //reinsert *v in the bucket sorter with the new degree degree_buckets.push(*v); } current_order--; } //at this point, order[i] = v_i; }
bool is_adj_dispatch(Graph& g, Vertex a, Vertex b, bidirectional_tag) { typedef typename graph_traits<Graph>::edge_descriptor edge_descriptor; typename graph_traits<Graph>::adjacency_iterator vi, viend, adj_found; boost::tie(vi, viend) = adjacent_vertices(a, g); adj_found = std::find(vi, viend, b); if (adj_found == viend) return false; typename graph_traits<Graph>::out_edge_iterator oi, oiend, out_found; boost::tie(oi, oiend) = out_edges(a, g); out_found = std::find_if(oi, oiend, incident_to(b, g)); if (out_found == oiend) return false; typename graph_traits<Graph>::in_edge_iterator ii, iiend, in_found; boost::tie(ii, iiend) = in_edges(b, g); in_found = std::find_if(ii, iiend, incident_from(a, g)); if (in_found == iiend) return false; return true; }
int tree_dec_naddrswitch_introduce(T_t &T, typename boost::graph_traits<T_t>::vertex_descriptor t, const G_t &G) { typedef typename boost::graph_traits<T_t>::adjacency_iterator adjacency_iter_t; adjacency_iter_t c, c_end; assignment_list_naddr_t::iterator ai; boost::tie(c, c_end) = adjacent_vertices(t, T); assignment_list_naddr_t &alist2 = T[t].assignments; assignment_list_naddr_t &alist = T[*c].assignments; std::set<unsigned short> new_inst; std::set_difference(T[t].bag.begin(), T[t].bag.end(), T[*c].bag.begin(), T[*c].bag.end(), std::inserter(new_inst, new_inst.end())); unsigned short int i = *(new_inst.begin()); for(ai = alist.begin(); ai != alist.end(); ++ai) { ai->local.insert(i); naddrspaceset_t::const_iterator ni, ni_end; for(ni = G[i].possible_naddrspaces.begin(), ni_end = G[i].possible_naddrspaces.end(); ni != ni_end; ++ni) { ai->global[i] = *ni; alist2.push_back(*ai); } } alist.clear(); return((int)alist2.size() <= options.max_allocs_per_node ? 0 : -1); }
void constraints() { function_requires< GraphConcept<G> >(); function_requires< MultiPassInputIteratorConcept<adjacency_iterator> >(); p = adjacent_vertices(v, g); v = *p.first; const_constraints(g); }
void neighbors(const Graph& g, typename graph_traits<Graph>::vertex_descriptor u, OutputIterator result) { typename graph_traits<Graph>::adjacency_iterator ai, aend; for (tie(ai, aend) = adjacent_vertices(u, g); ai != aend; ++ai) *result++ = *ai; }
typename property_traits<ColorMap>::value_type sequential_vertex_coloring(const VertexListGraph& G, OrderPA order, ColorMap color) { typedef graph_traits<VertexListGraph> GraphTraits; typedef typename GraphTraits::vertex_descriptor Vertex; typedef typename property_traits<ColorMap>::value_type size_type; size_type max_color = 0; const size_type V = num_vertices(G); // We need to keep track of which colors are used by // adjacent vertices. We do this by marking the colors // that are used. The mark array contains the mark // for each color. The length of mark is the // number of vertices since the maximum possible number of colors // is the number of vertices. std::vector<size_type> mark(V, std::numeric_limits<size_type>::max BOOST_PREVENT_MACRO_SUBSTITUTION()); //Initialize colors typename GraphTraits::vertex_iterator v, vend; for (tie(v, vend) = vertices(G); v != vend; ++v) put(color, *v, V-1); //Determine the color for every vertex one by one for ( size_type i = 0; i < V; i++) { Vertex current = get(order,i); typename GraphTraits::adjacency_iterator v, vend; //Mark the colors of vertices adjacent to current. //i can be the value for marking since i increases successively for (tie(v,vend) = adjacent_vertices(current, G); v != vend; ++v) mark[get(color,*v)] = i; //Next step is to assign the smallest un-marked color //to the current vertex. size_type j = 0; //Scan through all useable colors, find the smallest possible //color that is not used by neighbors. Note that if mark[j] //is equal to i, color j is used by one of the current vertex's //neighbors. while ( j < max_color && mark[j] == i ) ++j; if ( j == max_color ) //All colors are used up. Add one more color ++max_color; //At this point, j is the smallest possible color put(color, current, j); //Save the color of vertex current } return max_color; }
/** Return vector of vertex neighbors. */ inline vector<int> get_vertex_neighbours(int v) { vector<int> nb; InteractionGraph::adjacency_iterator i, end; boost::tie(i, end) = adjacent_vertices(v, *this); for (; i != end; i++) { nb.push_back(*i); } return nb; }
void print_adjacent_vertex(Graph const &g) { for (auto vertex = vertices(g); vertex.first != vertex.second; ++vertex.first){ std::cout << *vertex.first << " is connected with "; for (auto neighbour = adjacent_vertices(*vertex.first, g); neighbour.first != neighbour.second; ++neighbour.first){ std::cout << *neighbour.first << " "; } std::cout<<std::endl; } }
typename graph_traits<VertexListGraph>::vertex_descriptor* get_uwv_tuple(const VertexListGraph& graph) { typedef typename graph_traits<VertexListGraph>::vertex_descriptor Vertex; typedef typename graph_traits<VertexListGraph>::vertex_iterator Iterator; typedef typename graph_traits<VertexListGraph>::adjacency_iterator AdjIterator; Vertex* uwv = new Vertex[UWV_SIZE]; Iterator f_v, f_vend; AdjIterator s_v, s_vend, t_v, t_vend; bool done = false; for(tie(f_v, f_vend) = vertices(graph); f_v != f_vend; ++f_v) { uwv[FIRST] = *f_v; for(tie(s_v, s_vend) = adjacent_vertices(uwv[FIRST], graph); s_v != s_vend; ++s_v) { uwv[SECOND] = *s_v; if(uwv[SECOND] == uwv[FIRST]) continue; for(tie(t_v, t_vend) = adjacent_vertices(uwv[SECOND], graph); t_v != t_vend; ++t_v) { uwv[THIRD] = *t_v; if(uwv[THIRD] == uwv[FIRST] || uwv[THIRD] == uwv[SECOND]) continue; if(are_uwv_ok(graph, uwv)) goto DONE; } } } throw uwv_not_found_exception(); DONE: #ifdef DEBUG std::cerr << "[1 a.] UWV tuple: [" << uwv[FIRST] << ", " << uwv[SECOND] << ", " << uwv[THIRD] << "]" << std::endl; #endif return uwv; }
void HFPlanner::computeHF(gridVertex vgoal) { //initialize potential to -1 and goal to 0 setPotential(vgoal, _goalPotential); //relax potential int numneighs = _wkSpace->getDimension()*2; graph_traits<gridGraph>::vertex_iterator vi, vend; graph_traits<gridGraph>::adjacency_iterator avi, avi_end; for(int i=0; i<_hfiter; i++) { for(tie(vi,vend)=vertices(*g); vi!=vend; ++vi) { if(getPotential(*vi) == _goalPotential || getPotential(*vi) == _obstaclePotential) continue; //cout << "cell "<<*vi<< " neighs = "; KthReal p=0; int count=0; int totalcount=0; for(tie(avi,avi_end)=adjacent_vertices(*vi, *g); avi!=avi_end; ++avi) { totalcount++; //cout<<*avi<<" "; if(_dirichlet != 0) { //dirichlet count++; p+=getPotential(*avi); } else { //neumann //cout<<"("<<getPotential(*avi)<<") "; if(getPotential(*avi) != _obstaclePotential) { count++; p+=getPotential(*avi); } } } //the borders of the cspace fixed to high for(;totalcount<numneighs;totalcount++) { count++; p+=_obstaclePotential; } //cout<<" POT= "<<p<<"/"<<count<<"= "<<p/count<<endl; if(count) setPotential(*vi, p/count); } } }
inline typename graph_traits<Graph>::degree_size_type num_paths_through_vertex(const Graph& g, Vertex v) { function_requires< AdjacencyGraphConcept<Graph> >(); typedef typename graph_traits<Graph>::directed_category Directed; typedef typename graph_traits<Graph>::adjacency_iterator AdjacencyIterator; // TODO: There should actually be a set of neighborhood functions // for things like this (num_neighbors() would be great). AdjacencyIterator i, end; boost::tie(i, end) = adjacent_vertices(v, g); std::size_t k = std::distance(i, end); return detail::possible_edges(g, k, Directed()); }
void create_condensation_graph(const Graph& g, const ComponentLists& components, ComponentNumberMap component_number, CondensationGraph& cg, EdgeMultiplicityMap edge_mult_map) { typedef typename graph_traits<Graph>::vertex_descriptor vertex; typedef typename graph_traits<Graph>::vertices_size_type size_type; typedef typename graph_traits<CondensationGraph>::vertex_descriptor cg_vertex; std::vector<cg_vertex> to_cg_vertex(components.size()); for (size_type s = 0; s < components.size(); ++s) to_cg_vertex[s] = add_vertex(cg); for (size_type si = 0; si < components.size(); ++si) { cg_vertex s = to_cg_vertex[si]; std::vector<cg_vertex> adj; for (size_type i = 0; i < components[si].size(); ++i) { vertex u = components[s][i]; typename graph_traits<Graph>::adjacency_iterator v, v_end; for (tie(v, v_end) = adjacent_vertices(u, g); v != v_end; ++v) { cg_vertex t = to_cg_vertex[component_number[*v]]; if (s != t) // Avoid loops in the condensation graph adj.push_back(t); } } std::sort(adj.begin(), adj.end()); if (! adj.empty()) { size_type i = 0; cg_vertex t = adj[i]; typename graph_traits<CondensationGraph>::edge_descriptor e; bool inserted; tie(e, inserted) = add_edge(s, t, cg); put(edge_mult_map, e, 1); ++i; while (i < adj.size()) { if (adj[i] == t) put(edge_mult_map, e, get(edge_mult_map, e) + 1); else { t = adj[i]; tie(e, inserted) = add_edge(s, t, cg); put(edge_mult_map, e, 1); } ++i; } } } }
int tree_dec_safety_nodes(T_t &T, typename boost::graph_traits<T_t>::vertex_descriptor t, const G_t &G) { typedef typename boost::graph_traits<T_t>::adjacency_iterator adjacency_iter_t; adjacency_iter_t c, c_end; typename boost::graph_traits<T_t>::vertex_descriptor c0, c1; boost::tie(c, c_end) = adjacent_vertices(t, T); switch (out_degree(t, T)) { case 0: tree_dec_lospre_leaf(T, t, G); break; case 1: c0 = *c; if(tree_dec_safety_nodes(T, c0, G) < 0) return(-1); if (T[c0].bag.size() < T[t].bag.size()) { if (tree_dec_lospre_introduce(T, t, G)) return(-1); } else tree_dec_safety_forget(T, t, G); break; case 2: c0 = *c++; c1 = *c; if (T[c0].weight < T[c1].weight) // Minimize memory consumption. std::swap (c0, c1); if(tree_dec_safety_nodes(T, c0, G) < 0) return(-1); if(tree_dec_safety_nodes(T, c1, G) < 0) { T[c0].assignments.clear(); return(-1); } tree_dec_lospre_join(T, t, G); break; default: std::cerr << "Not nice.\n"; break; } return(0); }
ostream &operator<<(ostream &out, const Graph &graph) { pair<Graph::InternalGraphType::vertex_iterator,Graph::InternalGraphType::vertex_iterator> uit; for (uit = vertices(graph.adjacencyList); uit.first != uit.second; uit.first++) { out<<*(uit.first)<<" : ["; pair<Graph::InternalGraphType::adjacency_iterator,Graph::InternalGraphType::adjacency_iterator> vit; for (vit = adjacent_vertices(*(uit.first), graph.adjacencyList); vit.first != vit.second; vit.first++) { out<<*(vit.first)<<", "; } out<<"]"<<endl; } }
void mig_cuts_paged::enumerate() { reference_timer t( &_enumeration_time ); /* topsort */ std::vector<unsigned> topsort( num_vertices( _mig ) ); boost::topological_sort( _mig, topsort.begin() ); /* loop */ _top_index = 0u; for ( auto n : topsort ) { if ( out_degree( n, _mig ) == 0u ) { /* constant */ if ( n == 0u ) { data.assign_empty( 0u, {0u, 0u} ); cones.assign_empty( 0u ); } /* PI */ else { data.assign_singleton( n, n, {0u, 1u} ); cones.assign_singleton( n, n ); } } else { data.append_begin( n ); cones.append_begin( n ); /* get children */ auto it = adjacent_vertices( n, _mig ).first; const auto n1 = *it++; const auto n2 = *it++; const auto n3 = *it++; enumerate_node_with_bitsets( n, n1, n2, n3 ); data.append_singleton( n, n, {0u, 1u} ); cones.append_singleton( n, n ); } _top_index++; } }
bool is_adj_dispatch(Graph& g, Vertex a, Vertex b, directed_tag) { typename graph_traits<Graph>::adjacency_iterator vi, viend, found; boost::tie(vi, viend) = adjacent_vertices(a, g); found = std::find(vi, viend, b); if ( found == viend ) return false; typename graph_traits<Graph>::out_edge_iterator oi, oiend, out_found; boost::tie(oi, oiend) = out_edges(a, g); out_found = std::find_if(oi, oiend, incident_to(b, g)); if (out_found == oiend) return false; return true; }
void tree_dec_lospre_join(T_t &T, typename boost::graph_traits<T_t>::vertex_descriptor t, const G_t &G) { typedef typename boost::graph_traits<T_t>::adjacency_iterator adjacency_iter_t; adjacency_iter_t c, c_end, c2, c3; boost::tie(c, c_end) = adjacent_vertices(t, T); c2 = c; ++c; c3 = c; assignment_list_lospre_t &alist1 = T[t].assignments; assignment_list_lospre_t &alist2 = T[*c2].assignments; assignment_list_lospre_t &alist3 = T[*c3].assignments; alist2.sort(); alist3.sort(); assignment_list_lospre_t::iterator ai2, ai3; for (ai2 = alist2.begin(), ai3 = alist3.begin(); ai2 != alist2.end() && ai3 != alist3.end();) { if (assignments_lospre_locally_same(*ai2, *ai3)) { ai2->s.get<0>() += ai3->s.get<0>(); ai2->s.get<1>() += ai3->s.get<1>(); for (size_t i = 0; i < ai2->global.size(); i++) ai2->global[i] = (ai2->global[i] || ai3->global[i]); alist1.push_back(*ai2); ++ai2; ++ai3; } else if (*ai2 < *ai3) { ++ai2; continue; } else if (*ai3 < *ai2) { ++ai3; continue; } } alist2.clear(); alist3.clear(); }
static void find_connected(TaskSystemType& task_system, const typename TaskSystemType::ClusterIdType& curr_clust_id, std::list<typename TaskSystemType::ClusterIdType>& connected_comps, int nr_of_connected) { typedef typename TaskSystemType::GraphType GraphType; typedef typename TaskSystemType::ClusterType ClusterType; typedef typename TaskSystemType::ClusterIdType ClusterIdType; typedef typename TaskSystemType::inv_adjacency_iterator inv_adjacency_iterator; typedef typename TaskSystemType::adjacency_iterator adjacency_iterator; GraphType& sys_graph = task_system.sys_graph; ClusterType& curr_clust = sys_graph[curr_clust_id]; if(!curr_clust.is_valid()) return; inv_adjacency_iterator parent_iter, parent_end; boost::tie(parent_iter, parent_end) = inv_adjacent_vertices(curr_clust_id, sys_graph); for ( ; parent_iter != parent_end; ++parent_iter) { const ClusterIdType& curr_parent_id = *parent_iter; // ClusterType& curr_parent = sys_graph[curr_parent_id]; find_connected(task_system, curr_parent_id, connected_comps, nr_of_connected); } if(curr_clust.group != 0) std::cout << "Already visited node " << curr_clust.index_list << std::endl; else { connected_comps.push_back(curr_clust_id); curr_clust.group = nr_of_connected; curr_clust.valid = false; } adjacency_iterator child_iter, child_end; boost::tie(child_iter, child_end) = adjacent_vertices(curr_clust_id, sys_graph); for ( ; child_iter != child_end; ++child_iter) { const ClusterIdType& curr_child_id = *child_iter; // ClusterType& curr_child = sys_graph[curr_child_id]; find_connected(task_system, curr_child_id, connected_comps, nr_of_connected); } }
static void apply(TaskSystemType& task_system) { typedef typename TaskSystemType::GraphType GraphType; typedef typename TaskSystemType::ClusterType ClusterType; typedef typename TaskSystemType::ClusterIdType ClusterIdType; typedef typename TaskSystemType::vertex_iterator vertex_iterator; typedef typename TaskSystemType::adjacency_iterator adjacency_iterator; GraphType& sys_graph = task_system.sys_graph; vertex_iterator vert_iter, vert_end; boost::tie(vert_iter, vert_end) = vertices(sys_graph); /*! skip the root node. */ ++vert_iter; for ( ; vert_iter != vert_end; ++vert_iter) { const ClusterIdType& curr_clust_id = *vert_iter; ClusterType& curr_clust = sys_graph[curr_clust_id]; if(!curr_clust.is_valid()) { continue; } adjacency_iterator child_iter, child_end, curr_child_iter; boost::tie(child_iter, child_end) = adjacent_vertices(curr_clust_id, sys_graph); while (child_iter != child_end) { /*! Increment before concat. Apparently erasing an edge invalidates the vertex iterators in VS. something is going on inside boost that I don't know yet. Or VS is just being VS as ususal. (the edge container is in fact a set, but that should matter only if we iterate over ages. well apparently not :) )*/ curr_child_iter = child_iter; ++child_iter; const ClusterIdType& curr_child_id = *curr_child_iter; // ClusterType& curr_child = sys_graph[curr_child_id]; int nr_parents = in_degree(curr_child_id, sys_graph); if(nr_parents == 1) { task_system.concat_with_parent(curr_clust_id, curr_child_id); } } } task_system.levels_valid = false; }
void treeClusterFusion(TCDGraph::vertex_descriptor p, TCDGraph::vertex_descriptor v, TCDGraph& cg) { TCDGraph::vertex_iterator vend; tie(tuples::ignore, vend) = vertices(cg); if (degree(v, cg) > 1 || p == *vend) //on est pas sur une feuille { TCDGraph::adjacency_iterator a, aend; tie(a, aend) = adjacent_vertices(v, cg); for (; a != aend; ++a) { if (*a != p) { treeClusterFusion(v, *a, cg); } } } if (p == *vend) return; set<int> varsinter; set_intersection(cg[v].vars.begin(), cg[v].vars.end(), cg[p].vars.begin(), cg[p].vars.end(), inserter(varsinter, varsinter.begin())); // int size_res = cg[v].vars.size() + cg[p].vars.size() - varsinter.size(); // si absorber à 90% merge whatever if ((float)varsinter.size() / (float)cg[v].vars.size() >= fabs(ToulBar2::boostingBTD) || (float)varsinter.size() / (float)cg[p].vars.size() >= fabs(ToulBar2::boostingBTD)) { fusionCluster(v, p, cg); // } else { // // si absorber à 70% merge whatever merged size <= 100 // if ((float)varsinter.size() / (float)cg[v].vars.size() >= 0.7 // || (float)varsinter.size() / (float)cg[p].vars.size() >= 0.7) { // if (size_res <= 100) // fusionCluster(v, p, cg); // } else { // // si absorber à 50% merge whatever merged size <= 50 // if ((float)varsinter.size() / (float)cg[v].vars.size() >= 0.5 // || (float)varsinter.size() / (float)cg[p].vars.size() >= 0.5) { // if (size_res <= 50) // fusionCluster(v, p, cg); // } // } } }
Foam::label Foam::cellShapeControlMesh::removePoints() { label nRemoved = 0; for ( CellSizeDelaunay::Finite_vertices_iterator vit = finite_vertices_begin(); vit != finite_vertices_end(); ++vit ) { std::list<Vertex_handle> verts; adjacent_vertices(vit, std::back_inserter(verts)); bool removePt = true; for ( std::list<Vertex_handle>::iterator aVit = verts.begin(); aVit != verts.end(); ++aVit ) { Vertex_handle avh = *aVit; scalar diff = mag(avh->targetCellSize() - vit->targetCellSize()) /max(vit->targetCellSize(), 1e-6); if (diff > 0.05) { removePt = false; } } if (removePt) { remove(vit); nRemoved++; } } return nRemoved; }
void Text::setGraph(LinguisticGraphVertex position,LinguisticGraph* graph) { _currentVx=position; _tTokenGraph=graph; // go one step forward on the new path LinguisticGraphAdjacencyIt adjItr,adjItrEnd; boost::tie (adjItr,adjItrEnd) = adjacent_vertices(_currentVx,*_tTokenGraph); if (adjItr==adjItrEnd) { TOKENIZERLOGINIT; LERROR << "Tokenizer Text : no token forward !"; throw LinguisticProcessingException(); } _lastVx=*adjItr; if (++adjItr!=adjItrEnd) { TOKENIZERLOGINIT; LERROR << "Tokenizer Text : more than one next token !"; throw LinguisticProcessingException(); } //remove_edge(_currentVx,_lastVx,*_tTokenGraph); }
inline typename graph_traits<Graph>::degree_size_type num_triangles_on_vertex(const Graph& g, Vertex v) { function_requires< IncidenceGraphConcept<Graph> >(); function_requires< AdjacencyGraphConcept<Graph> >(); typedef typename graph_traits<Graph>::degree_size_type Degree; typedef typename graph_traits<Graph>::directed_category Directed; typedef typename graph_traits<Graph>::adjacency_iterator AdjacencyIterator; // TODO: I might be able to reduce the requirement from adjacency graph // to incidence graph by using out edges. Degree count(0); AdjacencyIterator i, j, end; for(boost::tie(i, end) = adjacent_vertices(v, g); i != end; ++i) { for(j = boost::next(i); j != end; ++j) { count += detail::count_edges(g, *i, *j, Directed()); } } return count; } /* namespace detail */
bool are_uwv_ok(const VertexListGraph& graph, Vertex uwv[]) { // Checking whether the FIRST and THIRD are not heighbors. typedef typename graph_traits<VertexListGraph>::adjacency_iterator AdjIterator; AdjIterator n_v, n_vend; for(tie(n_v, n_vend) = adjacent_vertices(uwv[FIRST], graph); n_v != n_vend; ++n_v) { if(uwv[THIRD] == *n_v) return false; } // Removing FIRST and THIRD, then checking whether graph remains connected. VertexListGraph temp_graph; copy_graph(graph, temp_graph); clear_vertex(uwv[FIRST], temp_graph); clear_vertex(uwv[THIRD], temp_graph); remove_vertex(uwv[FIRST], temp_graph); remove_vertex(uwv[THIRD], temp_graph); return is_graph_connected(temp_graph); }
Tree bfs_tree(Graph const & G) { typedef std::pair<int, int> edge; Tree T(num_vertices(G)); int parent, v = 0; std::queue<edge> Q; std::vector<bool> V(num_vertices(G)); Q.emplace(-1, v); V[v] = true; while(!Q.empty()) { std::tie(parent, v) = Q.front(); Q.pop(); for(auto w : range(adjacent_vertices(v, G))) { if(!V[w]) { V[w] = true; add_edge(v, w, T); Q.emplace(v, w); } } } return T; }
static void apply(TaskSystemType& task_system) { typedef typename TaskSystemType::GraphType GraphType; typedef typename TaskSystemType::ClusterIdType ClusterIdType; typedef typename TaskSystemType::adjacency_iterator adjacency_iterator; GraphType& sys_graph = task_system.sys_graph; const ClusterIdType& root_node_id = task_system.root_node_id; adjacency_iterator child_iter, child_end; boost::tie(child_iter, child_end) = adjacent_vertices(root_node_id, sys_graph); for ( ; child_iter != child_end; ++child_iter) { const ClusterIdType& curr_child_id = *child_iter; concat_children_recursive(task_system, curr_child_id); } task_system.levels_valid = false; }