boost-graph

C++ Boost Graph Library: outputting custom vertex properties

别说谁变了你拦得住时间么 提交于 2019-12-04 14:49:38
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 in method typedef adjacency_list<setS, vecS, bidirectionalS, vertex_info_type, IkGraph_EdgeProperty>

How to use a BGL directed graph as an undirected one (for use in layout algorithm)?

时光毁灭记忆、已成空白 提交于 2019-12-04 13:23:00
I am working on a directed graph (actually a bidirectional one) with Boost.Graph. I'd like to use the layout algorithms that exist (either Kamada-Kawai or Fruchterman-Reingold) but they only accept undirected graphs as parameters. What is the simplest way to use these layout algorithms ? More generally, what's the right way to lure an algorithm into thinking that a directed graph is actually undirected ? Thanks, Benoît Are you sure that Fruchterman-Reingold algorithm only accepts undirected graphs? I tried to run the little example from the Boost documentation using a bidirectional graph

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

六月ゝ 毕业季﹏ 提交于 2019-12-04 13:20:50
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; typedef boost::graph_traits<Map>::edge_descriptor edge_descriptor; //lane.hpp #include "graphdefinitions

BGL Adding an edge with multiple properties

与世无争的帅哥 提交于 2019-12-04 09:16:22
I want to have all edges have to properties, weight and capacity. I found that BGL has these both already defined. So I define Edge and Vertex properties for the Graph typedef property<vertex_name_t, string> VertexProperty; typedef property<edge_weight_t, int, property<edge_capacity_t, int> > EdgeProperty; typedef adjacency_list<listS,vecS, undirectedS, VertexProperty, EdgeProperty > Graph; Here is where I am trying to add the edges to the graph: 172: EdgeProperty prop = (weight, capacity); 173: add_edge(vertex1,vertex2, prop, g); If I had just 1 property I know it would be prop = 5; However,

Algorithm for the Planarization of a non-planar Graph

房东的猫 提交于 2019-12-04 09:01:26
Is there a popular algorithm for the planarization of a non-planar graph. I'm currently planning to implement a Orthogonal Planar Layout algorithm for undirected graphs in Boost ( Boost Graph Library ). BGL has an implementation to check the planarity of an undirected graph ( Boyer-Myrvold Planarity Testing ) and I plan to use the planar embedding returned by this method to do an orthogonal layout. But I'm not sure what should be done if the input graph is non-planar. Should I do something with the Kuratowski sub-graph returned in such a scenario to make the graph planar. A Google Search on

copy a graph (adjacency_list) to another one

风格不统一 提交于 2019-12-04 08:23:17
How can I copy a graph of type adjacency_list to another one graph of type adjacency_list ? typedef adjacency_list<setS, setS, undirectedS, NodeDataStruct, EdgeDataStruct> MyGraph; MyGraph g1, g2; // processing g1: adding vertices and edges ... // processing g2: adding some vertices and edges ... g1.clear(); g1 = g2 // this gives an execution error (exception) g1 = MyGraph(g2); // this also gives an execution error g2.clear(); Andrew Durward Have you tried copy_graph ? Hard to know what the problem is without seeing the errors but if I had to guess, I'd first make sure you're providing a

How do I define a custom distance in Boost Dijkstra?

跟風遠走 提交于 2019-12-04 05:38:11
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 function must match the value type of the DistanceMap property map and the second argument type must

Adding custom properties to vertex of a grid in Boost Graph Library

三世轮回 提交于 2019-12-04 04:33:56
问题 I am using Boost Graph Library for map management in my robotics project. I intend to use Boost Grid and I am finding the Boost Graph documentation really hard to understand so I need a little help. This is the way I have created the grid, and printing it : struct sampleVertex { int row; int col; bool occupied; }; boost::array<std::size_t, 2> lengths = { { 3, 2 } }; boost::grid_graph<2> gridD(lengths); boost::write_graphviz(fout, gridD); Now, I want to add custom properties to the vertices,

boost graph library directed multigraph edge_range bug

两盒软妹~` 提交于 2019-12-04 04:01:02
问题 I have a directed multigraph with vertices A..C and edges E1..E4 A ---E1--> B A ---E2--> B A ---E3--> B B ---E4--> C I wanted to iterate over the edges that connect A and B. In BGL, I expressed this as: #include <boost/graph/adjacency_list.hpp> struct Vertex { std::string code; }; struct Edge { double distance; std::string code; }; int main() { using namespace boost; typedef adjacency_list<listS, vecS, directedS, Vertex, Edge> Graph; Graph g; auto a= add_vertex(Vertex{ "A" }, g); auto b= add

Adding a vertex_index to listS graph on the fly for betweenness centrality

时光总嘲笑我的痴心妄想 提交于 2019-12-04 02:52:43
问题 Update : The issue may be in the betweenness code. If I comment out the call to brandes_betweenness_centrality the code will compile. the problem may not be the index set up as previously thought. I'll award bounty if you can come up with an alternative call to brandes_betweenness_centrality that will allow keeping the index external. I'm trying to convert some of my old vecS code to work with listS, specifically the brandes_betweenness_centrality algorithm. I'm trying to keep the Vertex and