boost-graph

How to get the OutEdgeList inside a BGL graph

时光怂恿深爱的人放手 提交于 2019-12-12 18:31:34
问题 I use a graph made with the boost graph library and want to access the OutEdgeList to get/set some internal informations (the reserved size of the vectors used to build the OutEdgeList). I extensively searched the docs but didn't find a function/member, which returns a reference or pointer to the OutEdgeList. My question is if there is a way to get the graphs OutEdgeList or if boost 'protects' the user from not messing directly with its internals. In another question I found an example where

BGL: How do I store edge_descriptors and vertex_descriptors efficiently?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-12 18:01:22
问题 So after my circular dependency problem with the BGL was solved I've come to another obstacle. I'm currently using an adjacency-list to model my graph. Bundled properties for both nodes and edges are applied to store some information in the graph. So I have something like this: class Node { int x, int y // position }; class Edge { float length; }; boost::adjacency_list<boost::listS, boost::listS, boost::directedS, Node, Edge> The problem arises when I want to store shortcuts to specific nodes

Boost DFS back_edge

懵懂的女人 提交于 2019-12-12 15:26:03
问题 I'm trying to find all edges that are part of any cycle in a undirected Graph. Using Boost's depth_first_search and my understanding of back edges, I don't see why the back_edge method is called for both edges in the sample Graph which doesn't contain any cycles. #include <boost/config.hpp> #include <boost/graph/adjacency_list.hpp> #include <boost/graph/depth_first_search.hpp> using namespace std; using namespace boost; typedef adjacency_list<vecS, vecS, undirectedS, no_property, property

Random access of Vertices using Boost::graph

℡╲_俬逩灬. 提交于 2019-12-12 15:23:28
问题 I am trying to iterate over my boost graph's vertices in parallel using OpenMP. This seems to require having an iterator that supports random access of elements (e.g., itr[i] gets the i th element). However, the iterator that vertices(g) returns (a vertex_iterator ) does not seem to support this. Is there an efficient, clean way to accomplish this? Ideally, I just want a standard for loop such as this: for (int i = 0; i < num_vertices; i++) { vertex v = itr[i]; // Compute on vertex } which

Boost Graph Library: Prevent DFS from visiting unconnected nodes

空扰寡人 提交于 2019-12-12 14:43:17
问题 I have a bidirectional graph. Some of the vertices are unconnected. I use boost::depth_first_search to traverse the vertices. I also supply the starting source node. I see that the unconnected vertices are also processed after the connected nodes are done. How can I prevent visiting such nodes? In fact, how can I tell DFS to only visit those nodes reachable from the source node and don't visit anything else? I have the following code: /// Define vertex properties. struct NodeProperty {

Degree of Vertex Iterator in BGL

ぐ巨炮叔叔 提交于 2019-12-12 14:24:55
问题 I am endeavouring to remove all of the nodes from my graph (using the pattern defined here) which have no connecting edges. My (MWE) code thus far is as follows: //g++ -O3 question.cpp -o question.exe #include <iostream> #include <boost/graph/adjacency_list.hpp> #include <boost/graph/labeled_graph.hpp> #include <boost/graph/iteration_macros.hpp> typedef long long node_id_t; typedef boost::adjacency_list< boost::listS, // Store out-edges of each vertex in a std::list boost::listS, // Store

Graph with two types of nodes

允我心安 提交于 2019-12-12 09:54:31
问题 I'm writing a program using C++ and Boost Graph Library (BGL). I have two classes named Buildings and Contracts. I need to make a graph which represents connection relations between them all. So the graph should have two types of vertices (B and C), be oriented and include edges B->B, C->C and B->C. Is it possible? If yes, how to implement this? EDIT Actually, I tried to avoid connections between different type nodes, so I had two separate graphs. But it made my model far more complicated

Find all linesegments=edges within a certain distance to a point in a graph, how to combine boost-graph with boost-geometry?

谁都会走 提交于 2019-12-12 04:35:07
问题 I have a set of user paths (2 dim) in a game setup that are modelled as a set of lines (arcs) and waypoints = vertices. The whole set of paths can be seen as a graph where the edges are line segments that have additional properties like length, probability, etc. Now I have to identify the set of (straight) line segments = edges within a certain distance to the user's current position in order to find the user's position in the graph. How to implement this as simply as possible without

Boost Graph edges with indexes

情到浓时终转凉″ 提交于 2019-12-12 01:49:56
问题 I am trying to define a graph with undirected edges from a set of pair(int,int) edges (where each int represents a vertex index). Each such edge has an index of its own. The catch is that I want that the internal vertex index of the graph will be consistent with the original vertex indexes. I also like to be able to extract the original edge index from an edge descriptor. From http://www.boost.org/doc/libs/1_47_0/libs/graph/doc/using_property_maps.html ( Exterior Properties section) I

breadth_first_search on labeled_graph

三世轮回 提交于 2019-12-11 13:07:54
问题 How should breadth_first_search be called using labeled_graph assuming the following setup? - results in 2 errors: binary '[' : no operator found which takes a right-hand operand of type 'Vertex' (or there is no acceptable conversion) Error 2 left of '.id' must have class/struct/union #include<iostream> #include<boost/graph/adjacency_list.hpp> #include<boost/graph/breadth_first_search.hpp> #include <boost/graph/labeled_graph.hpp> using namespace boost; struct NodeInfo{int id;}; struct