boost-graph

Need to find sub graphs from one big graph using boost::graph

浪尽此生 提交于 2020-01-03 05:13:11
问题 PH -> PH1 PH -> PH2 PH1 -> N1 PH1 -> N2 PH2 -> N3 PH2 -> N4 required output as : sub graph 1 : PH1 -> N1 PH1 -> N2 sub graph 2 : PH2 -> N3 PH2 -> N3 回答1: This is almost trivial using connected_components . The complicating thing is to ignore the PH node. You didn't say whether this node is given or should be detected. I have written some code to try to detect it. Let's Start #include <boost/graph/adjacency_list.hpp> using Graph = boost::adjacency_list<boost::vecS, boost::vecS, boost:

Saving no-parallel edge graph to a graphml file using boost

佐手、 提交于 2020-01-03 03:30:09
问题 Following code save a graph into a graphml file. It works!. But when I replace typedef adjacency_list< vecS, vecS, directedS, with typedef adjacency_list< setS, setS, directedS, so that no duplicate vertex or edge is inserted into the graph, it complains. #include <boost/graph/graphml.hpp> using namespace std; typedef struct { string name; string label; } vertex_type_t; int main(int,char*[]) { using namespace boost; typedef adjacency_list< vecS, vecS, directedS, vertex_type_t > graph_t; graph

Boost Graph Library Polymorphic Bundled Properties

最后都变了- 提交于 2020-01-02 07:43:51
问题 So I'm using a boost graph of the following type: typedef boost::adjacency_list<boost::listS, boost::vecS, boost:directedS, VertexT, EdgeT> GraphT VertexT and EdgeT are both classes to keep many of the properties I need. These are bundled properties. I'm not sure if some of the ways I want to use bgl are possible so if you are familiar with them help would be much appreciated. VertexT and EdgeT are suppose to be polymorphic base classes. My understanding is bgl is not meant to use for

Extract the adjacency matrix from a BGL graph

£可爱£侵袭症+ 提交于 2020-01-02 03:51:05
问题 Using the Boost Graph Library I am looking for a way to extract the adjacency matrix from an underlying graph represented by either boost::adjacency_list or boost::adjacency_matrix . I'd like to use this matrix in conjunction with boost::numeric::ublas to solve a system of simultaneous linear equations. Here is a minimal example to get you going: #include <boost/graph/adjacency_list.hpp> #include <boost/graph/adjacency_matrix.hpp> using namespace boost; typedef boost::adjacency_list< listS,

Is it possible to have several edge weight property maps for one graph?

你离开我真会死。 提交于 2019-12-29 08:15:25
问题 How would I create a graph, such that the property map (weight of edges) is different in each property map? Is it possible to create such a property map? Like an array of property maps? I have not seen anyone on the Internet using it, could I have an example? Graph g(10); // graph with 10 nodes cin>>a>>b>>weight1>>weight2>>weight3>>weight4; and put each weight in a property map. 回答1: You can compose a property map in various ways. The simplest approach would seem something like: Using C++11

BGL indexing a vertex by keys

我是研究僧i 提交于 2019-12-28 07:03:27
问题 My requirement is to have a graph structure where each vertex is uniquely identified by a boost::uuids::uuid . All vertices have a color property by which vertices of similar category will be grouped. I am not working on a static map, vertices and edges will be created and removed dynamically. typedef boost::adjacency_list< boost::listS, boost::listS, boost::bidirectionalS, boost::property<boost::vertex_index_t, boost::uuids::uuid, boost::property<boost::vertex_color_t, resource_color, boost:

To initialize a filtered_graph object in constructor after graph is defined in BOOST GRAPH

泄露秘密 提交于 2019-12-25 07:01:30
问题 I have a query in initializing filtered_graph in boost. here is my code, // predicate template <typename TGraph> struct edge_predicate { bool operator()(const typename boost::graph_traits<TGraph>::edge_descriptor& v) const { return true //testing purpose } }; // class class A{ typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::undirectedS, Node_Info, Edge_Info > Graph_t; typedef boost::filtered_graph < Graph_t , edge_predicate > FilteredGraphType_t; // members Graph G;

Boost Graph Library: Error while compiling with make_reverse_graph

一曲冷凌霜 提交于 2019-12-25 03:14:34
问题 I get a lot of errors when compiling while using the function make_reverse_graph of the Boost Graph Library. 回答1: Be sure that your graph is defined as boost::bidirectionalS . This means that there is for each vertex a list of its in-edges, which makes the reversion of the graph much more efficient. 来源: https://stackoverflow.com/questions/31020538/boost-graph-library-error-while-compiling-with-make-reverse-graph

Boost graph and spirit [duplicate]

白昼怎懂夜的黑 提交于 2019-12-24 19:27:13
问题 This question already has an answer here : Using boost graph library: how to create a graph by reading edge lists from file (1 answer) Closed 2 years ago . Can Someone Please explain this Last line? I need to eventually determine if two vertexes are connected. include <boost/fusion/adapted/std_pair.hpp> include <boost/spirit/include/qi.hpp> include <boost/graph/edge_list.hpp> include <fstream> typedef std::pair<int,int> Edge; typedef std::vector<Edge> EdgeList; typedef boost::edge_list

How do you add edges to boost::adjacency_matrix with property bundles?

蓝咒 提交于 2019-12-24 16:15:15
问题 I was trying to add edges in a boost::adjacency_matrix graph w/ bundled vertex and edge properties. The code was as follows: // VD and ED are just trivial structs using Graph = boost::adjacency_matrix<boost::directedS, VD, ED>; using Vertex = boost::graph_traits<Graph>::vertex_descriptor; using Edge = boost::graph_traits<Graph>::edge_descriptor; const unsigned kNodesCount = 4; Graph g { kNodesCount }; // create two nodes auto one = boost::add_vertex(g); auto two = boost::add_vertex(g); // add