Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r54995 - in trunk: boost/graph libs/graph/doc
From: asutton_at_[hidden]
Date: 2009-07-17 09:02:18


Author: asutton
Date: 2009-07-17 09:02:17 EDT (Fri, 17 Jul 2009)
New Revision: 54995
URL: http://svn.boost.org/trac/boost/changeset/54995

Log:
Adding edge-list requirements to write-grapviz function(s) and documentation,
fixing #3259.

Text files modified:
   trunk/boost/graph/graphviz.hpp | 50 +++++++++++----------
   trunk/libs/graph/doc/write-graphviz.html | 88 ++++++++++++++++++++--------------------
   2 files changed, 70 insertions(+), 68 deletions(-)

Modified: trunk/boost/graph/graphviz.hpp
==============================================================================
--- trunk/boost/graph/graphviz.hpp (original)
+++ trunk/boost/graph/graphviz.hpp 2009-07-17 09:02:17 EDT (Fri, 17 Jul 2009)
@@ -237,7 +237,7 @@
   template <typename Graph, typename VertexPropertiesWriter,
             typename EdgePropertiesWriter, typename GraphPropertiesWriter,
             typename VertexID>
- inline void
+ inline void
   write_graphviz
     (std::ostream& out, const Graph& g,
      VertexPropertiesWriter vpw,
@@ -246,6 +246,8 @@
      VertexID vertex_id
      BOOST_GRAPH_ENABLE_IF_MODELS_PARM(Graph,vertex_list_graph_tag))
   {
+ BOOST_CONCEPT_ASSERT((EdgeListGraphConcept<Graph>));
+
     typedef typename graph_traits<Graph>::directed_category cat_type;
     typedef graphviz_io_traits<cat_type> Traits;
     std::string name = "G";
@@ -271,7 +273,7 @@
 
   template <typename Graph, typename VertexPropertiesWriter,
             typename EdgePropertiesWriter, typename GraphPropertiesWriter>
- inline void
+ inline void
   write_graphviz(std::ostream& out, const Graph& g,
                  VertexPropertiesWriter vpw,
                  EdgePropertiesWriter epw,
@@ -284,7 +286,7 @@
   template <typename Graph>
   inline void
   write_graphviz(std::ostream& out, const Graph& g
- BOOST_GRAPH_ENABLE_IF_MODELS_PARM(Graph,vertex_list_graph_tag))
+ BOOST_GRAPH_ENABLE_IF_MODELS_PARM(Graph,vertex_list_graph_tag))
   {
     default_writer dw;
     default_writer gw;
@@ -416,7 +418,7 @@
 
     detail::write_graphviz_subgraph(out, g,
                                     vertex_marker.begin(),
- edge_marker.begin(),
+ edge_marker.begin(),
                                     get(vertex_index, g));
   }
 
@@ -434,20 +436,20 @@
 
   template <typename Graph, typename VertexID>
   void write_graphviz(std::ostream& out, const subgraph<Graph>& g,
- VertexID vertex_id)
+ VertexID vertex_id)
   {
     std::vector<bool> edge_marker(num_edges(g), true);
     std::vector<bool> vertex_marker(num_vertices(g), true);
 
     detail::write_graphviz_subgraph(out, g,
                                     vertex_marker.begin(),
- edge_marker.begin(),
+ edge_marker.begin(),
                                     vertex_id);
   }
 
   template <typename Graph, typename VertexID>
   void write_graphviz(const std::string& filename, const subgraph<Graph>& g,
- VertexID vertex_id)
+ VertexID vertex_id)
   {
     std::ofstream out(filename.c_str());
     std::vector<bool> edge_marker(num_edges(g), true);
@@ -494,7 +496,7 @@
   // Library has not existed for a while
   // extern void read_graphviz(const std::string& file, GraphvizDigraph& g);
   // extern void read_graphviz(FILE* file, GraphvizDigraph& g);
- //
+ //
   // extern void read_graphviz(const std::string& file, GraphvizGraph& g);
   // extern void read_graphviz(FILE* file, GraphvizGraph& g);
 
@@ -507,7 +509,7 @@
     void operator()(std::ostream& out, Descriptor key) const
     {
       bool first = true;
- for (dynamic_properties::const_iterator i = dp->begin();
+ for (dynamic_properties::const_iterator i = dp->begin();
            i != dp->end(); ++i) {
         if (typeid(key) == i->second->key()) {
           if (first) out << " [";
@@ -529,14 +531,14 @@
   {
   public:
     dynamic_vertex_properties_writer(const dynamic_properties& dp,
- const std::string& node_id)
+ const std::string& node_id)
       : dp(&dp), node_id(&node_id) { }
 
     template<typename Descriptor>
     void operator()(std::ostream& out, Descriptor key) const
     {
       bool first = true;
- for (dynamic_properties::const_iterator i = dp->begin();
+ for (dynamic_properties::const_iterator i = dp->begin();
            i != dp->end(); ++i) {
         if (typeid(key) == i->second->key()
             && i->first != *node_id) {
@@ -577,8 +579,8 @@
     };
 
     template<typename Vertex>
- inline std::string
- get(node_id_property_map<Vertex> pm,
+ inline std::string
+ get(node_id_property_map<Vertex> pm,
         typename node_id_property_map<Vertex>::key_type v)
     { return get(*pm.node_id, *pm.dp, v); }
 
@@ -587,7 +589,7 @@
   template<typename Graph>
   inline void
   write_graphviz(std::ostream& out, const Graph& g,
- const dynamic_properties& dp,
+ const dynamic_properties& dp,
                  const std::string& node_id = "node_id"
                  BOOST_GRAPH_ENABLE_IF_MODELS_PARM(Graph,vertex_list_graph_tag))
   {
@@ -677,7 +679,7 @@
     static int idx = 0;
     return edge_t(idx++);
   };
-
+
   bool operator==(const edge_t& rhs) const {
     return idx_ == rhs.idx_;
   }
@@ -693,14 +695,14 @@
   virtual bool is_directed() const = 0;
   virtual void do_add_vertex(const node_t& node) = 0;
 
- virtual void
+ virtual void
   do_add_edge(const edge_t& edge, const node_t& source, const node_t& target)
     = 0;
 
- virtual void
+ virtual void
   set_node_property(const id_t& key, const node_t& node, const id_t& value) = 0;
 
- virtual void
+ virtual void
   set_edge_property(const id_t& key, const edge_t& edge, const id_t& value) = 0;
 
   virtual void // RG: need new second parameter to support BGL subgraphs
@@ -722,7 +724,7 @@
 
   bool is_directed() const
   {
- return
+ return
       boost::is_convertible<
         typename boost::graph_traits<MutableGraph>::directed_category,
         boost::directed_tag>::value;
@@ -735,17 +737,17 @@
 
     // Set up a mapping from name to BGL vertex.
     bgl_nodes.insert(std::make_pair(node, v));
-
+
     // node_id_prop_ allows the caller to see the real id names for nodes.
     put(node_id_prop_, dp_, v, node);
   }
 
- void
+ void
   do_add_edge(const edge_t& edge, const node_t& source, const node_t& target)
   {
     std::pair<bgl_edge_t, bool> result =
      add_edge(bgl_nodes[source], bgl_nodes[target], graph_);
-
+
     if(!result.second) {
       // In the case of no parallel edges allowed
         boost::throw_exception(bad_parallel_edge(source, target));
@@ -773,7 +775,7 @@
     put(key, dp_, &graph_, value);
   }
 
-
+
  protected:
   MutableGraph& graph_;
   dynamic_properties& dp_;
@@ -791,7 +793,7 @@
 template <typename MutableGraph>
 bool read_graphviz(std::istream& in, MutableGraph& graph,
                    dynamic_properties& dp,
- std::string const& node_id = "node_id")
+ std::string const& node_id = "node_id")
 {
   std::string data;
   in >> std::noskipws;

Modified: trunk/libs/graph/doc/write-graphviz.html
==============================================================================
--- trunk/libs/graph/doc/write-graphviz.html (original)
+++ trunk/libs/graph/doc/write-graphviz.html 2009-07-17 09:02:17 EDT (Fri, 17 Jul 2009)
@@ -2,17 +2,17 @@
 
 <!--
      Copyright (c) Lie-Quan Lee and Jeremy Siek 2000, 2001
-
+
      Distributed under the Boost Software License, Version 1.0.
      (See accompanying file LICENSE_1_0.txt or copy at
      http://www.boost.org/LICENSE_1_0.txt)
   -->
 <Head>
 <Title>Boost Graph Library: write graphviz</Title>
-<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
- ALINK="#ff0000">
-<IMG SRC="../../../boost.png"
- ALT="C++ Boost" width="277" height="86">
+<BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
+ ALINK="#ff0000">
+<IMG SRC="../../../boost.png"
+ ALT="C++ Boost" width="277" height="86">
 
 <BR Clear>
 
@@ -23,42 +23,42 @@
 
 <pre>
 // Output graph structure without properties.
-template &lt; typename VertexListGraph &gt;
-void
-write_graphviz(std::ostream&amp; out, const VertexListGraph&amp; g);
+template &lt; typename VertexAndEdgeListGraph &gt;
+void
+write_graphviz(std::ostream&amp; out, const VertexAndEdgeListGraph&amp; g);
 
 // Graph structure with customized property output
-template &lt; typename VertexListGraph, typename VertexPropertyWriter &gt;
-void
-write_graphviz(std::ostream&amp; out, const VertexListGraph&amp; g,
+template &lt; typename VertexAndEdgeListGraph, typename VertexPropertyWriter &gt;
+void
+write_graphviz(std::ostream&amp; out, const VertexAndEdgeListGraph&amp; g,
                VertexPropertyWriter vpw);
 
-template &lt; typename VertexListGraph, typename VertexPropertyWriter,
+template &lt; typename VertexAndEdgeListGraph, typename VertexPropertyWriter,
            typename EdgePropertyWriter &gt;
 void
-write_graphviz(std::ostream&amp; out, const VertexListGraph&amp; g,
+write_graphviz(std::ostream&amp; out, const VertexAndEdgeListGraph&amp; g,
                VertexPropertyWriter vpw, EdgePropertyWriter epw);
 
-template &lt; typename VertexListGraph, typename VertexPropertyWriter,
+template &lt; typename VertexAndEdgeListGraph, typename VertexPropertyWriter,
            typename EdgePropertyWriter, typename GraphPropertyWriter &gt;
-void
-write_graphviz(std::ostream&amp; out, const VertexListGraph&amp; g,
- VertexPropertyWriter vpw, EdgePropertyWriter epw,
+void
+write_graphviz(std::ostream&amp; out, const VertexAndEdgeListGraph&amp; g,
+ VertexPropertyWriter vpw, EdgePropertyWriter epw,
                GraphPropertyWriter gpw);
 
-template &lt; typename VertexListGraph, typename VertexPropertyWriter,
+template &lt; typename VertexAndEdgeListGraph, typename VertexPropertyWriter,
            typename EdgePropertyWriter, typename GraphPropertyWriter,
            typename VertexID &gt;
-void
-write_graphviz(std::ostream&amp; out, const VertexListGraph&amp; g,
- VertexPropertyWriter vpw, EdgePropertyWriter epw,
+void
+write_graphviz(std::ostream&amp; out, const VertexAndEdgeListGraph&amp; g,
+ VertexPropertyWriter vpw, EdgePropertyWriter epw,
                GraphPropertyWriter gpw, VertexID vertex_id);
 
 // Graph structure with dynamic property output
 template&lt;typename Graph&gt;
 void
 write_graphviz(std::ostream&amp; out, const Graph&amp; g,
- const dynamic_properties&amp; dp,
+ const dynamic_properties&amp; dp,
                const std::string&amp; node_id = "node_id");
 
 template&lt;typename Graph, typename VertexID&gt;
@@ -69,9 +69,9 @@
 </pre>
 
 <p>
-This is to write a BGL graph object into an output stream in graphviz
-dot format so that users can make use of AT&T graphviz to draw a
-picture with nice layout.
+This is to write a BGL graph object into an output stream in graphviz dot format
+so that users can make use of AT&T graphviz
+to draw a picture with nice layout.
 <p>
 The first version with two parameters will write the graph into a
 <tt>std::ostream</tt> where each vertex is represented by its numerical vertex
@@ -121,7 +121,7 @@
 Thus, users could easily extend the <tt>write_graphviz</tt> function
 by creating their own PropertyWriter only.
 <p>
-A PropertyWriter
+A PropertyWriter
 for vertices or edges is a functor which can be called with two parameters:
 <tt>std::ostream</tt> and either a vertex or an edge descriptor. It should output a
 pair of brackets with a series of assigments &quot;name=value&quot; inside.
@@ -151,10 +151,10 @@
 </pre>
 
 <p>
-A PropertyWriter
-for graphs is a functor which is called with one parameter of type
+A PropertyWriter
+for graphs is a functor which is called with one parameter of type
 <tt>std::ostream</tt> and should print a series of graph properties. The following
-code excerpt is an example of a PropertyWriter for a graph.
+code excerpt is an example of a PropertyWriter for a graph.
 <pre>
   struct sample_graph_writer {
     void operator()(std::ostream& out) const {
@@ -176,28 +176,28 @@
  OUT: <tt>std::ostream&amp; out</tt>
 <blockquote>
   A standard <tt>std::ostream</tt> object.
-</blockquote>
+</blockquote>
 
- IN: <tt>VertexListGraph&amp; g</tt>
+ IN: <tt>VertexAndEdgeListGraph&amp; g</tt>
 <blockquote>
- A directed or undirected graph. The graph's type must be a model of
- VertexListGraph. Also the graph
- must have an internal <tt>vertex_index</tt> property map.
-</blockquote>
+ A directed or undirected graph. The graph's type must be a model of
+ VertexAndEdgeListGraph. Also the
+ graph must have an internal <tt>vertex_index</tt> property map.
+</blockquote>
 
  IN: <tt>VertexPropertyWriter vpw</tt>
 <blockquote>
   A functor that models PropertyWriter concept to print
   properties of a vertex.<br>
 <b>Default</b>: <tt>default_writer()</tt>
-</blockquote>
+</blockquote>
 
  IN: <tt>EdgePropertyWriter epw</tt>
 <blockquote>
   A functor that models PropertyWriter concept to print
   properties of an edge.<br>
 <b>Default</b>: <tt>default_writer()</tt>
-</blockquote>
+</blockquote>
 
  IN: <tt>GraphPropertyWriter epw</tt>
 <blockquote>
@@ -228,15 +228,15 @@
 Example
 </H3>
 
-This example demonstrates using BGL-graphviz interface to write
+This example demonstrates using BGL-graphviz interface to write
 a BGL graph into a graphviz format file.
 
 <pre>
 #include &lt;boost/graph/graphviz.hpp&gt;
 
-enum files_e { dax_h, yow_h, boz_h, zow_h, foo_cpp,
+enum files_e { dax_h, yow_h, boz_h, zow_h, foo_cpp,
                foo_o, bar_cpp, bar_o, libfoobar_a,
- zig_cpp, zig_o, zag_cpp, zag_o,
+ zig_cpp, zig_o, zag_cpp, zag_o,
                  libzigzag_a, killerapp, N };
 const char* name[] = { "dax.h", "yow.h", "boz.h", "zow.h", "foo.cpp",
                        "foo.o", "bar.cpp", "bar.o", "libfoobar.a",
@@ -245,13 +245,13 @@
 
 int main(int,char*[])
 {
-
+
   typedef pair&lt;int,int&gt; Edge;
   Edge used_by[] = {
     Edge(dax_h, foo_cpp), Edge(dax_h, bar_cpp), Edge(dax_h, yow_h),
     Edge(yow_h, bar_cpp), Edge(yow_h, zag_cpp),
     Edge(boz_h, bar_cpp), Edge(boz_h, zig_cpp), Edge(boz_h, zag_cpp),
- Edge(zow_h, foo_cpp),
+ Edge(zow_h, foo_cpp),
     Edge(foo_cpp, foo_o),
     Edge(foo_o, libfoobar_a),
     Edge(bar_cpp, bar_o),
@@ -269,7 +269,7 @@
 
   using namespace boost;
 
- typedef adjacency_list< vecS, vecS, directedS,
+ typedef adjacency_list< vecS, vecS, directedS,
       property< vertex_color_t, default_color_type >,
       property< edge_weight_t, int >
> Graph;
@@ -343,4 +343,4 @@
 </TD></TR></TABLE>
 
 </BODY>
-</HTML>
+</HTML>


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk