Network Types and Interface
Networks in Erdos are graphs with additional ability to store internally properties associated to vertices, edges and the graph itself. Edge and vertex properties are nothing else than edge and vertex maps with a name associated to them. Erdos defines some interface methods (and their convenient short form equivalent) to work with networks and properties.
Property Interface
#
Erdos.add_edge_property!
— Method.
add_edge_property!(g, name, T)
add_edge_property!(g, name, emap)
Add the edge property name
to g
.
If a type T
is given as an input, an edge map with valtype T
is created and stored into g
.
As an alternative, an existing edge map emap
can be stored into g
.
eprop!
is the short form of this function.
Example
g = random_regular_graph(10, 3, Network)
add_edge_property!(g, "weight", Float64)
# or equivalently
eprop!(g, "weight", Float64)
#
Erdos.add_vertex_property!
— Method.
add_vertex_property!(g, name, T)
add_vertex_property!(g, name, vmap)
Add the vertex property name
to g
.
If a type T
is given as an input, a vertex map with valtype T
is created and stored into g
.
As an alternative, an existing vertex map vmap
can be stored into g
.
vprop!
is the short form of this function.
#
Erdos.edge_property
— Method.
edge_property(g, name)
Return an edge map corresponding to property name
of edges in g
.
edge_property(g)
Returns a dictionary with elements property_name => edge_map
.
edge_property(g, e)
Returns a dictionary of the form name => val
containing all the properties associated to edge e
.
eprop
is the short form of this function.
#
Erdos.eprop
— Function.
See edge_property
#
Erdos.eprop!
— Function.
#
Erdos.gprop
— Function.
See graph_property
#
Erdos.gprop!
— Function.
#
Erdos.graph_property
— Method.
graph_property(g, name)
Return the property name
of g
.
graph_property(g)
Returns a dictionary with elements property_name => property_value
gprop
is the short form of this function.
#
Erdos.has_edge_property
— Method.
has_edge_property(g, name)
has_edge_property(g, name, e)
Check if network g
has an edge property named name
. The second method checks also if edge e
has an assigned value for that property.
has_eprop
is the short form of this function.
#
Erdos.has_eprop
— Function.
#
Erdos.has_gprop
— Function.
#
Erdos.has_graph_property
— Method.
has_graph_property(g, name)
Check if network g
has a graph property named name
.
has_gprop
is the short form of this function.
#
Erdos.has_vertex_property
— Method.
has_vertex_property(g, name, v)
Check if network g
has a vertex property named name
. The second method checks also if vertex v
has an assigned value for that property.
has_vprop
is the short form of this function.
#
Erdos.has_vprop
— Function.
#
Erdos.idx
— Method.
idx(e::AIndexedEdge)
Returns the index of edge e
.
#
Erdos.rem_edge_property!
— Method.
rem_edge_property!(g, name)
Remove the edge property name
from g
.
rem_eprop!
is the short form of this function.
#
Erdos.rem_eprop!
— Function.
#
Erdos.rem_gprop!
— Function.
#
Erdos.rem_graph_property!
— Method.
rem_graph_property!(g, name)
Remove the property name
from g
.
rem_gprop!
is the short form of this function.
#
Erdos.rem_vertex_property!
— Method.
rem_vertex_property!(g, name)
Remove the vertex property name
from g
.
rem_vprop!
is the short form of this function.
#
Erdos.rem_vprop!
— Function.
#
Erdos.set_graph_property!
— Method.
set_graph_property!(g, name, x)
Set the property name
to value x
to g
. Creates the property if it doesn't exist. gprop!
can be conveniently used as a short form of this function.
Example
g = Network(10, 20)
set_graph_property!(g, "label", "My Network")
# or equivalently
gprop!(g, "label", "My Network")
#
Erdos.vertex_property
— Method.
vertex_property(g, name)
Return an vertex map corresponding to property name
of vertices in g
.
vertex_property(g)
Returns a dictionary with elements property_name => vertex_map
.
vertex_property(g, v)
Returns a dictionary of the form name => val
containing all the properties associated to vertex v
.
#
Erdos.vprop
— Function.
See vertex_property
#
Erdos.vprop!
— Function.
Defining new network types
In order to define a custom network type, e.g. MyNet <: ANetwork
, the corresponding interface methods have to be implemented. This is automatically done for custom network types having a props::PropertyStore
member. Take a look to src/factory/net.jl
and src/maps/property_store.jl
for an example.