boost-graph

how to write GraphViz subgraphs with boost::write_graphviz

穿精又带淫゛_ 提交于 2019-12-01 05:46:55
Is it possible to generate a DOT subgraph using ::boost::write_graphviz ? For instance, if I create a subgraph G0 in a graph G, can I get something like the following in the DOT output: graph G { subgraph G0 { ... } ... } I finally figured out both how subgraphs work and how to use boost::write_graphviz to actually print these. The first requirement is "semi-documented" in a comment in the boost library source code: requires graph_name property . The most surprising requirement however seemed to be that detail::write_graphviz_subgraph assumes the presence of vertex_attribute edge_attribute

On C++ Boost Graph Creation and the vertex_index Property.

*爱你&永不变心* 提交于 2019-12-01 05:34:35
问题 I am boost noob. I am wondering why compilation fails in the following code. I am creating a set of vertices, and trying to assign my own vertex indices and vertex names. (I am following this page: http://fireflyblue.blogspot.com/2008/01/boost-graph-library.html. ) I understand that vertS vertex lists in Boost does not need explicit vertex id creations, and I have also seen this very related question in Stackoverflow (how provide a vertex_index property for my graph) which discusses how to

Check if vertex already exists before an add_edge using Boost Graph [BGL]

夙愿已清 提交于 2019-12-01 05:15:24
问题 Is there a way to check if a vertex in a graph created using Boost already exists rather than looping through the vertices? And if it already exists, how can I add a new edge using its vertex descriptor? Example: Graph g; vertex v; v = add_vertex(1, g); vertex_name[v] = "root"; v = add_vertex(2, g); vertex_name[v] = "vert_2"; v = add_vertex(3, g); vertex_name[v] = "vert_3"; // This is not possible edge e1; if (vertex.find("root") == vertex.end()) { (boost::add_edge("root", "vert_2", g)).first

Make Boost Dijkstra algorithm stop when it reaches a destination node

喜欢而已 提交于 2019-12-01 03:51:16
问题 I'm using boost::graph and its Dijkstra implementation. When someone is using the Dijkstra algorithm, it may be to know the shortest path between 2 nodes in a graph. But as you need to check all nodes in the graph to find the shortest path, usually (like the boost algorithm) Dijkstra gives you back all the distances between one origin point, and all the other nodes of the graph. One easy improvement of this algorithm when you only want the path between 2 nodes is to stop it when the algorithm

How to efficiently shuffle edges in a graph

天大地大妈咪最大 提交于 2019-11-30 20:28:01
问题 I am writing a code to shuffle the edges of a graph according to the Configuration Model. In essence, two edges [(v1,v2) and (v3,v4)] are randomly chosen and swapped [yielding (v1,v3) and (v2,v4)] if no self-edge is created [v1 is not v3, and v2 is not v4]; no multi-edge is created [the edges (v1,v3) and (v2,v4) did not already existed]. I wrote the following code to achieve this // Instantiates an empty undirected graph. typedef boost::adjacency_list< boost::setS, boost::vecS, boost:

Boost.Graph how to merge two vertices/contract edge

时光怂恿深爱的人放手 提交于 2019-11-30 15:40:15
问题 How to merge two vertices/contract edge at Boost.Graph? I need to move edges from vertex A to vertex B, and delete vertex A - is there any built-in function? Or maybe there is something special for adjacency_list? If there is no such function - then why? I think it is common graph operation. EDIT : I do know that it is possible to do it manually, but there are some corner cases (like preserving edges properties), that why it is good candidate to be in library. I mostly interested to know if

Boost.Graph how to merge two vertices/contract edge

ⅰ亾dé卋堺 提交于 2019-11-30 15:35:54
How to merge two vertices/contract edge at Boost.Graph? I need to move edges from vertex A to vertex B, and delete vertex A - is there any built-in function? Or maybe there is something special for adjacency_list? If there is no such function - then why? I think it is common graph operation. EDIT : I do know that it is possible to do it manually, but there are some corner cases (like preserving edges properties), that why it is good candidate to be in library. I mostly interested to know if Boost.Graph have already that operation (maybe with some fancy name?). And if not - why such primitive

How to print a graph in graphviz with multiple properties displayed

半城伤御伤魂 提交于 2019-11-30 07:39:16
问题 My question is based off of: How to print a graph with a single property displayed I am using bundled properties: typedef struct vert{ std::string name; }; typedef struct edge{ int capacity; int weight; }; typedef adjacency_list<listS, vecS, undirectedS, vert, edge> Graph; Graph g; vector<int,int> ele; I have the following called in a loop that should create the edges: edge prop; prop.weight = 5; prop.capacity = 4; add_edge(ele.first,ele.second, prop, g); This segment is what prints the graph

Use a Graph Library/Node Network Library or Write My Own?

狂风中的少年 提交于 2019-11-29 22:26:13
I'm trying to decide between going with a pre-made graph/node network library or to roll my own. I'm implementing some graph search algorithms which might require some significant customization to the class structure of the node and/or edges. The reason I'm not sure what to do is that I'm unsure if customization of a pre-made might be more expensive/trouble than making my own in the first place. I'm also curious, but less so, of the performance trade-offs. Is there anyone out there have direct experience with using one of the libraries out there and have advice based on a success or failure

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

陌路散爱 提交于 2019-11-29 12:23:06
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. You can compose a property map in various ways. The simplest approach would seem something like: Using C++11 lambdas with function_property_map Live On Coliru #include <boost/property_map/function_property_map.hpp>