Skip to content

labeled_graph::remove_vertex does not remove label #167

Closed

Description

@arneboe

When calling remove_vertex on a labeled_graph the vertex is removed but the label is not.
A dangling reference to the vertex is left behind. Accessing it causes segfaults.

Minimal example:

#include <iostream>
#include <string>

#include <boost/graph/directed_graph.hpp>
#include <boost/graph/labeled_graph.hpp>

using namespace boost;
using namespace std;

int main() {

    using namespace boost::graph_detail;
    typedef directed_graph<> Digraph;
    typedef labeled_graph<Digraph, string> Graph;
    
    Graph g;
    g.add_vertex("foo");
    
    auto v = g.vertex("foo");
    if(v != nullptr)
        cout << "foo exists\n";
    
    g.remove_vertex("foo");
    
    auto v2 = g.vertex("foo");
    if(v2 != nullptr)
        std::cout << " BUG! vertex label still exists.\n";


    return 0;
}

Activity

  1. anadon commented on Apr 17, 2019

    @anadon
    Contributor

    @jzmaddock Hey, this looks like a good one for me to work on.

  2. jzmaddock commented on Apr 17, 2019

    @jzmaddock
    Contributor

    Go for it!

  3. anadon commented on Apr 17, 2019

    @anadon
    Contributor

    @arneboe Can I get your full name and email, since what you submitted is what I'm basing the regression test on? I need to credit you.

  4. arneboe commented on Apr 18, 2019

    @arneboe
    ContributorAuthor

    I dont care about the credit, but if you have to: Arne Böckmann

  5. anadon commented on Apr 18, 2019

    @anadon
    Contributor

    It looks like the intended design, given the state of BGL, is to have _map a protected member, not a private member. So you hack was less of a hack than was expected.

  6. anadon commented on Apr 18, 2019

    @anadon
    Contributor
  7. anadon commented on Apr 18, 2019

    @anadon
    Contributor
  8. anadon commented on Apr 24, 2019

    @anadon
    Contributor

    This is going to be delayed somewhat. There are general cleanups in testing which I need to do first.

  9. HWiese1980 commented on Apr 24, 2019

    @HWiese1980

    Sure, take your time! Better have it fixed correctly and thoroughly, than to rush it and only come up with some quick'n'dirty patch that fails somewhere else.

  10. anadon commented on Jul 11, 2019

    @anadon
    Contributor

    Just an update, had to move twice, once across states, and started a new job. Getting back to this more now.

  11. HWiese1980 commented on Jul 24, 2019

    @HWiese1980

    Alright, no pressure. Just don't forget it ;-)

  12. fjch1997 commented on Jul 29, 2022

    @fjch1997

    And... it was forgotten
    This bug really tripped me up when I tried to use labeled_graph

  13. HWiese1980 commented on Jul 30, 2022

    @HWiese1980

    As it seems... @anadon how's it going?

  14. jeremy-murphy commented on Aug 1, 2022

    @jeremy-murphy
    Collaborator

    Not sure if they are still active on Boost.Graph, but if someone submits a pull request to fix this issue, I can help them get it polished and merge it.

  15. EGRCel commented on Jun 29, 2023

    @EGRCel

    Hey there, any update on it? @anadon by any chance do you still have your WIP PR that people can pick up from?

  16. DeuceBox commented on Jun 30, 2023

    @DeuceBox

    This may be related:

    There was a patch at https://svn.boost.org/trac/boost/ticket/9493 (I did not create it) which is no longer reachable, but I've been using it in production for years

    I've preserved it here:
    DeuceBox@de651cb

    It appears to fix the bug in the minimal example given in the OP.

  17. self-assigned this
    on Jul 7, 2023
  18. StahlTim commented on Nov 17, 2023

    @StahlTim

    @DeuceBox @jeremy-murphy
    Is there currently an active pull request introducing the fix referenced by @DeuceBox?

    Facing the same issue and would appreciate the fix being shipped with the stock boost library.

  19. DeuceBox commented on Nov 17, 2023

    @DeuceBox

    @StahlTim @jeremy-murphy since there wasn't any real discussion beyond the branch/fix I linked a while back, I've put in a PR.

  20. jeremy-murphy commented on Nov 18, 2023

    @jeremy-murphy
    Collaborator

    I'll prioritise merging in the fix asap.

  21. jeremy-murphy commented on Nov 28, 2023

    @jeremy-murphy
    Collaborator

    Could someone please check out the fix I just merged and test it? Thanks to @DeuceBox for making the PR.

  22. EGRCel commented on Jul 26, 2024

    @EGRCel

    Hi @jeremy-murphy, has this fix already been merged somewhere? I can't find it in the latest release

  23. DeuceBox commented on Jul 26, 2024

    @DeuceBox

    @EduardoGoulart1 It's merged here #354 in the "develop" branch. The boostorg/graph "develop" branch is what the boostorg/boost "master" branch references. However, the latest boostorg/boost release branch/tag (boost-1.85.0) references the corresponding release tag in boostorg/graph (https://github.com/boostorg/graph/releases/tag/boost-1.85.0), but it appears based on https://github.com/boostorg/graph/tags that the boostorg/graph repo's release tags haven't pointed to anything new since 2022.

    @jeremy-murphy could we get the next boostorg/graph release tag to reference a more recent version of develop? I don't know what's involved in that process.

  24. jeremy-murphy commented on Jul 27, 2024

    @jeremy-murphy
    Collaborator

    Thanks for pointing it out. That's about how long I've been maintainer for and I'm still learning what needs to be done! I assumed all that release tag business would be automatic from the super project.

  25. IamHuskar commented on Jul 3, 2025

    @IamHuskar

    Thanks for pointing it out. That's about how long I've been maintainer for and I'm still learning what needs to be done! I assumed all that release tag business would be automatic from the super project.

    still have some bugs with graph vertex type boost:vecS
    when remove a vertex in _graph . the index in _graph has been changed after remove . but _map still hold the old value

  26. Becheler commented on Mar 30, 2026

    @Becheler
    Collaborator

    Just to drop in and mention I began to work on this. The test suite seems quite incomplete and I will first try to have better coverage of possible bugs before fixing anything 😄

  27. Becheler commented on May 14, 2026

    @Becheler
    Collaborator

    Hi people,

    After looking into it, it looks like a serpent nest: both labeled_graph and named_graph are incomplete and/or broken, and their implementation is problematic in multiple aspects (for example named_graph is a bit of a wart on adjacency_list: it's mixed in as a base class and drags in Boost.MultiIndex unconditionally, even for users who never touch named lookup)

    Fixes are not trivial, so I provided an umbrella issue aiming at solving all of this at once #465 .
    I will close this issues as it's being superseded by the umbrella issue.
    Thanks again guys for this helpful discussion and analysis ❤️

  28. added theissue type on May 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions