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

rem_prop! and clear_props! on vertex leaves dangling metaindex #75

Open
DanBerge opened this issue Apr 11, 2019 · 1 comment
Open

rem_prop! and clear_props! on vertex leaves dangling metaindex #75

DanBerge opened this issue Apr 11, 2019 · 1 comment
Labels

Comments

@DanBerge
Copy link
Contributor

Neither rem_prop!(g, v, :prop) or clear_props!(g, v) clears associated metaindex. Should rem_prop! and clear_props! clear the associated metaindex?

julia> g=MetaGraph()
{0, 0} undirected Int64 metagraph with Float64 weights defined by :weight (default weight 1.0)

julia> set_indexing_prop!(g,:name)
Set(Symbol[:name])

julia> add_vertex!(g,:name,"Original Name")
true

julia> clear_props!(g,1)
Dict{Int64,Dict{Symbol,Any}} with 0 entries

julia> set_prop!(g,1,:name,"New Name")
Set(Symbol[:name])

julia> g["New Name",:name]
1

julia> g["Original Name",:name]
1

julia> g.vprops
Dict{Int64,Dict{Symbol,Any}} with 1 entry:
  1 => Dict{Symbol,Any}(:name=>"New Name")

julia> g.metaindex
Dict{Symbol,Dict{Any,Integer}} with 1 entry:
  :name => Dict{Any,Integer}("New Name"=>1,"Original Name"=>1)
julia> g=MetaGraph()
{0, 0} undirected Int64 metagraph with Float64 weights defined by :weight (default weight 1.0)

julia> set_indexing_prop!(g,:name)
Set(Symbol[:name])

julia> add_vertex!(g,:name,"Original Name")
true

julia> rem_prop!(g,1,:name)
Dict{Symbol,Any} with 0 entries

julia> set_prop!(g,1,:name,"New Name")
Set(Symbol[:name])

julia> g["New Name",:name]
1

julia> g["Original Name",:name]
1

julia> g.vprops
Dict{Int64,Dict{Symbol,Any}} with 1 entry:
  1 => Dict{Symbol,Any}(:name=>"New Name")

julia> g.metaindex
Dict{Symbol,Dict{Any,Integer}} with 1 entry:
  :name => Dict{Any,Integer}("New Name"=>1,"Original Name"=>1)
@sbromberger
Copy link
Owner

sbromberger commented Apr 11, 2019

Yes. I think we need to rewrite significant parts of the indexing code so that it integrates with existing set_prop! / set_props! functions.

As discussed in slack, I propose the following:

prop(g, ..., :prop)

returns the property :prop of a graph (no add'l args), a vertex (1 add'l arg), or an edge(2 add'l args).

props(..)

returns the properties of a graph (1 arg), a vertex (2 args), or an edge(3 args)

setprop!(...)

sets a property of a graph, vertex, or edge

make_index!(g, :prop)

makes :prop a vertex indexing property; requires that all vertices have :prop defined and unique.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants