Skip to content
This repository was archived by the owner on Oct 8, 2021. It is now read-only.
This repository was archived by the owner on Oct 8, 2021. It is now read-only.

add_vertex! fails if setting multiple indexing properties using a Dict #122

@hdavid16

Description

@hdavid16

If I have 2 indexing properties, I cannot set their values when creating a vertex using a Dict. However, I can set their values separately. Why is this not allowed? I'm happy to put together a PR changing this behavior.

Trying to set indexing prop values using Dict:

g = MetaGraph()
set_indexing_prop!(g,:idx1)
set_indexing_prop!(g,:idx2)
add_vertex!(g, Dict(:idx1 => :a, :idx2 => :b))

ERROR: The following properties are indexing_props and cannot be updated: Set([:idx1, :idx2])
Stacktrace:
 [1] error(s::String)
   @ Base .\error.jl:33
 [2] set_props!(g::MetaGraph{Int64, Float64}, v::Int64, d::Dict{Symbol, Symbol})
   @ MetaGraphs C:\Users\HD\.julia\packages\MetaGraphs\NpVqv\src\MetaGraphs.jl:293
 [3] add_vertex!(g::MetaGraph{Int64, Float64}, d::Dict{Symbol, Symbol})
   @ MetaGraphs C:\Users\HD\.julia\packages\MetaGraphs\NpVqv\src\MetaGraphs.jl:120
 [4] top-level scope
   @ REPL[24]:1

Setting indexing properties sequentially (no error):

g = MetaGraph()
set_indexing_prop!(g,:idx1)
set_indexing_prop!(g,:idx2)
add_vertex!(g, :idx1, :a)
set_prop!(g, 1, :idx2, :b)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions