Skip to content

Check label uniqueness before inserting vertex #21

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
gdalle opened this issue Nov 25, 2021 · 5 comments
Closed

Check label uniqueness before inserting vertex #21

gdalle opened this issue Nov 25, 2021 · 5 comments
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@gdalle
Copy link
Member

gdalle commented Nov 25, 2021

Do we do that? I don't think so

@gdalle gdalle added bug Something isn't working good first issue Good for newcomers labels Nov 29, 2021
@pthpth
Copy link
Contributor

pthpth commented Dec 1, 2021

"""
    add_vertex!(g, label, val)

Add a vertex to MetaGraph `g` with label `label` having value `val`.

Return true if the vertex has been added, false incase the label already exists or vertex was not added.
"""
function add_vertex!(g::MetaGraph, label, val)
    if g.haskey(label)
        return false
    added = add_vertex!(g.graph)
    if added
        v = nv(g)
        g.vprops[label] = (v, val)
        g.metaindex[v] = label
    end
    added
end

Changing the addvertex! function to this

@gdalle
Copy link
Member Author

gdalle commented Dec 1, 2021

Thanks @DarkLord0206, that looks about right! Do you want to prepare a pull request with this change and the relevant tests?

@pthpth
Copy link
Contributor

pthpth commented Dec 1, 2021

Yes. I will do the same.

@gdalle
Copy link
Member Author

gdalle commented Dec 1, 2021

Nice! If you need help feel free to ping me

@pthpth
Copy link
Contributor

pthpth commented Dec 2, 2021

#24 is the PR for the following issue. Please accept it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants