comparison DEPENDENCIES/generic/include/boost/graph/graphviz.hpp @ 101:c530137014c0

Update Boost headers (1.58.0)
author Chris Cannam
date Mon, 07 Sep 2015 11:12:49 +0100
parents 2665513ce2d3
children
comparison
equal deleted inserted replaced
100:793467b5e61c 101:c530137014c0
287 EdgePropertiesWriter epw, 287 EdgePropertiesWriter epw,
288 GraphPropertiesWriter gpw 288 GraphPropertiesWriter gpw
289 BOOST_GRAPH_ENABLE_IF_MODELS_PARM(Graph,vertex_list_graph_tag)) 289 BOOST_GRAPH_ENABLE_IF_MODELS_PARM(Graph,vertex_list_graph_tag))
290 { write_graphviz(out, g, vpw, epw, gpw, get(vertex_index, g)); } 290 { write_graphviz(out, g, vpw, epw, gpw, get(vertex_index, g)); }
291 291
292 #if !defined(BOOST_MSVC) || BOOST_MSVC > 1300
293 // ambiguous overload problem with VC++
294 template <typename Graph> 292 template <typename Graph>
295 inline void 293 inline void
296 write_graphviz(std::ostream& out, const Graph& g 294 write_graphviz(std::ostream& out, const Graph& g
297 BOOST_GRAPH_ENABLE_IF_MODELS_PARM(Graph,vertex_list_graph_tag)) 295 BOOST_GRAPH_ENABLE_IF_MODELS_PARM(Graph,vertex_list_graph_tag))
298 { 296 {
299 default_writer dw; 297 default_writer dw;
300 default_writer gw; 298 default_writer gw;
301 write_graphviz(out, g, dw, dw, gw); 299 write_graphviz(out, g, dw, dw, gw);
302 } 300 }
303 #endif
304 301
305 template <typename Graph, typename VertexWriter> 302 template <typename Graph, typename VertexWriter>
306 inline void 303 inline void
307 write_graphviz(std::ostream& out, const Graph& g, VertexWriter vw 304 write_graphviz(std::ostream& out, const Graph& g, VertexWriter vw
308 BOOST_GRAPH_ENABLE_IF_MODELS_PARM(Graph,vertex_list_graph_tag)) 305 BOOST_GRAPH_ENABLE_IF_MODELS_PARM(Graph,vertex_list_graph_tag))
347 out << " " << escape_dot_string(g_name) << " {" << std::endl; 344 out << " " << escape_dot_string(g_name) << " {" << std::endl;
348 345
349 typename Graph::const_children_iterator i_child, j_child; 346 typename Graph::const_children_iterator i_child, j_child;
350 347
351 //print graph/node/edge attributes 348 //print graph/node/edge attributes
352 #if defined(BOOST_MSVC) && BOOST_MSVC <= 1300
353 typedef typename graph_property<Graph, graph_graph_attribute_t>::type
354 GAttrMap;
355 typedef typename graph_property<Graph, graph_vertex_attribute_t>::type
356 NAttrMap;
357 typedef typename graph_property<Graph, graph_edge_attribute_t>::type
358 EAttrMap;
359 GAttrMap gam = get_property(g, graph_graph_attribute);
360 NAttrMap nam = get_property(g, graph_vertex_attribute);
361 EAttrMap eam = get_property(g, graph_edge_attribute);
362 graph_attributes_writer<GAttrMap, NAttrMap, EAttrMap> writer(gam, nam, eam);
363 writer(out);
364 #else
365 make_graph_attributes_writer(g)(out); 349 make_graph_attributes_writer(g)(out);
366 #endif
367 350
368 //print subgraph 351 //print subgraph
369 for ( boost::tie(i_child,j_child) = g.children(); 352 for ( boost::tie(i_child,j_child) = g.children();
370 i_child != j_child; ++i_child ) 353 i_child != j_child; ++i_child )
371 write_graphviz_subgraph(out, *i_child, vertex_marker, edge_marker, 354 write_graphviz_subgraph(out, *i_child, vertex_marker, edge_marker,
380 Vertex v = g.local_to_global(*i); 363 Vertex v = g.local_to_global(*i);
381 int pos = get(vertex_id, v); 364 int pos = get(vertex_id, v);
382 if ( vertex_marker[pos] ) { 365 if ( vertex_marker[pos] ) {
383 vertex_marker[pos] = false; 366 vertex_marker[pos] = false;
384 out << escape_dot_string(pos); 367 out << escape_dot_string(pos);
385 #if defined(BOOST_MSVC) && BOOST_MSVC <= 1300
386 typedef typename property_map<Graph, vertex_attribute_t>::const_type
387 VertexAttributeMap;
388 attributes_writer<VertexAttributeMap> vawriter(get(vertex_attribute,
389 g.root()));
390 vawriter(out, v);
391 #else
392 make_vertex_attributes_writer(g.root())(out, v); 368 make_vertex_attributes_writer(g.root())(out, v);
393 #endif
394 out << ";" << std::endl; 369 out << ";" << std::endl;
395 } 370 }
396 } 371 }
397 372
398 for (boost::tie(ei, edge_end) = edges(g); ei != edge_end; ++ei) { 373 for (boost::tie(ei, edge_end) = edges(g); ei != edge_end; ++ei) {
401 int pos = get(get(edge_index, g.root()), g.local_to_global(*ei)); 376 int pos = get(get(edge_index, g.root()), g.local_to_global(*ei));
402 if ( edge_marker[pos] ) { 377 if ( edge_marker[pos] ) {
403 edge_marker[pos] = false; 378 edge_marker[pos] = false;
404 out << escape_dot_string(get(vertex_id, u)) << " " << Traits::delimiter() 379 out << escape_dot_string(get(vertex_id, u)) << " " << Traits::delimiter()
405 << " " << escape_dot_string(get(vertex_id, v)); 380 << " " << escape_dot_string(get(vertex_id, v));
406 #if defined(BOOST_MSVC) && BOOST_MSVC <= 1300
407 typedef typename property_map<Graph, edge_attribute_t>::const_type
408 EdgeAttributeMap;
409 attributes_writer<EdgeAttributeMap> eawriter(get(edge_attribute, g));
410 eawriter(out, *ei);
411 #else
412 make_edge_attributes_writer(g)(out, *ei); //print edge properties 381 make_edge_attributes_writer(g)(out, *ei); //print edge properties
413 #endif
414 out << ";" << std::endl; 382 out << ";" << std::endl;
415 } 383 }
416 } 384 }
417 out << "}" << std::endl; 385 out << "}" << std::endl;
418 } 386 }
566 private: 534 private:
567 const dynamic_properties* dp; 535 const dynamic_properties* dp;
568 const std::string* node_id; 536 const std::string* node_id;
569 }; 537 };
570 538
539 template <typename Graph>
540 class dynamic_graph_properties_writer
541 {
542 public:
543 dynamic_graph_properties_writer(const dynamic_properties& dp, const Graph& g) : g(&g), dp(&dp) { }
544
545 void operator()(std::ostream& out) const
546 {
547 for (dynamic_properties::const_iterator i = dp->begin();
548 i != dp->end(); ++i) {
549 if (typeid(Graph*) == i->second->key()) {
550 // const_cast here is to match interface used in read_graphviz
551 out << i->first << "=" << escape_dot_string(i->second->get_string(const_cast<Graph*>(g))) << ";\n";
552 }
553 }
554 }
555
556 private:
557 const Graph* g;
558 const dynamic_properties* dp;
559 };
560
571 namespace graph { namespace detail { 561 namespace graph { namespace detail {
572 562
573 template<typename Vertex> 563 template<typename Vertex>
574 struct node_id_property_map 564 struct node_id_property_map
575 { 565 {
617 { 607 {
618 write_graphviz 608 write_graphviz
619 (out, g, 609 (out, g,
620 /*vertex_writer=*/dynamic_vertex_properties_writer(dp, node_id), 610 /*vertex_writer=*/dynamic_vertex_properties_writer(dp, node_id),
621 /*edge_writer=*/dynamic_properties_writer(dp), 611 /*edge_writer=*/dynamic_properties_writer(dp),
622 /*graph_writer=*/default_writer(), 612 /*graph_writer=*/dynamic_graph_properties_writer<Graph>(dp, g),
623 id); 613 id);
624 } 614 }
625 615
626 ///////////////////////////////////////////////////////////////////////////// 616 /////////////////////////////////////////////////////////////////////////////
627 // Graph reader exceptions 617 // Graph reader exceptions