[Boost-bugs] [Boost C++ Libraries] #4843: GraphML parser broken

Subject: [Boost-bugs] [Boost C++ Libraries] #4843: GraphML parser broken
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2010-11-12 09:36:02


#4843: GraphML parser broken
-----------------------------------------------------------+----------------
 Reporter: Alexandre Romana <alexandre.romana@…> | Owner: asutton
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: graph
  Version: Boost 1.44.0 | Severity: Problem
 Keywords: GraphML |
-----------------------------------------------------------+----------------
 Hi,

 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:

 * id (optional)
 * directed (optional)
 * source (required)
 * target (required)
 * sourceport (optional)
 * targetport (optional)

 In trunk/libs/graph/src/graphml.cpp_at_63244:

 {{{
 #!div style="font-size: 80%"
 We have:
   {{{#!C++
 90 BOOST_FOREACH(const ptree* gr, graphs) {
 91 bool default_directed =
 gr->get<std::string>(path("<xmlattr>/edgedefault")) == "directed";
 92 // Search for edges
 93 BOOST_FOREACH(const ptree::value_type& edge, *gr) {
 94 if (edge.first != "edge") continue;
 95 std::string id =
 edge.second.get<std::string>(path("<xmlattr>/id"));
 96 std::string source =
 edge.second.get<std::string>(path("<xmlattr>/source"));
 97 std::string target =
 edge.second.get<std::string>(path("<xmlattr>/target"));
 98 std::string local_directed =
 edge.second.get(path("<xmlattr>/directed"), "");
 99 bool is_directed = (local_directed == "" ?
 default_directed : local_directed == "true");
 100 if (is_directed != m_g.is_directed()) {
 101 if (is_directed) {
 102 BOOST_THROW_EXCEPTION(directed_graph_error());
 103 } else {
 104 BOOST_THROW_EXCEPTION(undirected_graph_error());
 105 }
 106 }
  }}}
 }}}

 {{{
 #!div style="font-size: 80%"
 Should be (look at line 95):
   {{{#!C++
 90 BOOST_FOREACH(const ptree* gr, graphs) {
 91 bool default_directed =
 gr->get<std::string>(path("<xmlattr>/edgedefault")) == "directed";
 92 // Search for edges
 93 BOOST_FOREACH(const ptree::value_type& edge, *gr) {
 94 if (edge.first != "edge") continue;
 95 std::string id =
 edge.second.get<std::string>(path("<xmlattr>/id"), "");
 96 std::string source =
 edge.second.get<std::string>(path("<xmlattr>/source"));
 97 std::string target =
 edge.second.get<std::string>(path("<xmlattr>/target"));
 98 std::string local_directed =
 edge.second.get(path("<xmlattr>/directed"), "");
 99 bool is_directed = (local_directed == "" ?
 default_directed : local_directed == "true");
 100 if (is_directed != m_g.is_directed()) {
 101 if (is_directed) {
 102 BOOST_THROW_EXCEPTION(directed_graph_error());
 103 } else {
 104 BOOST_THROW_EXCEPTION(undirected_graph_error());
 105 }
 106 }
  }}}
 }}}

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/4843>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:04 UTC