boost-graph

how to read graph-domain attributes with boost::read_graphml?

人走茶凉 提交于 2020-01-07 00:54:50
问题 Probably a silly question, but I can't find any answer online. My application reads a topology from a custom file and builds a boost::graph out of it. I'm in the process of moving to a more standard graphml representation. I can read/write node properties using a vertex_descriptor as a key, and similarly I can use an edge_descriptor for edge attributes, but what about graph attributes? To which key type will they be associated when they are read in the graphml file? To explain my doubt, here

Boost:: Dijkstra Shortest Path, how to get vertice index from path iterator?

强颜欢笑 提交于 2020-01-06 01:51:31
问题 Before you start reading, to help you understand my issue, I am telling that I have copied the code from this link: Dijkstra Shortest Path with VertexList = ListS in boost graph So.. I am rewriting my program code to use boost, but now when 99% is ready I am stuck with my GPS (for a game). I have a list of nodes, which I added in a way which fortunately was easy to convert to the boost method. The thing I needed to do was just create a vertice variable like this: Vertex Vx[MAX_NODES]; I

BGL: Using bundled properties to store vertex descriptor of another vertex

懵懂的女人 提交于 2020-01-05 11:15:10
问题 I am trying to create a tree graph using boost::adjacency list and bundled properties to store the parent for every vertex, I want to store vertex descriptors in a way that they wont invalidate in case I remove a vertex, so I use boost::listS , the code should look something like this // custom vertex for tree graphs struct tree_vertex_info{ // descriptor of parent vertex boost::graph_traits<Tree>::vertex_descriptor parent_in_tree; }; // the tree graph type typedef boost::adjacency_list<boost

Using vertex_name when reading a GraphML file with Boost Graph

。_饼干妹妹 提交于 2020-01-05 10:16:11
问题 I am trying to load a simple GraphML file such that each vertex has a vertex name as stored in the GraphML. I can change the GraphML, the important thing is that I have access to the vertex_name from code afterwards. Here's the most minimal example that I could extract that still shows the problem: #include <iostream> #include <string> #include <fstream> #include <boost/graph/adjacency_list.hpp> #include <boost/graph/graphml.hpp> int main() { using namespace boost; typedef adjacency_list<vecS

Boost graph: dijkstra_shortest_paths: cannot form a reference to 'void'

霸气de小男生 提交于 2020-01-05 08:10:14
问题 I have these graph classes: struct Vertex { octomap::point3d coord; OcTreeNode *node; }; typedef boost::adjacency_list<boost::listS, boost::vecS, boost::undirectedS, Vertex> Graph; typedef boost::graph_traits<Graph>::vertex_descriptor VertexDesc; typedef boost::graph_traits<Graph>::edge_descriptor EdgeDesc; struct GraphContainer { std::map<OcTreeNode*, VertexDesc> revmap; Graph graph; }; and I'm trying to use dijkstra to compute shortest paths: GraphContainer *gc = ...; VertexDesc vGoal = ...

External property map tied to std::vector in boost graph library

微笑、不失礼 提交于 2020-01-04 14:16:28
问题 I am currently trying to define external properties of a boost graph. I use some bundled properties as internal ones: struct VertexProperties { int demand; }; struct EdgeProperties { uint capacity; int cost; }; typedef adjacency_list <vecS, vecS, bidirectionalS, VertexProperties, EdgeProperties> Graph; However, during the algorithm I need some external properties, that is I want to be able to map edges/vertices of my graph to elements stored in a std::vector in such a way that I can access

Pointers to class members when iterating with boost::fusion

点点圈 提交于 2020-01-04 06:17:50
问题 I have a boost::graph that uses bundled properties like the following: struct Vertex { std::string id; }; If I want to use this information in boost::dynamic_properties (e.g. for printing in graphml-format), I can use something like that: template<typename T> std::string myPrettyPrinter(const T& t); int main() { using namespace boost; MyGraph g; dynamic_properties dp; dp.property("id", make_transform_value_property_map( & myPrettyPrinter<std::string>, get(&Vertex::id, g) ) ); } Since the

In the Boost Graph Library, why does adding an edge invalidate Edge iterators (and other questions)?

冷暖自知 提交于 2020-01-04 05:17:19
问题 A few questions about the chart in the BGL documentation labeled "Summary of Descriptor and Iterator Invalidation": Why does adding an edge invalidate the edge and adjacency iterators; why isn't every column of the add_edge() row "OK"? Wouldn't the in/out edge lists simply be appended? Why does removing an edge only invalidate an edge iterator if the graph is directed; why is the second to last column in the second row not simply "EL=vecS"? In the undirected graph case wouldn't removing an

Perform connected_components with Boost adjacency_list where VertexList=listS

跟風遠走 提交于 2020-01-04 03:13:24
问题 I use Boost Graph Library in a project and it is declared as: typedef adjacency_list <listS, listS, undirectedS, TrackInformation, LinkInformation> TracksConnectionGraph; Things are going fine until I have to call connected_components on my graph. typedef std::map<TracksConnectionGraph::vertex_descriptor, TracksConnectionGraph::vertices_size_type> component_type; component_type component; boost::associative_property_map< component_type > component_map(component); int num_components =

Iterating through edge weights of a const boost::graph

旧巷老猫 提交于 2020-01-03 15:19:32
问题 I need to iterate through the edges of a graph and examine the weight of each edge. I'm not modifying the edges, therefore my function takes a const-reference to a graph. However, the only way I know to get the edge weights is to get access to the property map, which seems to violate const-ness. void printEdgeWeights(const Graph& graph) { typedef Graph::edge_iterator EdgeIterator; std::pair<EdgeIterator, EdgeIterator> edges = boost::edges(graph); typedef boost::property_map<Graph, boost::edge