Vertex Metadata
Vertex Metadata
Graft supports the assignment of metadata to vertices, and adopts a tabular approach to storage. Vertex metadata is stored as an AbstractDataFrame
. The vertices internal identifiers are used to index the vertex table.
The following example demonstrates vertex metadata:
julia> using Graft julia> g = completegraph(10); julia> setlabel!(g, map(string, 1:10)); julia> # Create a new vertex property setvprop!(g, :, 1 : 10, :p1); julia> # Fetch an entire column from the vertex table getvprop(g, :, :p1) 10-element DataArrays.DataArray{Int64,1}: 1 2 3 4 5 6 7 8 9 10 julia> # Modify the property's value for a subset of the vertices setvprop!(g, 1:5, 5, :p1) 5 julia> # Fetch the property's value for a subset of the vertices getvprop(g, 1:5, :p1) 5-element DataArrays.DataArray{Int64,1}: 5 5 5 5 5 julia> # Create a new vertex property setvprop!(g, :, 1, :p2); julia> # List all vertex properties in the graph listvprops(g) 2-element Array{Symbol,1}: :p1 :p2 julia> # Display the vertex table V = VertexDescriptor(g) │ VertexID │ Labels │ p1 │ p2 │ ├──────────┼────────┼────┼────┤ │ 1 │ "1" │ 5 │ 1 │ │ 2 │ "2" │ 5 │ 1 │ │ 3 │ "3" │ 5 │ 1 │ │ 4 │ "4" │ 5 │ 1 │ │ 5 │ "5" │ 5 │ 1 │ │ 6 │ "6" │ 6 │ 1 │ │ 7 │ "7" │ 7 │ 1 │ │ 8 │ "8" │ 8 │ 1 │ │ 9 │ "9" │ 9 │ 1 │ │ 10 │ "10" │ 10 │ 1 │ Vertex 5 p1 => 5 p2 => 1 julia> # Examine a single labelled vertex V["5"]
Detailed documentation:
#
Graft.listvprops
— Function.
List the column headers in the vertex dataframe
#
Graft.hasvprop
— Function.
Check if the vertex dataframe has the input column
#
Graft.getvprop
— Function.
Retrieve vertex properties.
getvprop(g::Graph, v::VertexID, vprop::Symbol) -> Fetch the value of a property for vertex v
getvprop(g::Graph, vs::VertexList, vprop::Symbol) -> Fetch the value of a property for v in vs
getvprop(g::Graph, ::Colon, vprop::Symbol) -> Fetch the value of a property for all verices
#
Graft.setvprop!
— Function.
Set vertex properties.
setvprop!(g::Graph, v::VertexID, val(s), vprop::Symbol) -> Set a property for v
setvprop!(g::Graph, vs::VertexList, val(s), vprop::Symbol) -> Set a property for v in vs
setvprop!(g::Graph, ::Colon, val(s), vprop::Symbol) -> Set a property for all vertices in g