Closed CameronBieganek closed 4 years ago
Taking a broader view, it might also be nice to be able to do things like this:
julia> mg.label["vertex2"].color = "blue" # setproperty!
"blue"
julia> mg.label["vertex2"].color # getproperty
"blue"
And then if one needed to retrieve the underlying integer vertex ID, perhaps something like the following:
julia> mg.label["vertex2"].id
2
Right now it appears that you can have multiple custom indexes. I don't do enough graph computing to know whether or not that's a feature that people need. If only one custom index was allowed, then we could have the following hypothetical API:
mg = MetaGraph(path_graph(3))
# getindex() with an Int uses the primitive index.
for i in vertices(mg)
mg[i].label = "id$i" # overloaded setproperty!() is used here.
end
set_index_prop!(mg, :label)
add_edge!(mg, mg["id1"], mg["id2"]) # indexing with non-Int uses the custom index.
Or something like that.... The design details require some thought.
What happens if the indexed property is an integer?
Darn it, I was trying to avoid that question. :)
Superseded by https://github.com/JuliaGraphs/MetaGraphsNext.jl
Would it be possible to overload
getproperty
so that a meta graph vertex can be accessed using the.
property-access syntax? For example, if I have an index calledlabel
, I could do something like the following to get the vertex number:instead of the current syntax:
I think the current syntax is confusing, because it looks like you're trying to index a 2D object like a matrix or a data frame.