boost-graph

Replace BGL iterate over vertexes with “pure” C++11 alternative?

帅比萌擦擦* 提交于 2019-12-10 12:39:50
问题 I want to replace the BGL iteration over vertexes or edges with pure C++11 equivalent. The BGL code (from: http://www.boost.org/doc/libs/1_52_0/libs/graph/doc/quick_tour.html) is: typename boost::graph_traits<Graph>::out_edge_iterator out_i, out_end; typename boost::graph_traits<Graph>::edge_descriptor e; for (std::tie(out_i, out_end) = out_edges(v, g); out_i != out_end; ++out_i) { e = *out_i; Vertex src = source(e, g), targ = target(e, g); std::cout << "(" << name[get(vertex_id, src)] << ","

Should I use iterators or descriptors to keep a reference on an edge or vertex?

北城余情 提交于 2019-12-10 10:13:30
问题 I am currently designing an application composed of both a Boost Graph (adjacency_list) and several classes referencing edges or vertices from this structure. My question is: what is the recommended way to maintain a reference to a node or a vertex? I guess that in the iterator case the object access is faster but the iterator can be invalidated by dynamic changes on the graph structure. On the opposite, a descriptor is an id which means that a search is necessary to retrieve the data but may

How do I stop the breadth-first search using Boost Graph Library when using a custom visitor?

纵饮孤独 提交于 2019-12-10 02:34:54
问题 Say I found the node that meets my criteria and I need to stop the search. 回答1: The solution is to throw an exception of your known type - then catch it on the calling side. From the FAQ: How do I perform an early exit from an algorithm such as BFS? Create a visitor that throws an exception when you want to cut off the search, then put your call to breadth_first_search inside of an appropriate try/catch block. This strikes many programmers as a misuse of exceptions, however, much thought was

How to solve Boost::BGL template<->class circular dependency?

一曲冷凌霜 提交于 2019-12-09 20:08:41
问题 I have a problem with using the adjacency-list of the Boost Graphics Library. It seems to be a circular dependency problem: I have a typedef T of a template which uses some class A. Additionally A stores a pointer to an object of type T. Now the compiler tells me, that T does not name a type. Here are excerptions of my more concrete files: //graphdefinitions.hpp #include "lane.hpp" #include "tie.hpp" typedef boost::adjacency_list<boost::listS, boost::listS, boost::directedS, Tie, Lane> Map;

C++ Boost Graph Library: outputting custom vertex properties

给你一囗甜甜゛ 提交于 2019-12-09 19:12:04
问题 I am struggling to get a custom property writer to work with BGL. struct IkGraph_VertexProperty { int id_ ; int type_ ; std::pair<int,int> gaussians_ ; // Type of Joint, Ids of Gaussians }; struct IkGraph_VertexPropertyTag { typedef edge_property_tag kind; static std::size_t const num; }; std::size_t const IkGraph_VertexPropertyTag::num = (std::size_t)&IkGraph_VertexPropertyTag::num; typedef property<IkGraph_VertexPropertyTag, IkGraph_VertexProperty> vertex_info_type; ...custom graph defined

How do I define a custom distance in Boost Dijkstra?

混江龙づ霸主 提交于 2019-12-09 17:48:28
问题 I'm currently looking at the documentation of Boost Dijkstra - http://www.boost.org/doc/libs/1_52_0/libs/graph/doc/dijkstra_shortest_paths.html; my objective is to modify the distance combining to get a "max" instead of a "plus" when computing my distances. The doc says this: IN: distance_combine(CombineFunction cmb) This function is used to combine distances to compute the distance of a path. The CombineFunction type must be a model of Binary Function. The first argument typ of the binary

Generating a Graph using Boost library by allowing user to select the number of vertex

谁都会走 提交于 2019-12-08 12:18:17
问题 I would like to generate a graph using boost library which would allow user to input the number of edges and vertex. What I basically want to do is, I would want the user to input the number of vertices and number each vertex. I would give the user a privilege to select a vertex as a master vertex using the numeral as a reference. I would like the user to specify in the console, number of edges from each vertex and the edges can be random. Is it possible to somehow implement this using BGL?

Boost BGL Transitive reduction

♀尐吖头ヾ 提交于 2019-12-08 05:34:20
问题 I try to use the transitive_reduction of boost, but I don't know how to use it. I have a graph defined with : typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::bidirectionalS, IQsNode*> Graph; typedef Graph::vertex_descriptor Vertex; I would like to call the method : Graph TC; boost::transitive_reduction(_fullGraph, TC,g_to_tr_map_stor,g_to_tc_map_stor); I don't know the type I must use for "g_to_tr_map_stor" and "g_to_tc_map_stor". According with information i readed , it must

Shortest path graph algorithm help Boost

三世轮回 提交于 2019-12-08 01:34:59
问题 I have a rectangular grid shaped DAG where the horizontal edges always point right and the vertical edges always point down. The edges have positive costs associated with them. Because of the rectangular format, the nodes are being referred to using zero-based row/column. Here's an example graph: Now, I want to perform a search. The starting vertex will always be in the left column (column with index 0) and in the upper half of the graph. This means I'll pick the start to be either (0,0), (1

What is needed to use BGL algorithms on existing data structures ( edges and vertices as vector<Object *>)?

荒凉一梦 提交于 2019-12-08 00:29:41
问题 I have custom data structures like this : vector<myVertex *> my_vertices; vector<myEdge *> my_edges; My class myEdge has source() and target() methods, returning myVertex*, so it should be quite ready as is, right? What external adaptation do I need to do to use a BGL graph with my containers? I am aware of the adaptor examples in the doc, yet some help would be much appreciated! I am interested is the sheer adjacency_list basic-graph type, not sure about the graph traversal concepts I need