1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161
|
<?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">
<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/" />
<title>Boost read_graphml</title>
<link rel="stylesheet" href="default.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">
<pre class="literal-block">
void read_graphml(std::istream& in, MutableGraph& graph,
dynamic_properties& 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
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>
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
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>
<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>
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>
<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>
</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"><boost/graph/graphml.hpp></span></tt></p>
</div>
<div class="section" id="exceptions">
<h1><a class="toc-backref" href="#id3" name="exceptions">Exceptions</a></h1>
<pre class="literal-block">
struct graph_exception : public std::exception {
virtual ~graph_exception() throw();
virtual const char* what() const throw() = 0;
};
struct bad_parallel_edge : public graph_exception {
std::string from;
std::string to;
bad_parallel_edge(const std::string&, const std::string&);
virtual ~bad_parallel_edge() throw();
const char* what() const throw();
};
struct directed_graph_error : public graph_exception {
virtual ~directed_graph_error() throw();
virtual const char* what() const throw();
};
struct undirected_graph_error : public graph_exception {
virtual ~undirected_graph_error() throw();
virtual const char* what() const throw();
};
struct parse_error : public graph_exception {
parse_error(const std::string&);
virtual ~parse_error() throw() {}
virtual const char* what() const throw();
std::string statement;
};
</pre>
<p>Under certain circumstances, <tt class="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
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
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
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<setS,vecS></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="directed"</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="undirected"</span></tt>
graph attribute in the graphml format.</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 "bgl-graphml" 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>
</div>
<div class="section" id="notes">
<h1><a class="toc-backref" href="#id5" name="notes">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
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
constructible.</strong></li>
<li>Nested graphs are supported as long as they are exactly of the same
type as the root graph, i.e., are also directed or undirected. Note
that since nested graphs are not directly supported by BGL, they
are in fact completely ignored when building the graph, and the
internal vertices or edges are interpreted as belonging to the root
graph.</li>
<li>Hyperedges and Ports are not supported.</li>
</ul>
</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>
</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.
</div>
</body>
</html>
|