Network Types and Interface
Networks in Erdos.jl are graphs with additional ability to store properties associated to vertices, edges and the graph itself. The ready to go network types are the Network
and DiNetwork
types. Custom types con be defined inheriting from ANetwork
and ADiNetwork
abstract types.
Abstract Types
#
Erdos.ANetwork
— Type.
abstract type ANetwork <: AGraph end
An abstract graph with the additional possibility to attach properties to vertices and edges.
#
Erdos.ADiNetwork
— Type.
abstract type ADiNetwork <: ADiGraph end
An abstract directed graph with the additional possibility to attach properties to vertices and edges.
#
Erdos.AIndexedEdge
— Type.
abstract type AIndexedEdge <: AEdge end
Edge types with unique indexes, accessed by idx
Network / DiNetwork / IndexedEdge
#
Erdos.Network
— Type.
mutable struct Network <: ANetwork
ne::Int
edge_index_range::Int
out_edges::Vector{Vector{Pair{Int,Int}}} #unordered adjlist
epos::Vector{Pair{Int,Int}} # position of the edge in out_edges
free_indexes::Vector{Int} # indexes of deleted edges to be used up
# for new edges to avoid very large
# indexes, and unnecessary property map
# memory used
props::PropertyStore
end
A type representing a directed graph with indexed edges.
Network(n=0)
Construct a Network
with n
vertices and no edges.
Network(adjmx::AbstractMatrix; selfedges=true, upper=false)
Construct a Network
from the adjacency matrix adjmx
, placing an edge in correspondence to each nonzero element of adjmx
. If selfedges=false
the diagonal elements of adjmx
are ignored. If upper=true
only the upper triangular part of adjmx
is considered.
#
Erdos.DiNetwork
— Type.
mutable struct DiNetwork <: ADiNetwork
ne::Int
edge_index_range::Int
out_edges::Vector{Vector{Pair{Int,Int}}} #unordered out_adjlist
in_edges::Vector{Vector{Pair{Int,Int}}} #unordered in_adjlist
epos::Vector{Pair{Int,Int}} # position of the edge in out_edges
# the first in the pair is the vertex
# with lower index
free_indexes::Vector{Int} # indexes of deleted edges to be used up
# for new edges to avoid very large
# indexes, and unnecessary property map
# memory use
props::PropertyStore
end
A type representing an directed graph with indexed edges.
DiNetwork(n=0)
Construct a DiNetwork
with n
vertices and no edges.
DiNetwork(adjmx::AbstractMatrix; selfedges=true)
Construct a DiNetwork
from the adjacency matrix adjmx
. If selfedges=false
the diagonal elements of adjmx
are ignored.
#
Erdos.IndexedEdge
— Type.
struct IndexedEdge <: AIndexedEdge
src::Int
dst::Int
idx::Int
end
An indexed edge type
IndexedEdge(u, v) = IndexedEdge(u,v,-1)
Creates an edge with invalid index.
Defining new network types
In order to define a custom network type, e.g. MyNet <: ANetwork
, the corresponding methods in the preceding paragraph 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.