You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A multilayer graph is composed of *layers*, i.e. graphs whose vertices represent the same set of nodes (not all nodes need to be represented in every layer), and *interlayers*, i.e. the [bipartite graphs](https://en.wikipedia.org/wiki/Bipartite_graph) that connect vertices in two different layers. Vertices in a multilayer graph are represented using the [`MultilayerVertex`](@ref) struct, while nodes are represented using the [`Node`](@ref) struct.
24
24
25
-
[`MultilayerGraph`](@ref) and [`MultilayerDiGraph`](@ref) are fully-fledged [Graphs.jl](https://github.com/JuliaGraphs/Graphs.jl) extensions. Both structs are designed to allow for layers and interlayers of any type (as long as they are Graphs.jl extensions themselves) and to permit layers and interlayers of different types. However, it is required that all layers and interlayers in [`MultilayerGraph`](@ref) are undirected, and all layers and interlayers in [`MultilayerDiGraph`](@ref) are directed.
25
+
`MultilayerGraph` and `MultilayerDiGraph` are fully-fledged [Graphs.jl](https://github.com/JuliaGraphs/Graphs.jl) extensions. Both structs are designed to allow for layers and interlayers of any type (as long as they are Graphs.jl extensions themselves) and to permit layers and interlayers of different types. However, it is required that all layers and interlayers in `MultilayerGraph` are undirected, and all layers and interlayers in `MultilayerDiGraph` are directed.
26
26
27
-
[`MultilayerGraph`](@ref) and [`MultilayerDiGraph`](@ref) support the specification of vertex and edge metadata, provided that the underlying layer or interlayer also supports metadata.
27
+
`MultilayerGraph` and `MultilayerDiGraph` support the specification of vertex and edge metadata, provided that the underlying layer or interlayer also supports metadata.
28
28
29
29
## Installation
30
30
@@ -36,7 +36,7 @@ pkg> add MultilayerGraphs
36
36
37
37
## Tutorial
38
38
39
-
Here we illustrate how to define, handle and analyse a [`MultilayerGraph`](@ref) (the directed version is completely analogous).
39
+
Here we illustrate how to define, handle and analyse a `MultilayerGraph` (the directed version is completely analogous).
40
40
41
41
```julia
42
42
using Revise
@@ -56,7 +56,6 @@ const max_vertices = 7
56
56
const min_edges =1
57
57
const max_edges = max_vertices*(max_vertices-1)
58
58
const n_nodes = max_vertices
59
-
; #hide
60
59
```
61
60
62
61
Next we define nodes:
@@ -76,7 +75,7 @@ const all_nodes = [Node("node_$i") for i in 1:n_nodes]
76
75
Node("node_7")
77
76
```
78
77
79
-
And construct `MultilayerVertex`s from these nodes:
78
+
You may access (but not modify) the `id` of a `Node` via the [`id`](@ref) function. And construct `MultilayerVertex`s from these nodes:
80
79
81
80
```julia
82
81
## Convert nodes to multilayer vertices without metadata
Where `MV` is an alias for `MultilayerVertex`. The first field is the `Node` being represented, the second the (name of) the layer the vertex is represented in (here it is set to `nothing`, since these vertices are yet to be assigned), and the metadata associated to the vertex (no metadata are currently represented via an empty `NamedTuple`). `MultilayerVertex` metadata can be represented via a `Tuple` or a `NamedTuple` (see below for examples).
108
+
Where `MV` is an alias for `MultilayerVertex`. The first field is the `Node` being represented (accessible via the [`node`](@ref) function), the second the (name of) the layer the vertex is represented in ((accessible via the [`layer`](@ref) function), here it is set to `nothing`, since these vertices are yet to be assigned), and the metadata associated to the vertex ((accessible via the [`metadata`](@ref) function), no metadata are currently represented via an empty `NamedTuple`). `MultilayerVertex` metadata can be represented via a `Tuple` or a `NamedTuple` (see below for examples).
110
109
111
110
### Layers
112
111
@@ -155,7 +154,6 @@ function _get_srcmv_dstmv_layer(layer::Layer)
155
154
156
155
return mvs, src_mv, dst_mv
157
156
end
158
-
; #hide
159
157
```
160
158
161
159
We are now are ready to define some `Layer`s. Every type of graph from the Graphs.jl ecosystem may underlie a `Layer` (or an `Interlayer`). We will construct a few of them, each time with a different number of vertices and edges.
The API that inspects and modifies `Layer`s will be shown below together with that of `Interlayer`s, since they are usually the same. There are of course other constructors that you may discover by typing `?Layer` in the console.
211
208
212
209
### Interlayers
213
210
214
-
Now we turn to defining `Interlayer`s. Interlayers are the graphs containing all the edges between vertices is two distinct layers. As before, we need an utility to ease randomization:
211
+
Now we turn to defining [`Interlayer`](@ref)s. Interlayers are the graphs containing all the edges between vertices is two distinct layers. As before, we need an utility to ease randomization:
215
212
216
213
217
214
```julia
@@ -240,7 +237,6 @@ function rand_ne_interlayer(layer_1, layer_2)
240
237
_ne =rand(_nv:(_nv*(_nv-1)) ÷2 )
241
238
return _ne
242
239
end
243
-
; #hide
244
240
```
245
241
246
242
An `Interlayer` is constructed by passing its name, the two `Layer`s it should connect, and the other parameters just like the `Layer`'s constructor. The random constructor reads:
The `vertices` command would return an internal representation of the `MultilayerVertex`s. This method, together with others, serves to make `MultilayerGraphs.jl` compatible with the Graphs.jl ecosystem, but it is not meant to be called by the end user. It is, anyway, thought to be used by developers who wish to interface their packages with `MultilayerGraphs.jl` just as with other packages of the `Graphs.jl` ecosystem: a developer-oriented guide will be compiled if there is the need.
407
402
408
-
In the [API](@ref) page the intended usage of all methods (*end-user* or *developer*) is highlighted.
403
+
In the [API](@ref) page the intended usage of all methods ([End-User](@ref) or [Developer](@ref)) is highlighted.
409
404
410
-
To add a vertex, simply use [`add_vertex!`](@ref). Let us define a vertex with metadata to add. Since nodes may not be represented more than once in layers, we have to define a new node to:
405
+
To add a vertex, simply use [`add_vertex!(layer::Layer, mv::MultilayerVertex)`](@ref). Let us define a vertex with metadata to add. Since nodes may not be represented more than once in layers, we have to define a new node to:
Copy file name to clipboardExpand all lines: src/multilayerdigraph.jl
+7-16Lines changed: 7 additions & 16 deletions
Original file line number
Diff line number
Diff line change
@@ -2,24 +2,15 @@
2
2
MultilayerDiGraph{T, U, G <: AbstractGraph{T}} <: AbstractMultilayerGraph{T,U}
3
3
4
4
A concrete type that can represent a general multilayer graph. Its internal fields aren't meant to be modified by the user. Please prefer the provided API.
5
-
6
-
# FIELDS
7
-
8
-
- `layers::Vector{LayerDescriptor{T,U}}`: vector containing all the layers of the multilayer graph. Their underlying graphs must be all undirected.
9
-
- `interlayers::OrderedDict{Set{Symbol},InterlayerDescriptor{T,U}} `: the ordered dictionary containing all the interlayers of the multilayer graph. Their underlying graphs must be all undirected.
10
-
- `v_V_associations::Bijection{ T, <: MultilayerVertex}`: A Bijection from Bijections.jl that associates numeric vertices to `MultilayerVertex`s.
11
-
- `idx_N_associations::Bijection{ Int64 , Node}`: A Bijection from Bijections.jl that associates Int64 to `Node`s.
12
-
- `fadjlist::Vector{Vector{HalfEdge{ <: MultilayerVertex, <: Union{Nothing, U}}}}`: the forward adjacency list of the MultilayerDiGraph. It is a vector of vectors of [`HalfEdge`](@ref)s. Its i-th element are the[`HalfEdge`](@ref)s that originate from `v_V_associations[i]`.
13
-
- `v_metadata_dict::Dict{T, <: Union{ <: Tuple, <: NamedTuple}}`: A Dictionary that associates numeric vertices to their metadata
layers::Vector{LayerDescriptor{T,U}}# vector containing all the layers of the multilayer graph. Their underlying graphs must be all undirected.
8
+
interlayers::OrderedDict{Set{Symbol},InterlayerDescriptor{T,U}}# the ordered dictionary containing all the interlayers of the multilayer graph. Their underlying graphs must be all undirected.
9
+
v_V_associations::Bijection{ T, <: MultilayerVertex}# A Bijection from Bijections.jl that associates numeric vertices to `MultilayerVertex`s.
10
+
idx_N_associations::Bijection{ Int64 , Node}# A Bijection from Bijections.jl that associates Int64 to `Node`s.
11
+
fadjlist::Vector{Vector{HalfEdge{ <:MultilayerVertex, <:Union{Nothing, U}}}}# the forward adjacency list of the MultilayerDiGraph. It is a vector of vectors of `HalfEdge`s. Its i-th element are the `HalfEdge`s that originate from `v_V_associations[i]`.
12
+
badjlist::Vector{Vector{HalfEdge{ <:MultilayerVertex, <:Union{Nothing, U}}}}# the bacward adjacency list of the MultilayerDiGraph. It is a vector of vectors of `HalfEdge`s. Its i-th element are the `HalfEdge`s that insost on `v_V_associations[i]`.
13
+
v_metadata_dict::Dict{T, <: Union{ <: Tuple, <: NamedTuple}}# A Dictionary that associates numeric vertices to their metadata
Copy file name to clipboardExpand all lines: src/multilayergraph.jl
+6-15Lines changed: 6 additions & 15 deletions
Original file line number
Diff line number
Diff line change
@@ -2,23 +2,14 @@
2
2
MultilayerGraph{T, U, G <: AbstractGraph{T}} <: AbstractMultilayerGraph{T,U}
3
3
4
4
A concrete type that can represent a general multilayer graph. Its internal fields aren't meant to be modified by the user. Please prefer the provided API.
5
-
6
-
# FIELDS
7
-
8
-
- `layers::Vector{LayerDescriptor{T,U}}`: vector containing all the layers of the multilayer graph. Their underlying graphs must be all undirected.
9
-
- `interlayers::OrderedDict{Set{Symbol},InterlayerDescriptor{T,U}} `: the ordered dictionary containing all the interlayers of the multilayer graph. Their underlying graphs must be all undirected.
10
-
- `v_V_associations::Bijection{ T, <: MultilayerVertex}`: A Bijection from Bijections.jl that associates numeric vertices to `MultilayerVertex`s.
11
-
- `idx_N_associations::Bijection{ Int64 , Node}`: A Bijection from Bijections.jl that associates Int64 to `Node`s.
12
-
- `fadjlist::Vector{Vector{HalfEdge{ <: MultilayerVertex, <: Union{Nothing, U}}}}`: the forward adjacency list of the MultilayerGraph. It is a vector of vectors of [`HalfEdge`](@ref)s. Its i-th element are the[`HalfEdge`](@ref)s that originate from `v_V_associations[i]`.
13
-
- `v_metadata_dict::Dict{T, <: Union{ <: Tuple, <: NamedTuple}}`: A Dictionary that associates numeric vertices to their metadata.
layers::Vector{LayerDescriptor{T,U}}# vector containing all the layers of the multilayer graph. Their underlying graphs must be all undirected.
8
+
interlayers::OrderedDict{Set{Symbol},InterlayerDescriptor{T,U}}# the ordered dictionary containing all the interlayers of the multilayer graph. Their underlying graphs must be all undirected.
9
+
v_V_associations::Bijection{ T, <: MultilayerVertex}# A Bijection from Bijections.jl that associates numeric vertices to `MultilayerVertex`s.
10
+
idx_N_associations::Bijection{ Int64 , Node}# A Bijection from Bijections.jl that associates Int64 to `Node`s.
11
+
fadjlist::Vector{Vector{HalfEdge{ <:MultilayerVertex, <:Union{Nothing, U}}}}# the forward adjacency list of the MultilayerGraph. It is a vector of vectors of `HalfEdge`s. Its i-th element are the `HalfEdge`s that originate from `v_V_associations[i]`.
12
+
v_metadata_dict::Dict{T, <: Union{ <: Tuple, <: NamedTuple}}# A Dictionary that associates numeric vertices to their metadata.
Copy file name to clipboardExpand all lines: src/subgraphs/layer.jl
-7Lines changed: 0 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -18,13 +18,6 @@ abstract type AbstractLayer{T,U,G} <: AbstractSubGraph{T,U,G} end
18
18
mutable struct Layer{T <: Integer, U <: Real, G <: AbstractGraph{T}} <: AbstractLayer{T,U,G}
19
19
20
20
Represents a layer in a `Multilayer(Di)Graph`.
21
-
22
-
# FIELDS
23
-
24
-
- `name::Symbol`: the name of the layer;
25
-
- `graph::G`: underlying graph of the layer;
26
-
- `forbidden_vertices::Vector{MultilayerVertex}`: nodes of the MultilayerGraph that are not part of this Layer (they will be formally present in the Layer but it will be checked that they aren't adjacent to any other node);
27
-
- `forbidden_edges`::Vector{NTuple{2, MultilayerVertex}}: edges that are required not to exist in this Layer.
0 commit comments