boost-graph

c++ boost::graph get parent vertices from directed graph

不羁岁月 提交于 2019-12-07 21:01:47
问题 I have a directed graph (implemented via an adjacency_graph from the boost::graph library) and I'm trying to find the parent vertices of a certain vertex. In the past (via pygraph) I have simply reversed the digraph, then done a neighbours search, but it appears that reversing the graph with boost::reverse_graph turns my digraph into a bidirectional graph, and therefore I can't use the adjacent_vertices method anymore. Is there a better way to get the parent vertices? Thanks. Here's my

Boost graphviz custom vertex labels

久未见 提交于 2019-12-07 18:28:27
问题 Currently I have the following code for a project that represents some probability trees and uses custom structs for the vertex and edge types: #include <boost/graph/adjacency_list.hpp> #include <boost/graph/graphviz.hpp> struct Vertex{ std::string name; size_t times_visited; float value; bool terminal_node; bool root_node; }; struct Edge{ float probability; }; //Some typedefs for simplicity typedef boost::adjacency_list<boost::listS, boost::vecS, boost::directedS, Vertex, Edge> directed

Boost graph designing without adjacency list or adjacency matrix [closed]

老子叫甜甜 提交于 2019-12-07 16:57:39
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 5 years ago . Is there any way to create a graph structure without using adjacency list or adjacency matrix in C++ boost? (a vertex structure using pointers which points to its neighbour vertices) 回答1: It is possible, of course, provided your data has "traits" of a theoretical graph, meaning you essentially deal with

Boost graph with existing data structure or using it as the data structure

那年仲夏 提交于 2019-12-07 15:11:49
问题 I'm writing an application that's parsing a data structure with something like struct Block { std::string foo; /* ... even more local data ... */ }; std::map<std::string, Block> blockContainer; // Each Block will have a name here struct Signal { // the direct links to the Blocks, no redundant storage of the name so that an // simple renaming of a Block would be possible std::map<std::string, Block>::iterator from; std::map<std::string, Block>::iterator to; std::string bar; /* ... even more

Boost BGL Transitive reduction

橙三吉。 提交于 2019-12-06 16:56:56
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 be a map from vertices to integers. I try many kind of map but without success. Some ideas ? Thx sehe As

Shortest path graph algorithm help Boost

时间秒杀一切 提交于 2019-12-06 14:27:44
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,0), (2,0), (3,0) or (4,0). The goal vertex is always in the right column (column with index 6) and

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

三世轮回 提交于 2019-12-06 07:30:17
问题 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 回答1: Are you sure that Fruchterman-Reingold algorithm only accepts

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

我怕爱的太早我们不能终老 提交于 2019-12-06 04:29:19
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 yet. What I understood so far about the adjacency_list parameters : adjacency_list<OutEdgeListS,

BGL Adding an edge with multiple properties

∥☆過路亽.° 提交于 2019-12-06 03:33:05
问题 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);

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

与世无争的帅哥 提交于 2019-12-06 02:26:54
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 be less prone to trigger a memory error in case the graph changes. Is it true? Stability of iterators