Opened 13 years ago

Closed 13 years ago

#3972 closed Bugs (fixed)

Broken support for unordered sets and multisets in adjacency_list graphs

Reported by: Thomas Claveirole <thomas@…> Owned by: Jeremiah Willcock
Milestone: Boost 1.43.0 Component: graph
Version: Boost Development Trunk Severity: Problem
Keywords: graph adjacency_list unordered unordered_set unordered_multiset Cc: i@…

Description

Hello,

The support for adjacency_list graphs using unordered sets and multisets is currently broken. I will attach a patch that solves this issues in this report.

Basically, several compounds are missing and there is a bug in edge_range(). Here is a detailed description of the issue:

  • Container traits

container_traits, container_category, and iterator_stability specializations and overrides are missing for unordered_multiset and unordered_multimap, in pending/container_traits.hpp.

  • parallel_edge_traits

parallel_edge_traits specializations are missing for hash_multisetS and hash_multimapS, in graph/adjacency_list.hpp.

  • edge_range

edge_range() uses std::equal_range() on the node's out edge list. std::equal_range() expects its input to be ordered in ascending order. This precondition fails when using an unordered set or multiset for storing the edges.

As a solution, the proposed patch uses std::equal_range() by default, except on associative containers, for which it uses the container's equal_range() method (the equal_range() method is a requirement of associative containers).

Regards, Thomas Claveirole

Attachments (5)

unordered-adjacency_list.patch (5.5 KB ) - added by Thomas Claveirole <thomas@…> 13 years ago.
Patch that solves the described issue.
unordered-adjacency_list.2.patch (5.6 KB ) - added by Thomas Claveirole <thomas@…> 13 years ago.
Sorry, the previous patch has a minor bug. This one is correct.
unordered-adjacency_list.3.patch (5.7 KB ) - added by Thomas Claveirole <thomas@…> 13 years ago.
Same as unordered-adjacency_list.2.patch with updated copyright notices.
unordered_equal_range_dispatch.patch (4.5 KB ) - added by Ignacy Gawedzki <i@…> 13 years ago.
Fix equal_range dispatch and container categories
unordered_equal_range_dispatch.2.patch (4.6 KB ) - added by i@… 13 years ago.
Corrected copyright lines.

Download all attachments as: .zip

Change History (12)

by Thomas Claveirole <thomas@…>, 13 years ago

Patch that solves the described issue.

by Thomas Claveirole <thomas@…>, 13 years ago

Sorry, the previous patch has a minor bug. This one is correct.

in reply to:  description ; comment:1 by Jeremiah Willcock, 13 years ago

Owner: changed from Andrew Sutton to Jeremiah Willcock
Status: newassigned

I agree with your bug. Could you please change the copyright message to you, though, since your patch adds so much code? With that I think I can apply it soon.

by Thomas Claveirole <thomas@…>, 13 years ago

Same as unordered-adjacency_list.2.patch with updated copyright notices.

in reply to:  1 comment:2 by Thomas Claveirole <thomas@…>, 13 years ago

Replying to jewillco:

Could you please change the copyright message to you, though, since your patch adds so much code?

Sure. Here is a new patch. It adds a copyright line with my name and current year. Is this OK, or should I rather modify the existing lines?

comment:3 by Jeremiah Willcock, 13 years ago

Resolution: fixed
Status: assignedclosed

(In [60198]) Added in container_traits and adjacency_list patches to fix unordered container issues (patch from #3972); fixes #3972

comment:4 by Jeremiah Willcock, 13 years ago

This should be fixed now -- I moved the equal_range stuff to container_traits, and it turns out that the iterators are actually unstable, not stable as was in the patch.

by Ignacy Gawedzki <i@…>, 13 years ago

Fix equal_range dispatch and container categories

comment:5 by Ignacy Gawedzki <i@…>, 13 years ago

Cc: i@… added
Resolution: fixed
Status: closedreopened

The actual dispatch functions for equal_range, as per r60698, don't work as expected. As a result std::equal_range is always used. The default dispatch function should take a container_tag as argument and not a template parameter, since the latter always takes precedence.

Besides, unordered_{set,multiset,map,multimap} should have their own tags which aren't subclasses of sorter_associative_container_tag.

The attached patch corrects those two issues.

comment:6 by Jeremiah Willcock, 13 years ago

Could you please add a copyright notice with your name at the top of the file (i.e., rebuild your patch with that change) rather than updating the year on the existing notice? I should be able to apply your patch after that. Thank you.

by i@…, 13 years ago

Corrected copyright lines.

comment:7 by Jeremiah Willcock, 13 years ago

Resolution: fixed
Status: reopenedclosed

(In [60999]) Applied another patch (unordered_equal_range_dispatch.2.patch) from #3972; fixes #3972

Note: See TracTickets for help on using tickets.