boost-graph

Boost Graph Library: possible to combine Bundled Properties with Interior Properties?

为君一笑 提交于 2019-12-24 15:28:53
问题 I'm using this typedef for my BGL graph type, Graph , using struct VertexProperty as a bundled vertex property: struct VertexProperty { BeamType beam; size_t index; }; typedef typename boost::adjacency_list< boost::listS, boost::listS, boost::bidirectionalS, VertexProperty > Graph; Before a recent change in my project, I'd been using the VertexProperty::index to construct a two_bit_color_map for use with depth_first_search : auto colorMap = boost::make_two_bit_color_map( boost::num_vertices

boost dijkstra_shortest_paths: can't extract (or find?) the path (path contains a cycle)

烂漫一生 提交于 2019-12-24 09:17:20
问题 I have the following undirected graph classes: typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::undirectedS, Vertex, Edge> Graph; typedef boost::graph_traits<Graph>::vertex_descriptor VertexDesc; typedef boost::graph_traits<Graph>::edge_descriptor EdgeDesc; typedef boost::graph_traits<Graph>::vertex_iterator VertexIter; typedef boost::graph_traits<Graph>::edge_iterator EdgeIter; struct GraphContainer { std::map<OcTreeNode*, VertexDesc> revmap; Graph graph; }; after populating

Reason for not allowing random access to the vector of edges in adjacency lists

社会主义新天地 提交于 2019-12-24 07:16:33
问题 Why is edge_iterator not an integer_iterator like vertex_iterator? I am using undirected adjacency list with vectors to store both vertices and edges. 回答1: Adjacency lists store a list of adjacencies. That is, per vertex, it stores a list of adjacent vertices. That means that vertices can be stored in a single container, but each vertex contains its own (separate) container of adjacencies ("other vertex references"). This should explain: there is no such thing as "the edge container", making

boost BGL write_graphviz make_label_writer with fillcolor node

假如想象 提交于 2019-12-24 03:00:49
问题 I want to fill color some node with custom color, so is there custom property setting in vertex attribute from graph or re-implementing custom functor make_edges_writer? #include <boost/config.hpp> #include <iostream> #include <vector> #include <fstream> #include <string> #include <boost/graph/adjacency_list.hpp> #include <boost/graph/graph_utility.hpp> #include <boost/graph/graphviz.hpp> using namespace boost; struct Edges { int id; std::string name; }; struct vert{ std::string name; }; enum

C++ Boost graph library: Building a vector of vertices visited in an undirected graph search?

穿精又带淫゛_ 提交于 2019-12-24 02:12:52
问题 From what I can gather of how to use BGL in order to invoke a DFS of a graph from a known root node I need to do something along the lines of class MyVisitor : public boost::default_dfs_visitor { public: void discover_vertex(MyVertex v, const MyGraph& g) const { cerr << v << endl; return; } }; void bfsMethod(Graph g, int rootNodeId) { boost::undirected_dfs(g, vertex(rootNodeId,g), boost::visitor(vis)); } Now I am not sure how I alter this so that std::vector of vertexId's (or pointers) is

Find all reachable vertices in a Boost BGL graph using BFS

自闭症网瘾萝莉.ら 提交于 2019-12-24 01:58:15
问题 I have constructed a boost BGL graph: using vertex_t = std::variant<node_t, specialNode_t>; // structs using edge_t = std::variant<TerminalType>; // enum using Graph_t = boost::adjacency_list< boost::vecS, boost::vecS, boost::undirectedS, vertex_t, edge_t>; Graph_t myGraph; and I'm trying to find (collect) all vertices reachable from a certain starting point (vertex) sorted by their distance. That means I'd like to create a list of all vertices reachable from a certain starting vertex where

C++ and generic graph distance algorithm

牧云@^-^@ 提交于 2019-12-23 22:17:02
问题 My problem is the following. I am learning C++ by writing a graph library and want to make use of as much generic programming techniques as possible; hence, answering my question through "use BOOST" will not help me; in fact, I tried looking through BOOST's code for an answer to my question, but it was a humbling experience, since I can't even figure out where certain functions are defined; just way too high level of C++ for learning from it at my level. That said, my library is templated in

Writing boost dynamic properties to a file using Boost Graph Library

别来无恙 提交于 2019-12-23 20:26:00
问题 I have already asked a question here about using Boost Graph Library and writing graph into file. Due to change in my requirements, I need to write dynamic graph properties into a DOT file. After some look up, I managed to come up with some code but it does not work. Below is what I have done so far: Map class uses the Cell class as vertices and Cell class uses a separate CellProperty class for setting and getting all the Cell properties. And finally Map class where I build the graph and try

boost graph library: deterministic order of iteration of in_edges?

天涯浪子 提交于 2019-12-23 17:24:19
问题 TL;DR : I would very much like for the order of iteration of in_edges on my graph ( adjacency_list with edge_list of setS ) to be determinstic, but as far as I can tell, the order of iteration is determined by a comparison operator that is just pointer comparison---thus iteration order is determined by the vagaries of malloc . Help! For concreteness, my graph and related types are: struct VertexCargo { int Id; ... }; typedef adjacency_list<setS, vecS, bidirectionalS, property<vertex_info_t,

Stopping condition for Kamada-Kawai layout

眉间皱痕 提交于 2019-12-23 16:30:58
问题 I am using the following code to obtain the Kamada-Kawai layout: template <class PointMap> PointMap layout() const { PointMap res; boost::associative_property_map<PointMap> temp(res); minstd_rand gen; rectangle_topology<> rect_top(gen, 0, 0, 50, 50); random_graph_layout(g_, temp, rect_top); // random layout to show that // Kamada-Kawai isn't doing the job // circle_graph_layout(g_, temp, 10.0); // http://stackoverflow.com/q/33903879/2725810 // http://stackoverflow.com/a/8555715/2725810