boost-graph

dijkstra's algorithm not computing the predecessors of the vertices in my boost graph

夙愿已清 提交于 2019-12-11 03:51:38
问题 I am trying to write a program which uses the boost graph library to construct a graph from a text file and then perform certain algorithms of the user's choice on it. My code runs fine, but once boost::dijkstra_shortest_paths() or boost::prim_minimum_spanning_tree() finishes executing, the predecessor property for each vertex is set to that self-same vertex! It's like the algorithm runs without doing its job. I am rather unsure why this is happening, and was wondering if someone could shine

C++ graph with removable nodes, accessible properties and reliable IDs

。_饼干妹妹 提交于 2019-12-11 03:29:56
问题 I'm trying to migrate from a proprietary graph library to an Open Source one. EDIT: since so few people seem to know how Boost Graph actually works, if you can provide a solution using the LEMON Graph Library, that's fine too. Currently, my vertices have type Graph_Vertex* and can have an associated void* pointer to store related information. A similar logic is used with respect to edges, which are of type Graph_Edge* . I use the void* pointer to store my own structure Node_State , which is

Boost Graph : Test if two vertices are adjacent

只谈情不闲聊 提交于 2019-12-11 02:15:51
问题 I'm new in using C++ boost library in particularly the boost graph library which a needed to try coding some algorithms where i commonly check the adjacency of two vertices and dealing with other graph concepts like computing graph invariants. What i know is that we can iterate through adjacent vertices with the function : adjacent_vertices(u, g) but i'm searching for an efficient way to test if two vertices u, v are adjacent or not without doing linear search 回答1: The AdjacencyMatrix concept

Minimum Spanning Tree with Boost

社会主义新天地 提交于 2019-12-11 02:01:45
问题 I have the following code that generates an undirected graph: // --- Header File --- class Node { ... }; struct Edge { float weight; }; typedef adjacency_list<vecS, vecS, undirectedS, Node, Edge> Grafo; class MST { public: MST(std::vector<Node> nodes); Grafo g; vector<edge_t> build(); }; // --- cpp File --- MST::MST(std::vector<Node> nodes) { // build the graph by setting vertices and edges... } vector<edge_t> MST::build() { vector<edge_t> mst; kruskal_minimum_spanning_tree(g, std::back

Boost filtered graph with blacklisted edges

不打扰是莪最后的温柔 提交于 2019-12-10 23:19:33
问题 I want to run Dijkstra on a graph with blacklisted edges, i.e., I want to compute shortest paths that do not use those links. For the moment, I first define the filter: typedef std::pair<int, int> Edge; typedef boost::adjacency_list<boost::listS, boost::vecS, boost::directedS, boost::no_property, boost::property<boost::edge_weight_t, int> > graph_t; struct BlackListEdgeConstraint { private: std::set blackList; graph_t* g; public: BlackListEdgeConstraint():blackList(std::set<Edge>() ),g(NULL){

how is boost::property_map implemented in boost and how to change it

↘锁芯ラ 提交于 2019-12-10 19:28:38
问题 I was wondering how the property maps are implemented in a boost Graph. For example, I have vertex and edge properties defined like this: //vertex property:--> struct NodeInfo { int a , b , c; }; //actual bundled property struct NodeInfoPropertyTag { // tag and kind (as in boost documentation) typedef boost::vertex_property_tag kind; static std::size_t const num; }; std::size_t const NodeInfoPropertyTag::num = (std::size_t) &NodeInfoPropertyTag::num; //typedef the Vertex Property typedef

Visitor class holding large shared state: best way to implement reference semantics?

依然范特西╮ 提交于 2019-12-10 16:15:31
问题 This question is loosely based on the Boost.Graph library (BGL) that uses a Visitor-like pattern to customize recursive (search) algorithms. The BGL passes visitor objects by value (in analogy with the STL function objects) and the documentation states Since the visitor parameter is passed by value, if your visitor contains state then any changes to the state during the algorithm will be made to a copy of the visitor object, not the visitor object passed in. Therefore you may want the visitor

Why can't I use boost graph write_graphviz with OutEdgeList=listS and VertexList=listS

偶尔善良 提交于 2019-12-10 14:33:43
问题 Why can't I compile the following simple app. If I changes listS to vecS every thing works just fine. (I'am using boost 1.46.1 and gcc 4.4.5) #include <iostream> #include <boost/graph/adjacency_list.hpp> #include <boost/graph/graphviz.hpp> int main(int argc, const char *argv[]) { boost::adjacency_list< boost::listS, boost::listS, boost::bidirectionalS > g; boost::write_graphviz(std::cout, g); return 0; } 回答1: write_graphviz needs the vertex_id property to display vertex identifier labels. An

find multiple edges given 2 vertices in BOOST graph

大城市里の小女人 提交于 2019-12-10 14:33:39
问题 I am using Boost Graph library for some project and i want to find number of times an edge is repeated in a graph. for example, typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::undirectedS, Node_Info, Edge_Info > Graph_t; //node_info and Edge_info are external node and edge properties (structures) suppose if i have two nodes, node1 and node2 and there is an edge between them (node1, node2). edge property for each edge contains a timestamp start, end.. and there can be many such

Boost Graph Library: Bundled Properties and iterating across edges

梦想的初衷 提交于 2019-12-10 13:53:49
问题 Just trying to get my head around the Boost Graph Library and I have a few questions. I'm writing some code which is a wrapper class around a BGL graph. The idea is that I can manipulate the graph however I want, then call a wrapper method to output the graph in GEXF (XML) format. My code is something like this: struct Vertex { std::string label; ... }; struct Edge { std::string label; double weight; ... }; typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::directedS, Vertex, Edge