Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r53650 - in trunk: boost/graph libs/graph/doc libs/graph/src
From: jewillco_at_[hidden]
Date: 2009-06-04 21:47:38


Author: jewillco
Date: 2009-06-04 21:47:37 EDT (Thu, 04 Jun 2009)
New Revision: 53650
URL: http://svn.boost.org/trac/boost/changeset/53650

Log:
Applied patches from ticket #900; fixes #900
Text files modified:
   trunk/boost/graph/graphml.hpp | 3
   trunk/libs/graph/doc/read_graphml.html | 137 ++++++++++++++++------------------
   trunk/libs/graph/doc/read_graphml.rst | 47 +++++------
   trunk/libs/graph/doc/write_graphml.html | 100 ++++++++++++------------
   trunk/libs/graph/doc/write_graphml.rst | 17 ++--
   trunk/libs/graph/src/graphml.cpp | 158 +++++++++++++++++++++------------------
   6 files changed, 233 insertions(+), 229 deletions(-)

Modified: trunk/boost/graph/graphml.hpp
==============================================================================
--- trunk/boost/graph/graphml.hpp (original)
+++ trunk/boost/graph/graphml.hpp 2009-06-04 21:47:37 EDT (Thu, 04 Jun 2009)
@@ -34,10 +34,11 @@
 /////////////////////////////////////////////////////////////////////////////
 struct parse_error: public graph_exception
 {
- parse_error(const std::string& error) {statement = "parse error: " + error;}
+ parse_error(const std::string& err) {error = err; statement = "parse error: " + error;}
     virtual ~parse_error() throw() {}
     virtual const char* what() const throw() {return statement.c_str();}
     std::string statement;
+ std::string error;
 };
 
 

Modified: trunk/libs/graph/doc/read_graphml.html
==============================================================================
--- trunk/libs/graph/doc/read_graphml.html (original)
+++ trunk/libs/graph/doc/read_graphml.html 2009-06-04 21:47:37 EDT (Thu, 04 Jun 2009)
@@ -1,72 +1,70 @@
 <?xml version="1.0" encoding="utf-8" ?>
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<!--
- Copyright (C) 2006 Tiago de Paula Peixoto <tiago_at_[hidden]>
-
- 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)
-
- Authors: Tiago de Paula Peixoto
--->
-
 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
 <head>
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-<meta name="generator" content="Docutils 0.3.3: http://docutils.sourceforge.net/" />
+<meta name="generator" content="Docutils 0.6: http://docutils.sourceforge.net/" />
 <title>Boost read_graphml</title>
-<link rel="stylesheet" href="default.css" type="text/css" />
+<link rel="stylesheet" href="../../../../rst.css" type="text/css" />
 </head>
 <body>
-<h1 class="title"><a class="reference" href="../../../index.htm"><img align="middle" alt="Boost" src="../../../boost.png" /></a> <tt class="literal"><span class="pre">read_graphml</span></tt></h1>
 <div class="document" id="logo-read-graphml">
+<h1 class="title"><a class="reference external" href="../../../index.htm"><img align="middle" alt="Boost" class="align-middle" src="../../../boost.png" /></a> <tt class="docutils literal"><span class="pre">read_graphml</span></tt></h1>
+
+<!-- Copyright (C) 2006 Tiago de Paula Peixoto <tiago_at_[hidden]>
+
+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)
+
+Authors: Tiago de Paula Peixoto -->
 <pre class="literal-block">
 void read_graphml(std::istream&amp; in, MutableGraph&amp; graph,
                   dynamic_properties&amp; dp);
 </pre>
-<p>The <tt class="literal"><span class="pre">read_graphml</span></tt> function interprets a graph described using the
-<a class="reference" href="http://graphml.graphdrawing.org/">graphml</a> format and builds a BGL graph that captures that
+<p>The <tt class="docutils literal"><span class="pre">read_graphml</span></tt> function interprets a graph described using the
+<a class="reference external" href="http://graphml.graphdrawing.org/">GraphML</a> format and builds a BGL graph that captures that
 description. Using this function, you can initialize a graph using
 data stored as text.</p>
-<p>The graphml format can specify both directed and undirected graphs, and
-<tt class="literal"><span class="pre">read_graphml</span></tt> differentiates between the two. One must pass
-<tt class="literal"><span class="pre">read_graphml</span></tt> an undirected graph when reading an undirected graph;
-the same is true for directed graphs. Furthermore, <tt class="literal"><span class="pre">read_graphml</span></tt>
+<p>The GraphML format can specify both directed and undirected graphs, and
+<tt class="docutils literal"><span class="pre">read_graphml</span></tt> differentiates between the two. One must pass
+<tt class="docutils literal"><span class="pre">read_graphml</span></tt> an undirected graph when reading an undirected graph;
+the same is true for directed graphs. Furthermore, <tt class="docutils literal"><span class="pre">read_graphml</span></tt>
 will throw an exception if it encounters parallel edges and cannot add
 them to the graph.</p>
-<p>To handle attributes expressed in the graphml format, <tt class="literal"><span class="pre">read_graphml</span></tt>
-takes a <a class="reference" href="../../property_map/doc/dynamic_property_map.html">dynamic_properties</a> object and operates on its collection of
+<p>To handle attributes expressed in the GraphML format, <tt class="docutils literal"><span class="pre">read_graphml</span></tt>
+takes a <a class="reference external" href="../../property_map/doc/dynamic_property_map.html">dynamic_properties</a> object and operates on its collection of
 property maps. The reader passes all the properties encountered to
-this object, using the graphml attribute names as the property keys,
-and with the appropriate C++ type based on the graphml attribute type
-definition.</p>
-<dl>
+this object, using the GraphML attribute names as the property names,
+and with the appropriate C++ value type based on the GraphML attribute type
+definition. Graph properties are also set with the same
+<a class="reference external" href="../../property_map/doc/dynamic_property_map.html">dynamic_properties</a> object, where the key type is the type of the graph itself.</p>
+<dl class="docutils">
 <dt>Requirements:</dt>
 <dd><ul class="first last simple">
-<li>The type of the graph must model the <a class="reference" href="MutableGraph.html">Mutable Graph</a> concept.</li>
-<li>The type of the iterator must model the <a class="reference" href="../../iterator/index.html">Multi-Pass Iterator</a>
+<li>The type of the graph must model the <a class="reference external" href="MutableGraph.html">Mutable Graph</a> concept.</li>
+<li>The type of the iterator must model the <a class="reference external" href="../../iterator/index.html">Multi-Pass Iterator</a>
 concept.</li>
 <li>The property map value types must be default-constructible.</li>
 </ul>
 </dd>
 </dl>
 <div class="contents topic" id="contents">
-<p class="topic-title first"><a name="contents">Contents</a></p>
+<p class="topic-title first">Contents</p>
 <ul class="simple">
-<li><a class="reference" href="#where-defined" id="id2" name="id2">Where Defined</a></li>
-<li><a class="reference" href="#exceptions" id="id3" name="id3">Exceptions</a></li>
-<li><a class="reference" href="#building-the-graphml-reader" id="id4" name="id4">Building the graphml reader</a></li>
-<li><a class="reference" href="#notes" id="id5" name="id5">Notes</a></li>
-<li><a class="reference" href="#see-also" id="id6" name="id6">See Also</a></li>
-<li><a class="reference" href="#future-work" id="id7" name="id7">Future Work</a></li>
+<li><a class="reference internal" href="#where-defined" id="id2">Where Defined</a></li>
+<li><a class="reference internal" href="#exceptions" id="id3">Exceptions</a></li>
+<li><a class="reference internal" href="#building-the-graphml-reader" id="id4">Building the GraphML reader</a></li>
+<li><a class="reference internal" href="#notes" id="id5">Notes</a></li>
+<li><a class="reference internal" href="#see-also" id="id6">See Also</a></li>
 </ul>
 </div>
 <div class="section" id="where-defined">
-<h1><a class="toc-backref" href="#id2" name="where-defined">Where Defined</a></h1>
-<p><tt class="literal"><span class="pre">&lt;boost/graph/graphml.hpp&gt;</span></tt></p>
+<h1><a class="toc-backref" href="#id2">Where Defined</a></h1>
+<p><tt class="docutils literal"><span class="pre">&lt;boost/graph/graphml.hpp&gt;</span></tt></p>
 </div>
 <div class="section" id="exceptions">
-<h1><a class="toc-backref" href="#id3" name="exceptions">Exceptions</a></h1>
+<h1><a class="toc-backref" href="#id3">Exceptions</a></h1>
 <pre class="literal-block">
 struct graph_exception : public std::exception {
   virtual ~graph_exception() throw();
@@ -97,44 +95,46 @@
   virtual ~parse_error() throw() {}
   virtual const char* what() const throw();
   std::string statement;
+ std::string error;
 };
 </pre>
-<p>Under certain circumstances, <tt class="literal"><span class="pre">read_graphml</span></tt> will throw one of the
+<p>Under certain circumstances, <tt class="docutils literal"><span class="pre">read_graphml</span></tt> will throw one of the
 above exceptions. The three concrete exceptions can all be caught
-using the general <tt class="literal"><span class="pre">graph_exception</span></tt> moniker when greater precision
+using the general <tt class="docutils literal"><span class="pre">graph_exception</span></tt> moniker when greater precision
 is not needed. In addition, all of the above exceptions derive from
-the standard <tt class="literal"><span class="pre">std::exception</span></tt> for even more generalized error
+the standard <tt class="docutils literal"><span class="pre">std::exception</span></tt> for even more generalized error
 handling.</p>
-<p>The <tt class="literal"><span class="pre">bad_parallel_edge</span></tt> exception is thrown when an attempt to add a
-parallel edge to the supplied MutableGraph fails. The graphml format
+<p>The <tt class="docutils literal"><span class="pre">bad_parallel_edge</span></tt> exception is thrown when an attempt to add a
+parallel edge to the supplied MutableGraph fails. The GraphML format
 supports parallel edges, but some BGL-compatible graph types do not.
-One example of such a graph is <tt class="literal"><span class="pre">boost::adjacency_list&lt;setS,vecS&gt;</span></tt>,
+One example of such a graph is <tt class="docutils literal"><span class="pre">boost::adjacency_list&lt;setS,vecS&gt;</span></tt>,
 which allows at most one edge can between any two vertices.</p>
-<p>The <tt class="literal"><span class="pre">directed_graph_error</span></tt> exception occurs when an undirected graph
-type is passed to <tt class="literal"><span class="pre">read_graph</span></tt> but the textual representation of the
-graph is directed, as indicated by the <tt class="literal"><span class="pre">edgedefault=&quot;directed&quot;</span></tt>
-graph attribute in the graphml format.</p>
-<p>The <tt class="literal"><span class="pre">undirected_graph_error</span></tt> exception occurs when a directed graph
-type is passed to <tt class="literal"><span class="pre">read_graph</span></tt> but the textual representation of the
-graph is undirected, as indicated by the <tt class="literal"><span class="pre">edgedefault=&quot;undirected&quot;</span></tt>
-graph attribute in the graphml format.</p>
+<p>The <tt class="docutils literal"><span class="pre">directed_graph_error</span></tt> exception occurs when an undirected graph
+type is passed to <tt class="docutils literal"><span class="pre">read_graph</span></tt>, but the graph defined in the GraphML
+file contains at least one directed edge.</p>
+<p>The <tt class="docutils literal"><span class="pre">undirected_graph_error</span></tt> exception occurs when a directed graph
+type is passed to <tt class="docutils literal"><span class="pre">read_graph</span></tt>, but the graph defined in the GraphML
+file contains at least one undirected edge.</p>
+<p>The <tt class="docutils literal"><span class="pre">parse_error</span></tt> exception occurs when a syntax error is
+encountered in the GraphML file. The error string will contain the
+line and column where the error was encountered.</p>
 </div>
 <div class="section" id="building-the-graphml-reader">
-<h1><a class="toc-backref" href="#id4" name="building-the-graphml-reader">Building the graphml reader</a></h1>
-<p>To use the graphml reader, you will need to build and link against
-the &quot;bgl-graphml&quot; library. The library can be built by following the
-<a class="reference" href="../../../doc/html/bbv2/installation.html">Boost Jam Build Instructions</a> for the subdirectory <tt class="literal"><span class="pre">libs/graph/build</span></tt>.</p>
+<h1><a class="toc-backref" href="#id4">Building the GraphML reader</a></h1>
+<p>To use the GraphML reader, you will need to build and link against
+the &quot;boost_graph&quot; library. The library can be built by following the
+<a class="reference external" href="../../../more/getting_started.html#Build_Install">Boost Jam Build Instructions</a> for the subdirectory <tt class="docutils literal"><span class="pre">libs/graph/build</span></tt>.</p>
 </div>
 <div class="section" id="notes">
-<h1><a class="toc-backref" href="#id5" name="notes">Notes</a></h1>
+<h1><a class="toc-backref" href="#id5">Notes</a></h1>
 <blockquote>
 <ul class="simple">
 <li>On successful reading of a graph, every vertex and edge will have
 an associated value for every respective edge and vertex property
 encountered while interpreting the graph. These values will be set
-using the <tt class="literal"><span class="pre">dynamic_properties</span></tt> object. Some properties may be
-<tt class="literal"><span class="pre">put</span></tt> multiple times during the course of reading in order to
-ensure the graphml semantics. Those edges and vertices that are
+using the <tt class="docutils literal"><span class="pre">dynamic_properties</span></tt> object. Some properties may be
+<tt class="docutils literal"><span class="pre">put</span></tt> multiple times during the course of reading in order to
+ensure the GraphML semantics. Those edges and vertices that are
 not explicitly given a value for a property (and that property has
 no default) will be given the default constructed value of the
 value type. <strong>Be sure that property map value types are default
@@ -150,22 +150,15 @@
 </blockquote>
 </div>
 <div class="section" id="see-also">
-<h1><a class="toc-backref" href="#id6" name="see-also">See Also</a></h1>
-<p><a class="reference" href="write_graphml.html">write_graphml</a></p>
-</div>
-<div class="section" id="future-work">
-<h1><a class="toc-backref" href="#id7" name="future-work">Future Work</a></h1>
-<blockquote>
-<ul class="simple">
-<li>Better expat error detection.</li>
-</ul>
-</blockquote>
+<h1><a class="toc-backref" href="#id6">See Also</a></h1>
+<p><a class="reference external" href="write_graphml.html">write_graphml</a></p>
 </div>
 </div>
-<hr class="footer" />
 <div class="footer">
-<a class="reference" href="read_graphml.rst">View document source</a>.
-Generated by <a class="reference" href="http://docutils.sourceforge.net/">Docutils</a> from <a class="reference" href="http://docutils.sourceforge.net/rst.html">reStructuredText</a> source.
+<hr class="footer" />
+Generated on: 2009-06-05 01:26 UTC.
+Generated by <a class="reference external" href="http://docutils.sourceforge.net/">Docutils</a> from <a class="reference external" href="http://docutils.sourceforge.net/rst.html">reStructuredText</a> source.
+
 </div>
 </body>
 </html>

Modified: trunk/libs/graph/doc/read_graphml.rst
==============================================================================
--- trunk/libs/graph/doc/read_graphml.rst (original)
+++ trunk/libs/graph/doc/read_graphml.rst 2009-06-04 21:47:37 EDT (Thu, 04 Jun 2009)
@@ -23,23 +23,24 @@
 
  
 The ``read_graphml`` function interprets a graph described using the
-graphml_ format and builds a BGL graph that captures that
+GraphML_ format and builds a BGL graph that captures that
 description. Using this function, you can initialize a graph using
 data stored as text.
 
-The graphml format can specify both directed and undirected graphs, and
+The GraphML format can specify both directed and undirected graphs, and
 ``read_graphml`` differentiates between the two. One must pass
 ``read_graphml`` an undirected graph when reading an undirected graph;
 the same is true for directed graphs. Furthermore, ``read_graphml``
 will throw an exception if it encounters parallel edges and cannot add
 them to the graph.
 
-To handle attributes expressed in the graphml format, ``read_graphml``
+To handle attributes expressed in the GraphML format, ``read_graphml``
 takes a dynamic_properties_ object and operates on its collection of
 property maps. The reader passes all the properties encountered to
-this object, using the graphml attribute names as the property keys,
-and with the appropriate C++ type based on the graphml attribute type
-definition.
+this object, using the GraphML attribute names as the property names,
+and with the appropriate C++ value type based on the GraphML attribute type
+definition. Graph properties are also set with the same
+dynamic_properties_ object, where the key type is the type of the graph itself.
 
 Requirements:
  - The type of the graph must model the `Mutable Graph`_ concept.
@@ -88,6 +89,7 @@
     virtual ~parse_error() throw() {}
     virtual const char* what() const throw();
     std::string statement;
+ std::string error;
   };
 
 Under certain circumstances, ``read_graphml`` will throw one of the
@@ -98,27 +100,29 @@
 handling.
 
 The ``bad_parallel_edge`` exception is thrown when an attempt to add a
-parallel edge to the supplied MutableGraph fails. The graphml format
+parallel edge to the supplied MutableGraph fails. The GraphML format
 supports parallel edges, but some BGL-compatible graph types do not.
 One example of such a graph is ``boost::adjacency_list<setS,vecS>``,
 which allows at most one edge can between any two vertices.
 
 
 The ``directed_graph_error`` exception occurs when an undirected graph
-type is passed to ``read_graph`` but the textual representation of the
-graph is directed, as indicated by the ``edgedefault="directed"``
-graph attribute in the graphml format.
+type is passed to ``read_graph``, but the graph defined in the GraphML
+file contains at least one directed edge.
 
 The ``undirected_graph_error`` exception occurs when a directed graph
-type is passed to ``read_graph`` but the textual representation of the
-graph is undirected, as indicated by the ``edgedefault="undirected"``
-graph attribute in the graphml format.
+type is passed to ``read_graph``, but the graph defined in the GraphML
+file contains at least one undirected edge.
 
+The ``parse_error`` exception occurs when a syntax error is
+encountered in the GraphML file. The error string will contain the
+line and column where the error was encountered.
 
-Building the graphml reader
+
+Building the GraphML reader
 -----------------------------
-To use the graphml reader, you will need to build and link against
-the "bgl-graphml" library. The library can be built by following the
+To use the GraphML reader, you will need to build and link against
+the "boost_graph" library. The library can be built by following the
 `Boost Jam Build Instructions`_ for the subdirectory ``libs/graph/build``.
 
 
@@ -130,7 +134,7 @@
    encountered while interpreting the graph. These values will be set
    using the ``dynamic_properties`` object. Some properties may be
    ``put`` multiple times during the course of reading in order to
- ensure the graphml semantics. Those edges and vertices that are
+ ensure the GraphML semantics. Those edges and vertices that are
    not explicitly given a value for a property (and that property has
    no default) will be given the default constructed value of the
    value type. **Be sure that property map value types are default
@@ -151,14 +155,7 @@
 write_graphml_
 
 
-Future Work
------------
-
- - Better expat error detection.
-
-
-.. _Graphml: http://graphml.graphdrawing.org/
-
+.. _GraphML: http://graphml.graphdrawing.org/
 .. _`Mutable Graph`: MutableGraph.html
 .. _`Multi-Pass Iterator`: ../../iterator/index.html
 .. _dynamic_properties: ../../property_map/doc/dynamic_property_map.html

Modified: trunk/libs/graph/doc/write_graphml.html
==============================================================================
--- trunk/libs/graph/doc/write_graphml.html (original)
+++ trunk/libs/graph/doc/write_graphml.html 2009-06-04 21:47:37 EDT (Thu, 04 Jun 2009)
@@ -1,28 +1,27 @@
 <?xml version="1.0" encoding="utf-8" ?>
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<!--
- Copyright (C) 2006 Tiago de Paula Peixoto <tiago_at_[hidden]>
-
- 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)
-
- Authors: Tiago de Paula Peixoto
--->
 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
 <head>
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-<meta name="generator" content="Docutils 0.3.3: http://docutils.sourceforge.net/" />
+<meta name="generator" content="Docutils 0.6: http://docutils.sourceforge.net/" />
 <title>Boost write_graphml</title>
-<link rel="stylesheet" href="default.css" type="text/css" />
+<link rel="stylesheet" href="../../../../rst.css" type="text/css" />
 </head>
 <body>
-<h1 class="title"><a class="reference" href="../../../index.htm"><img align="middle" alt="Boost" src="../../../boost.png" /></a> <tt class="literal"><span class="pre">write_graphml</span></tt></h1>
 <div class="document" id="logo-write-graphml">
+<h1 class="title"><a class="reference external" href="../../../index.htm"><img align="middle" alt="Boost" class="align-middle" src="../../../boost.png" /></a> <tt class="docutils literal"><span class="pre">write_graphml</span></tt></h1>
+
+<!-- Copyright (C) 2006 Tiago de Paula Peixoto <tiago_at_[hidden]>
+
+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)
+
+Authors: Tiago de Paula Peixoto -->
 <pre class="literal-block">
 template&lt;typename Graph&gt;
 void
-write_graphml(std::ostream&amp; out, const Graph&amp; g, const dynamic_properties&amp; dp,
+write_graphml(std::ostream&amp; out, const Graph&amp; g, const dynamic_properties&amp; dp,
               bool ordered_vertices=false);
 
 template&lt;typename Graph, typename VertexIndexMap&gt;
@@ -31,53 +30,53 @@
               const dynamic_properties&amp; dp, bool ordered_vertices=false);
 </pre>
 <p>This is to write a BGL graph object into an output stream in the
-<a class="reference" href="http://graphml.graphdrawing.org/">graphml</a> format. Both overloads of <tt class="literal"><span class="pre">write_graphml</span></tt> will emit all of
-the properties stored in the <a class="reference" href="../../property_map/doc/dynamic_property_map.html">dynamic_properties</a> object, thereby
+<a class="reference external" href="http://graphml.graphdrawing.org/">GraphML</a> format. Both overloads of <tt class="docutils literal"><span class="pre">write_graphml</span></tt> will emit all of
+the properties stored in the <a class="reference external" href="../../property_map/doc/dynamic_property_map.html">dynamic_properties</a> object, thereby
 retaining the properties that have been read in through the dual
-function <a class="reference" href="read_graphml.html">read_graphml</a>. The second overload must be used when the
+function <a class="reference external" href="read_graphml.html">read_graphml</a>. The second overload must be used when the
 graph doesn't have an internal vertex index map, which must then be
 supplied with the appropriate parameter.</p>
 <div class="contents topic" id="contents">
-<p class="topic-title first"><a name="contents">Contents</a></p>
+<p class="topic-title first">Contents</p>
 <ul class="simple">
-<li><a class="reference" href="#where-defined" id="id2" name="id2">Where Defined</a></li>
-<li><a class="reference" href="#parameters" id="id3" name="id3">Parameters</a></li>
-<li><a class="reference" href="#example" id="id4" name="id4">Example</a></li>
-<li><a class="reference" href="#see-also" id="id5" name="id5">See Also</a></li>
-<li><a class="reference" href="#notes" id="id6" name="id6">Notes</a></li>
+<li><a class="reference internal" href="#where-defined" id="id2">Where Defined</a></li>
+<li><a class="reference internal" href="#parameters" id="id3">Parameters</a></li>
+<li><a class="reference internal" href="#example" id="id4">Example</a></li>
+<li><a class="reference internal" href="#see-also" id="id5">See Also</a></li>
+<li><a class="reference internal" href="#notes" id="id6">Notes</a></li>
 </ul>
 </div>
 <div class="section" id="where-defined">
-<h1><a class="toc-backref" href="#id2" name="where-defined">Where Defined</a></h1>
-<p><tt class="literal"><span class="pre">&lt;boost/graph/graphml.hpp&gt;</span></tt></p>
+<h1><a class="toc-backref" href="#id2">Where Defined</a></h1>
+<p><tt class="docutils literal"><span class="pre">&lt;boost/graph/graphml.hpp&gt;</span></tt></p>
 </div>
 <div class="section" id="parameters">
-<h1><a class="toc-backref" href="#id3" name="parameters">Parameters</a></h1>
-<dl>
-<dt>OUT: <tt class="literal"><span class="pre">std::ostream&amp;</span> <span class="pre">out</span></tt></dt>
-<dd>A standard <tt class="literal"><span class="pre">std::ostream</span></tt> object.</dd>
-<dt>IN: <tt class="literal"><span class="pre">VertexListGraph&amp;</span> <span class="pre">g</span></tt> </dt>
+<h1><a class="toc-backref" href="#id3">Parameters</a></h1>
+<dl class="docutils">
+<dt>OUT: <tt class="docutils literal"><span class="pre">std::ostream&amp;</span> <span class="pre">out</span></tt></dt>
+<dd>A standard <tt class="docutils literal"><span class="pre">std::ostream</span></tt> object.</dd>
+<dt>IN: <tt class="docutils literal"><span class="pre">VertexListGraph&amp;</span> <span class="pre">g</span></tt></dt>
 <dd>A directed or undirected graph. The
-graph's type must be a model of <a class="reference" href="VertexListGraph.html">VertexListGraph</a>. If the graph
-doesn't have an internal <tt class="literal"><span class="pre">vertex_index</span></tt> property map, one
+graph's type must be a model of <a class="reference external" href="VertexListGraph.html">VertexListGraph</a>. If the graph
+doesn't have an internal <tt class="docutils literal"><span class="pre">vertex_index</span></tt> property map, one
 must be supplied with the vertex_index parameter.</dd>
-<dt>IN: <tt class="literal"><span class="pre">VertexIndexMap</span> <span class="pre">vertex_index</span></tt></dt>
+<dt>IN: <tt class="docutils literal"><span class="pre">VertexIndexMap</span> <span class="pre">vertex_index</span></tt></dt>
 <dd>A vertex property map containing the indexes in the range
 [0,num_vertices(g)].</dd>
-<dt>IN: <tt class="literal"><span class="pre">dynamic_properties&amp;</span> <span class="pre">dp</span></tt></dt>
-<dd>Contains all of the vertex and edge properties that should be
-emitted by the graphml writer.</dd>
-<dt>IN: <tt class="literal"><span class="pre">bool</span> <span class="pre">ordered_vertices</span></tt></dt>
+<dt>IN: <tt class="docutils literal"><span class="pre">dynamic_properties&amp;</span> <span class="pre">dp</span></tt></dt>
+<dd>Contains all of the vertex, edge, and graph properties that should be
+emitted by the GraphML writer.</dd>
+<dt>IN: <tt class="docutils literal"><span class="pre">bool</span> <span class="pre">ordered_vertices</span></tt></dt>
 <dd>This tells whether or not the order of the vertices from vertices(g)
-matches the order of the indexes. If <tt class="literal"><span class="pre">true</span></tt>, the <tt class="literal"><span class="pre">parse.nodeids</span></tt>
-graph attribute will be set to <tt class="literal"><span class="pre">canonical</span></tt>. Otherwise it will be
-set to <tt class="literal"><span class="pre">free</span></tt>.</dd>
+matches the order of the indexes. If <tt class="docutils literal"><span class="pre">true</span></tt>, the <tt class="docutils literal"><span class="pre">parse.nodeids</span></tt>
+graph attribute will be set to <tt class="docutils literal"><span class="pre">canonical</span></tt>. Otherwise it will be
+set to <tt class="docutils literal"><span class="pre">free</span></tt>.</dd>
 </dl>
 </div>
 <div class="section" id="example">
-<h1><a class="toc-backref" href="#id4" name="example">Example</a></h1>
-<p>This example demonstrates using BGL-graphml interface to write
-a BGL graph into a graphml format file.</p>
+<h1><a class="toc-backref" href="#id4">Example</a></h1>
+<p>This example demonstrates using BGL-GraphML interface to write
+a BGL graph into a GraphML format file.</p>
 <pre class="literal-block">
 enum files_e { dax_h, yow_h, boz_h, zow_h, foo_cpp,
                foo_o, bar_cpp, bar_o, libfoobar_a,
@@ -134,7 +133,7 @@
 <p>The output will be:</p>
 <pre class="literal-block">
 &lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
-&lt;graphml xmlns=&quot;http://graphml.graphdrawing.org/xmlns/graphml&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:schemaLocation=&quot;http://graphml.graphdrawing.org/xmlns/graphml http://graphml.graphdrawing.org/xmlns/graphml/graphml-attributes-1.0rc.xsd&quot;&gt;
+&lt;graphml xmlns=&quot;http://graphml.graphdrawing.org/xmlns/graphml&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:schemaLocation=&quot;http://graphml.graphdrawing.org/xmlns/graphml http://graphml.graphdrawing.org/xmlns/graphml/graphml-attributes-1.0rc.xsd&quot;&gt;
   &lt;key id=&quot;key0&quot; for=&quot;node&quot; attr.name=&quot;name&quot; attr.type=&quot;string&quot; /&gt;
   &lt;key id=&quot;key1&quot; for=&quot;edge&quot; attr.name=&quot;weight&quot; attr.type=&quot;int&quot; /&gt;
   &lt;graph id=&quot;G&quot; edgedefault=&quot;directed&quot; parse.nodeids=&quot;canonical&quot; parse.edgeids=&quot;canonical&quot; parse.order=&quot;nodesfirst&quot;&gt;
@@ -245,23 +244,24 @@
 </pre>
 </div>
 <div class="section" id="see-also">
-<h1><a class="toc-backref" href="#id5" name="see-also">See Also</a></h1>
+<h1><a class="toc-backref" href="#id5">See Also</a></h1>
 <p>_read_graphml</p>
 </div>
 <div class="section" id="notes">
-<h1><a class="toc-backref" href="#id6" name="notes">Notes</a></h1>
+<h1><a class="toc-backref" href="#id6">Notes</a></h1>
 <blockquote>
 <ul class="simple">
-<li>Note that you can use graphml file write facilities without linking
-against the <tt class="literal"><span class="pre">boost_graph</span></tt> library.</li>
+<li>Note that you can use GraphML file write facilities without linking
+against the <tt class="docutils literal"><span class="pre">boost_graph</span></tt> library.</li>
 </ul>
 </blockquote>
 </div>
 </div>
-<hr class="footer" />
 <div class="footer">
-<a class="reference" href="write_graphml.rst">View document source</a>.
-Generated by <a class="reference" href="http://docutils.sourceforge.net/">Docutils</a> from <a class="reference" href="http://docutils.sourceforge.net/rst.html">reStructuredText</a> source.
+<hr class="footer" />
+Generated on: 2009-06-05 01:26 UTC.
+Generated by <a class="reference external" href="http://docutils.sourceforge.net/">Docutils</a> from <a class="reference external" href="http://docutils.sourceforge.net/rst.html">reStructuredText</a> source.
+
 </div>
 </body>
 </html>

Modified: trunk/libs/graph/doc/write_graphml.rst
==============================================================================
--- trunk/libs/graph/doc/write_graphml.rst (original)
+++ trunk/libs/graph/doc/write_graphml.rst 2009-06-04 21:47:37 EDT (Thu, 04 Jun 2009)
@@ -29,7 +29,7 @@
                 const dynamic_properties& dp, bool ordered_vertices=false);
 
 This is to write a BGL graph object into an output stream in the
-graphml_ format. Both overloads of ``write_graphml`` will emit all of
+GraphML_ format. Both overloads of ``write_graphml`` will emit all of
 the properties stored in the dynamic_properties_ object, thereby
 retaining the properties that have been read in through the dual
 function read_graphml_. The second overload must be used when the
@@ -60,8 +60,8 @@
 
 
 IN: ``dynamic_properties& dp``
- Contains all of the vertex and edge properties that should be
- emitted by the graphml writer.
+ Contains all of the vertex, edge, and graph properties that should be
+ emitted by the GraphML writer.
 
 IN: ``bool ordered_vertices``
   This tells whether or not the order of the vertices from vertices(g)
@@ -74,8 +74,8 @@
 Example
 -------
 
-This example demonstrates using BGL-graphml interface to write
-a BGL graph into a graphml format file.
+This example demonstrates using BGL-GraphML interface to write
+a BGL graph into a GraphML format file.
 
 ::
 
@@ -137,7 +137,7 @@
 ::
 
   <?xml version="1.0" encoding="UTF-8"?>
- <graphml xmlns="http://graphml.graphdrawing.org/xmlns/graphml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns/graphml http://graphml.graphdrawing.org/xmlns/graphml/graphml-attributes-1.0rc.xsd">
+ <graphml xmlns="http://graphml.graphdrawing.org/xmlns/graphml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns/graphml http://graphml.graphdrawing.org/xmlns/graphml/graphml-attributes-1.0rc.xsd">
     <key id="key0" for="node" attr.name="name" attr.type="string" />
     <key id="key1" for="edge" attr.name="weight" attr.type="int" />
     <graph id="G" edgedefault="directed" parse.nodeids="canonical" parse.edgeids="canonical" parse.order="nodesfirst">
@@ -254,11 +254,10 @@
 Notes
 -----
 
- - Note that you can use graphml file write facilities without linking
+ - Note that you can use GraphML file write facilities without linking
    against the ``boost_graph`` library.
 
-.. _graphml: http://graphml.graphdrawing.org/
-
+.. _GraphML: http://graphml.graphdrawing.org/
 .. _dynamic_properties: ../../property_map/doc/dynamic_property_map.html
 .. _read_graphml: read_graphml.html
 .. _VertexListGraph: VertexListGraph.html

Modified: trunk/libs/graph/src/graphml.cpp
==============================================================================
--- trunk/libs/graph/src/graphml.cpp (original)
+++ trunk/libs/graph/src/graphml.cpp 2009-06-04 21:47:37 EDT (Thu, 04 Jun 2009)
@@ -12,7 +12,7 @@
 #include <boost/variant.hpp>
 #include <expat.h>
 #include <boost/graph/graphml.hpp>
-#include <string>
+#include <boost/algorithm/string/replace.hpp>
 
 using namespace boost;
 
@@ -25,31 +25,29 @@
     void run(std::istream& in)
     {
         const int buffer_size = 4096;
- XML_Parser parser = XML_ParserCreateNS(0,'|');
- XML_SetElementHandler(parser, &on_start_element, &on_end_element);
- XML_SetCharacterDataHandler(parser, &on_character_data);
- XML_SetUserData(parser, this);
+ m_parser = XML_ParserCreateNS(0,'|');
+ XML_SetElementHandler(m_parser, &on_start_element, &on_end_element);
+ XML_SetCharacterDataHandler(m_parser, &on_character_data);
+ XML_SetUserData(m_parser, this);
         char buffer[buffer_size];
 
         bool okay = true;
         do
         {
- in.read(buffer, buffer_size);
-
- okay = XML_Parse(parser, buffer, in.gcount(), in.gcount() == 0);
+ in.read(buffer, buffer_size);
+ okay = XML_Parse(m_parser, buffer, in.gcount(), in.gcount() == 0);
         }
         while (okay && in.good());
 
         if (!okay)
         {
             std::stringstream s;
- s << "Parse error: " << XML_ErrorString(XML_GetErrorCode(parser))
- << " on line " << XML_GetCurrentLineNumber(parser)
- <<", column " << XML_GetCurrentColumnNumber(parser);
- XML_ParserFree(parser);
+ s << "on line " << XML_GetCurrentLineNumber(m_parser)
+ <<", column " << XML_GetCurrentColumnNumber(m_parser)
+ << ": " << XML_ErrorString(XML_GetErrorCode(m_parser));
             throw parse_error(s.str());
         }
- XML_ParserFree(parser);
+ XML_ParserFree(m_parser);
     }
 
 private:
@@ -71,46 +69,36 @@
         graphml_reader* self = static_cast<graphml_reader*>(user_data);
 
         std::string name(c_name);
- std::string::size_type pos = name.find('|');
- if (pos != std::string::npos)
- name.erase(0, pos+1);
-
- if (name == "key")
+ replace_first(name, "http://graphml.graphdrawing.org/xmlns|", "");
+
+ if (name == "edge")
         {
             std::string id;
- std::string key_name;
- std::string key_type;
- key_kind kind = all_key;
-
+ std::string source, target;
             while (*atts)
             {
                 std::string name = *atts++;
                 std::string value = *atts++;
 
                 if (name == "id") id = value;
- else if (name == "attr.name") key_name = value;
- else if (name == "attr.type") key_type = value;
- else if (name == "for")
+ else if (name == "source") source = value;
+ else if (name == "target") target = value;
+ else if (name == "directed")
                 {
- if (value == "graph") kind = graph_key;
- else if (value == "node") kind = node_key;
- else if (value == "edge") kind = edge_key;
- else if (value == "hyperedge") kind = hyperedge_key;
- else if (value == "port") kind = port_key;
- else if (value == "endpoint") kind = endpoint_key;
- else if (value == "all") kind = all_key;
- else
+ bool edge_is_directed = (value == "directed");
+ if (edge_is_directed != self->m_g.is_directed())
                     {
- throw parse_error("unrecognized key kind '" + value + "'");
+ if (edge_is_directed)
+ throw directed_graph_error();
+ else
+ throw undirected_graph_error();
                     }
                 }
             }
 
- self->m_keys[id] = kind;
- self->m_key_name[id] = key_name;
- self->m_key_type[id] = key_type;
- self->m_active_key = id;
- }
+ self->m_active_descriptor = self->m_edge.size();
+ self->handle_edge(source, target);
+ }
         else if (name == "node")
         {
             std::string id;
@@ -126,33 +114,55 @@
             self->handle_vertex(id);
             self->m_active_descriptor = id;
         }
- else if (name == "edge")
+ else if (name == "data")
+ {
+ while (*atts)
+ {
+ std::string name = *atts++;
+ std::string value = *atts++;
+
+ if (name == "key") self->m_active_key = value;
+ }
+ }
+ else if (name == "key")
         {
             std::string id;
- std::string source, target;
+ std::string key_name;
+ std::string key_type;
+ key_kind kind = all_key;
+
             while (*atts)
             {
                 std::string name = *atts++;
                 std::string value = *atts++;
 
                 if (name == "id") id = value;
- else if (name == "source") source = value;
- else if (name == "target") target = value;
- else if (name == "directed")
+ else if (name == "attr.name") key_name = value;
+ else if (name == "attr.type") key_type = value;
+ else if (name == "for")
                 {
- bool edge_is_directed = (value == "directed");
- if (edge_is_directed != self->m_g.is_directed())
+ if (value == "graph") kind = graph_key;
+ else if (value == "node") kind = node_key;
+ else if (value == "edge") kind = edge_key;
+ else if (value == "hyperedge") kind = hyperedge_key;
+ else if (value == "port") kind = port_key;
+ else if (value == "endpoint") kind = endpoint_key;
+ else if (value == "all") kind = all_key;
+ else
                     {
- if (edge_is_directed)
- throw directed_graph_error();
- else
- throw undirected_graph_error();
+ std::stringstream s;
+ s << "on line " << XML_GetCurrentLineNumber(self->m_parser)
+ << ", column " << XML_GetCurrentColumnNumber(self->m_parser)
+ << ": unrecognized key kind '" << value << "'";
+ throw parse_error(s.str());
                     }
                 }
             }
 
- self->m_active_descriptor = self->m_edge.size();
- self->handle_edge(source, target);
+ self->m_keys[id] = kind;
+ self->m_key_name[id] = key_name;
+ self->m_key_type[id] = key_type;
+ self->m_active_key = id;
         }
         else if (name == "graph")
         {
@@ -179,16 +189,6 @@
             }
             self->m_active_descriptor = "";
         }
- else if (name == "data")
- {
- while (*atts)
- {
- std::string name = *atts++;
- std::string value = *atts++;
-
- if (name == "key") self->m_active_key = value;
- }
- }
 
         self->m_character_data.clear();
     }
@@ -199,9 +199,7 @@
         graphml_reader* self = static_cast<graphml_reader*>(user_data);
 
         std::string name(c_name);
- std::string::size_type pos = name.find('|');
- if (pos != std::string::npos)
- name.erase(0, pos+1);
+ replace_first(name, "http://graphml.graphdrawing.org/xmlns|", "");
 
         if (name == "data")
         {
@@ -237,7 +235,11 @@
             }
             catch (bad_lexical_cast)
             {
- throw parse_error("invalid vertex: " + v);
+ std::stringstream s;
+ s << "on line " << XML_GetCurrentLineNumber(m_parser)
+ << ", column " << XML_GetCurrentColumnNumber(m_parser)
+ << ": invalid vertex: " << v;
+ throw parse_error(s.str());
             }
             
             while(id >= m_canonical_vertex.size())
@@ -310,16 +312,27 @@
 
     void handle_property(const std::string& key_id, const variant<std::string,size_t>& descriptor, const std::string& value)
     {
- if (get<std::string>(&descriptor))
+ try
         {
- if (get<std::string>(descriptor) == "")
- m_g.set_graph_property(m_key_name[key_id], value, m_key_type[key_id]);
+ if (get<std::string>(&descriptor))
+ {
+ if (get<std::string>(descriptor) == "")
+ m_g.set_graph_property(m_key_name[key_id], value, m_key_type[key_id]);
+ else
+ m_g.set_vertex_property(m_key_name[key_id], get_vertex_descriptor(get<std::string>(descriptor)), value, m_key_type[key_id]);
+ }
             else
- m_g.set_vertex_property(m_key_name[key_id], get_vertex_descriptor(get<std::string>(descriptor)), value, m_key_type[key_id]);
+ {
+ m_g.set_edge_property(m_key_name[key_id], get_edge_descriptor(get<size_t>(descriptor)), value, m_key_type[key_id]);
+ }
         }
- else
+ catch (parse_error &e)
         {
- m_g.set_edge_property(m_key_name[key_id], get_edge_descriptor(get<size_t>(descriptor)), value, m_key_type[key_id]);
+ std::stringstream s;
+ s << "on line " << XML_GetCurrentLineNumber(m_parser)
+ << ", column " << XML_GetCurrentColumnNumber(m_parser)
+ << ": " << e.error;
+ throw parse_error(s.str());
         }
     }
 
@@ -342,6 +355,7 @@
     std::string m_character_data;
     bool m_canonical_vertices;
     bool m_canonical_edges;
+ XML_Parser m_parser;
 };
 
 namespace boost


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