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)

source

# 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.

source

# Erdos.edge_propertyMethod.

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.

source

# Erdos.epropFunction.

See edge_property

source

# Erdos.eprop!Function.

See add_edge_property!

source

# Erdos.gpropFunction.

See graph_property

source

# Erdos.gprop!Function.

See set_graph_property!

source

# Erdos.graph_propertyMethod.

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.

source

# Erdos.has_edge_propertyMethod.

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.

source

# Erdos.has_epropFunction.

See has_edge_property

source

# Erdos.has_gpropFunction.

See has_graph_property

source

# Erdos.has_graph_propertyMethod.

has_graph_property(g, name)

Check if network g has a graph property named name.

has_gprop is the short form of this function.

source

# Erdos.has_vertex_propertyMethod.

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.

source

# Erdos.has_vpropFunction.

See has_vertex_property

source

# Erdos.idxMethod.

idx(e::AIndexedEdge)

Returns the index of edge e.

source

# 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.

source

# Erdos.rem_eprop!Function.

See rem_edge_property!

source

# Erdos.rem_gprop!Function.

See rem_graph_property!

source

# 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.

source

# 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.

source

# Erdos.rem_vprop!Function.

See rem_vertex_property!

source

# 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")

source

# Erdos.vertex_propertyMethod.

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.

source

# Erdos.vpropFunction.

See vertex_property

source

# Erdos.vprop!Function.

See add_vertex_property!

source

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.