Edge Metadata

Edge Metadata

Graft supports the assignment of metadata to vertices, and adopts a tabular approach to storage. Edge metadata is stored as an AbstractDataFrame. The adjacency matrix stores the row number for each edge, i.e. it serves as an edge to index map, or an index table to the edge metadata table.

The following example demonstrates edge metadata:

julia> using Graft

julia> g = completegraph(10);

julia> setlabel!(g, map(string, 1 : 10));

julia> eit = edges(g);

julia> # Create a new edge property
       seteprop!(g, :, 1 : 90, :p1);

julia> # Fetch an entire column from the vertex table
       geteprop(g, :, :p1)
90-element DataArrays.DataArray{Int64,1}:
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
  
 82
 83
 84
 85
 86
 87
 88
 89
 90

julia> # Modify the property's value for a subset of the vertices
       seteprop!(g, eit[1:5], 5, :p1)
5

julia> # Fetch the property's value for a subset of the vertices
       geteprop(g, eit[1:5], :p1)
5-element DataArrays.DataArray{Int64,1}:
 5
 5
 5
 5
 5

julia> # Create a new vertex property
       seteprop!(g, :, 1, :p2);

julia> # List all vertex properties in the graph
       listeprops(g)
2-element Array{Symbol,1}:
 :p1
 :p2

julia> # Display the edge table
       E = EdgeDescriptor(g)
 Index  Source  Target  p1  p2 
├───────┼────────┼────────┼────┼────┤
 1      "1"     "2"     5   1  
 2      "1"     "3"     5   1  
 3      "1"     "4"     5   1  
 4      "1"     "5"     5   1  
 5      "1"     "6"     5   1  
 6      "1"     "7"     6   1  
 7      "1"     "8"     7   1  
 8      "1"     "9"     8   1  

 82     "10"    "1"     82  1  
 83     "10"    "2"     83  1  
 84     "10"    "3"     84  1  
 85     "10"    "4"     85  1  
 86     "10"    "5"     86  1  
 87     "10"    "6"     87  1  
 88     "10"    "7"     88  1  
 89     "10"    "8"     89  1  
 90     "10"    "9"     90  1  

Edge 1 => 5
p1 => 5
p2 => 1
julia> # Examine a single labelled edge
       E["1", "5"]

Detailed documentation:

# Graft.listepropsFunction.

List the column headers of the edge dataframe

source

# Graft.hasepropFunction.

Check if the edge dataframe has the input edge property

source

# Graft.getepropFunction.

Retrieve edge properties.

geteprop(g::Graph, e::EdgeID, eprop::Symbol) -> Fetch the value of a property for edge e

source

geteprop(g::Graph, es::EdgeList, eprop::Symbol) -> Fetch the value of a property for edge e in es

source

geteprop(g::Graph, ::Colon, eprop::Symbol) -> Fetch the value of a property for all edges

source

# Graft.seteprop!Function.

Set edge properties.

seteprop!(g::Graph, e::EdgeID, val, eprop::Symbol) -> Set a property for an edge e

source

seteprop!(g::Graph, es::EdgeList, val(s), eprop::Symbol) -> Set a property for e in es

source

seteprop!(g::Graph, ::Colon, val(s), eprop::Symbol)

source