Edge and Vertex Maps
Arbitrary values can be associated to a graph's vertices and edges, and handed over to method's that necessitate them, thanks to the edge maps and vertex maps interfaces. Also, edge and vector maps can be internally stored in network types and accessed through the property interface.
Example usage:
# create a graph
g = erdos_renyi(10,0.1)
# assign random weights to each edge
weights = EdgeMap(g, e -> rand())
for e in edges(g)
# access map value
w = weights[e]
# or
i, j = e
w = weights[i,j]
.....
end
Edge Maps
#
Erdos.ConstEdgeMap
— Type.
struct ConstEdgeMap{T} <: SimpleEdgeMap{T}
val::T
end
A type representing a constant vector map. Any attempt to change the internal value, e.g. emap[u,v] = 4
, will fail silently.
#
Erdos.EdgeMap
— Type.
mutable struct EdgeMap{G <: AGraphOrDiGraph, T, D} <: AEdgeMap{T}
g::G
vtype::Type{T}
data::D
end
Type implementing an edge map. The underlying container data
can be a dictionary, a matrix or a vector (for graphs with indexed edges).
EdgeMap{T}(g, ::Type{T})
Returns a map that associates values of type T
to the vertices of graph g
. The underlying storage structures is chosen accordingly.
EdgeMap(g, data)
Construct a EdgeMap with data
as underlying storage. The storage type can be a matrix or an associative edg => val
type or a vector for graph with indexed edges.
EdgeMap(g, f)
Construct an edge map with value f(e)
for each e
in edges(g)
.
#
Erdos.edgemap2adjlist
— Method.
edgemap2adjlist(emap)
Returns a vector of vectors containing the values of the edge map emap
on graph g
following the same ordering of adjacency_list
(g)
.
Vertex Maps
Any AbstractVector{T}
or Dict{Int,T}
can be used as a vertex map.
#
Erdos.ConstVertexMap
— Type.
struct ConstVertexMap{T} <: AVertexMap{T}
val::T
end
A type representing a constant vector map. Any attempt to change the internal value, e.g. vm[1] = 4
, will fail silently.
#
Erdos.VertexMap
— Type.
mutable struct VertexMap{G <: AGraphOrDiGraph, T, D} <: AVertexMap{T}
g::G
vtype::Type{T}
data::D
end
Type implementing an edge map. The underlying container data
can be a dictionary or a vector.
VertexMap{T}(g, ::Type{T})
Returns a map that associates values of type T
to the vertices of graph g
. The underlying storage structures is chosen accordingly.
VertexMap(g, data)
Construct a VertexMap with data
as underlying storage.
VertexMap(g, f)
Construct a vertex map with value f(u)
for each u=1:nv(g)
.
PropertyStore
#
Erdos.PropertyStore
— Type.
mutable struct PropertyStore
gmaps::Dict{String, Any}
emaps::Dict{String,AEdgeMap}
vmaps::Dict{String,AVertexMap}
end
A type storing properties associated to networks.