Modify

Ticket #4843 (closed Bugs: fixed)

Opened 3 years ago

Last modified 3 years ago

GraphML parser broken

Reported by: Alexandre Romana <alexandre.romana@…> Owned by: asutton
Milestone: To Be Determined Component: graph
Version: Boost 1.44.0 Severity: Problem
Keywords: GraphML Cc:

Description

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@63244:

We have:

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               }

Should be (look at line 95):

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               }

Attachments

Change History

comment:1 Changed 3 years ago by jewillco

  • Status changed from new to closed
  • Resolution set to fixed

(In [66528]) Removed access to (unused) edge id attribute, also making that attribute optional; fixes #4843

View

Add a comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
The resolution will be deleted. Next status will be 'reopened'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.