Boost C++ Libraries: Ticket #4843: GraphML parser broken https://svn.boost.org/trac10/ticket/4843 <p> Hi, </p> <p> First of all, thanks for the library, it's awesome. However, latest versions are not able to correctly parse graphML files. The GraphML standard states the following for the edge attributes: </p> <ul><li>id (optional) </li><li>directed (optional) </li><li>source (required) </li><li>target (required) </li><li>sourceport (optional) </li><li>targetport (optional) </li></ul><p> In trunk/libs/graph/src/graphml.cpp@63244: </p> <div class="wikipage" style="font-size: 80%"><p> We have: </p> <div class="wiki-code"><div class="code"><pre><span class="mi">90</span> <span class="nf">BOOST_FOREACH</span><span class="p">(</span><span class="k">const</span> <span class="n">ptree</span><span class="o">*</span> <span class="n">gr</span><span class="p">,</span> <span class="n">graphs</span><span class="p">)</span> <span class="p">{</span> <span class="mi">91</span> <span class="kt">bool</span> <span class="n">default_directed</span> <span class="o">=</span> <span class="n">gr</span><span class="o">-&gt;</span><span class="n">get</span><span class="o">&lt;</span><span class="n">std</span><span class="o">::</span><span class="n">string</span><span class="o">&gt;</span><span class="p">(</span><span class="n">path</span><span class="p">(</span><span class="s">&quot;&lt;xmlattr&gt;/edgedefault&quot;</span><span class="p">))</span> <span class="o">==</span> <span class="s">&quot;directed&quot;</span><span class="p">;</span> <span class="mi">92</span> <span class="c1">// Search for edges</span> <span class="mi">93</span> <span class="n">BOOST_FOREACH</span><span class="p">(</span><span class="k">const</span> <span class="n">ptree</span><span class="o">::</span><span class="n">value_type</span><span class="o">&amp;</span> <span class="n">edge</span><span class="p">,</span> <span class="o">*</span><span class="n">gr</span><span class="p">)</span> <span class="p">{</span> <span class="mi">94</span> <span class="k">if</span> <span class="p">(</span><span class="n">edge</span><span class="p">.</span><span class="n">first</span> <span class="o">!=</span> <span class="s">&quot;edge&quot;</span><span class="p">)</span> <span class="k">continue</span><span class="p">;</span> <span class="mi">95</span> <span class="n">std</span><span class="o">::</span><span class="n">string</span> <span class="n">id</span> <span class="o">=</span> <span class="n">edge</span><span class="p">.</span><span class="n">second</span><span class="p">.</span><span class="n">get</span><span class="o">&lt;</span><span class="n">std</span><span class="o">::</span><span class="n">string</span><span class="o">&gt;</span><span class="p">(</span><span class="n">path</span><span class="p">(</span><span class="s">&quot;&lt;xmlattr&gt;/id&quot;</span><span class="p">));</span> <span class="mi">96</span> <span class="n">std</span><span class="o">::</span><span class="n">string</span> <span class="n">source</span> <span class="o">=</span> <span class="n">edge</span><span class="p">.</span><span class="n">second</span><span class="p">.</span><span class="n">get</span><span class="o">&lt;</span><span class="n">std</span><span class="o">::</span><span class="n">string</span><span class="o">&gt;</span><span class="p">(</span><span class="n">path</span><span class="p">(</span><span class="s">&quot;&lt;xmlattr&gt;/source&quot;</span><span class="p">));</span> <span class="mi">97</span> <span class="n">std</span><span class="o">::</span><span class="n">string</span> <span class="n">target</span> <span class="o">=</span> <span class="n">edge</span><span class="p">.</span><span class="n">second</span><span class="p">.</span><span class="n">get</span><span class="o">&lt;</span><span class="n">std</span><span class="o">::</span><span class="n">string</span><span class="o">&gt;</span><span class="p">(</span><span class="n">path</span><span class="p">(</span><span class="s">&quot;&lt;xmlattr&gt;/target&quot;</span><span class="p">));</span> <span class="mi">98</span> <span class="n">std</span><span class="o">::</span><span class="n">string</span> <span class="n">local_directed</span> <span class="o">=</span> <span class="n">edge</span><span class="p">.</span><span class="n">second</span><span class="p">.</span><span class="n">get</span><span class="p">(</span><span class="n">path</span><span class="p">(</span><span class="s">&quot;&lt;xmlattr&gt;/directed&quot;</span><span class="p">),</span> <span class="s">&quot;&quot;</span><span class="p">);</span> <span class="mi">99</span> <span class="kt">bool</span> <span class="n">is_directed</span> <span class="o">=</span> <span class="p">(</span><span class="n">local_directed</span> <span class="o">==</span> <span class="s">&quot;&quot;</span> <span class="o">?</span> <span class="nl">default_directed</span> <span class="p">:</span> <span class="n">local_directed</span> <span class="o">==</span> <span class="s">&quot;true&quot;</span><span class="p">);</span> <span class="mi">100</span> <span class="k">if</span> <span class="p">(</span><span class="n">is_directed</span> <span class="o">!=</span> <span class="n">m_g</span><span class="p">.</span><span class="n">is_directed</span><span class="p">())</span> <span class="p">{</span> <span class="mi">101</span> <span class="k">if</span> <span class="p">(</span><span class="n">is_directed</span><span class="p">)</span> <span class="p">{</span> <span class="mi">102</span> <span class="n">BOOST_THROW_EXCEPTION</span><span class="p">(</span><span class="n">directed_graph_error</span><span class="p">());</span> <span class="mi">103</span> <span class="p">}</span> <span class="k">else</span> <span class="p">{</span> <span class="mi">104</span> <span class="n">BOOST_THROW_EXCEPTION</span><span class="p">(</span><span class="n">undirected_graph_error</span><span class="p">());</span> <span class="mi">105</span> <span class="p">}</span> <span class="mi">106</span> <span class="p">}</span> </pre></div></div></div><div class="wikipage" style="font-size: 80%"><p> Should be (look at line 95): </p> <div class="wiki-code"><div class="code"><pre><span class="mi">90</span> <span class="nf">BOOST_FOREACH</span><span class="p">(</span><span class="k">const</span> <span class="n">ptree</span><span class="o">*</span> <span class="n">gr</span><span class="p">,</span> <span class="n">graphs</span><span class="p">)</span> <span class="p">{</span> <span class="mi">91</span> <span class="kt">bool</span> <span class="n">default_directed</span> <span class="o">=</span> <span class="n">gr</span><span class="o">-&gt;</span><span class="n">get</span><span class="o">&lt;</span><span class="n">std</span><span class="o">::</span><span class="n">string</span><span class="o">&gt;</span><span class="p">(</span><span class="n">path</span><span class="p">(</span><span class="s">&quot;&lt;xmlattr&gt;/edgedefault&quot;</span><span class="p">))</span> <span class="o">==</span> <span class="s">&quot;directed&quot;</span><span class="p">;</span> <span class="mi">92</span> <span class="c1">// Search for edges</span> <span class="mi">93</span> <span class="n">BOOST_FOREACH</span><span class="p">(</span><span class="k">const</span> <span class="n">ptree</span><span class="o">::</span><span class="n">value_type</span><span class="o">&amp;</span> <span class="n">edge</span><span class="p">,</span> <span class="o">*</span><span class="n">gr</span><span class="p">)</span> <span class="p">{</span> <span class="mi">94</span> <span class="k">if</span> <span class="p">(</span><span class="n">edge</span><span class="p">.</span><span class="n">first</span> <span class="o">!=</span> <span class="s">&quot;edge&quot;</span><span class="p">)</span> <span class="k">continue</span><span class="p">;</span> <span class="mi">95</span> <span class="n">std</span><span class="o">::</span><span class="n">string</span> <span class="n">id</span> <span class="o">=</span> <span class="n">edge</span><span class="p">.</span><span class="n">second</span><span class="p">.</span><span class="n">get</span><span class="o">&lt;</span><span class="n">std</span><span class="o">::</span><span class="n">string</span><span class="o">&gt;</span><span class="p">(</span><span class="n">path</span><span class="p">(</span><span class="s">&quot;&lt;xmlattr&gt;/id&quot;</span><span class="p">),</span> <span class="s">&quot;&quot;</span><span class="p">);</span> <span class="mi">96</span> <span class="n">std</span><span class="o">::</span><span class="n">string</span> <span class="n">source</span> <span class="o">=</span> <span class="n">edge</span><span class="p">.</span><span class="n">second</span><span class="p">.</span><span class="n">get</span><span class="o">&lt;</span><span class="n">std</span><span class="o">::</span><span class="n">string</span><span class="o">&gt;</span><span class="p">(</span><span class="n">path</span><span class="p">(</span><span class="s">&quot;&lt;xmlattr&gt;/source&quot;</span><span class="p">));</span> <span class="mi">97</span> <span class="n">std</span><span class="o">::</span><span class="n">string</span> <span class="n">target</span> <span class="o">=</span> <span class="n">edge</span><span class="p">.</span><span class="n">second</span><span class="p">.</span><span class="n">get</span><span class="o">&lt;</span><span class="n">std</span><span class="o">::</span><span class="n">string</span><span class="o">&gt;</span><span class="p">(</span><span class="n">path</span><span class="p">(</span><span class="s">&quot;&lt;xmlattr&gt;/target&quot;</span><span class="p">));</span> <span class="mi">98</span> <span class="n">std</span><span class="o">::</span><span class="n">string</span> <span class="n">local_directed</span> <span class="o">=</span> <span class="n">edge</span><span class="p">.</span><span class="n">second</span><span class="p">.</span><span class="n">get</span><span class="p">(</span><span class="n">path</span><span class="p">(</span><span class="s">&quot;&lt;xmlattr&gt;/directed&quot;</span><span class="p">),</span> <span class="s">&quot;&quot;</span><span class="p">);</span> <span class="mi">99</span> <span class="kt">bool</span> <span class="n">is_directed</span> <span class="o">=</span> <span class="p">(</span><span class="n">local_directed</span> <span class="o">==</span> <span class="s">&quot;&quot;</span> <span class="o">?</span> <span class="nl">default_directed</span> <span class="p">:</span> <span class="n">local_directed</span> <span class="o">==</span> <span class="s">&quot;true&quot;</span><span class="p">);</span> <span class="mi">100</span> <span class="k">if</span> <span class="p">(</span><span class="n">is_directed</span> <span class="o">!=</span> <span class="n">m_g</span><span class="p">.</span><span class="n">is_directed</span><span class="p">())</span> <span class="p">{</span> <span class="mi">101</span> <span class="k">if</span> <span class="p">(</span><span class="n">is_directed</span><span class="p">)</span> <span class="p">{</span> <span class="mi">102</span> <span class="n">BOOST_THROW_EXCEPTION</span><span class="p">(</span><span class="n">directed_graph_error</span><span class="p">());</span> <span class="mi">103</span> <span class="p">}</span> <span class="k">else</span> <span class="p">{</span> <span class="mi">104</span> <span class="n">BOOST_THROW_EXCEPTION</span><span class="p">(</span><span class="n">undirected_graph_error</span><span class="p">());</span> <span class="mi">105</span> <span class="p">}</span> <span class="mi">106</span> <span class="p">}</span> </pre></div></div></div> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/4843 Trac 1.4.3 Jeremiah Willcock Fri, 12 Nov 2010 15:34:25 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/4843#comment:1 https://svn.boost.org/trac10/ticket/4843#comment:1 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/66528" title="Removed access to (unused) edge id attribute, also making that ...">[66528]</a>) Removed access to (unused) edge id attribute, also making that attribute optional; fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/4843" title="#4843: Bugs: GraphML parser broken (closed: fixed)">#4843</a> </p> Ticket