Skip to content

Commit e118ab5

Browse files
InterdisciplinaryPhysicsTeampitmonticoneClaudMor
committed
update
Co-Authored-By: Pietro Monticone <38562595+pitmonticone@users.noreply.github.com> Co-Authored-By: Claudio Moroni <43729990+ClaudMor@users.noreply.github.com>
1 parent 3248db2 commit e118ab5

File tree

2 files changed

+47
-1
lines changed

2 files changed

+47
-1
lines changed

src/MultilayerGraphs.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ export
7474
# layer.jl
7575
AbstractLayer,
7676
Layer,
77+
simple_layer,
7778
has_node,
7879
add_vertex!,
7980
rem_vertex!,

src/subgraphs/layer.jl

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,51 @@ function Layer(
9494
return Layer(descriptor, vertices, edge_list)
9595
end
9696

97+
98+
"""
99+
simple_layer(
100+
name::Symbol,
101+
vertices::Vector{<:MultilayerVertex},
102+
edge_list::Vector{<:MultilayerEdge},
103+
weighttype::Type{U};
104+
default_vertex_metadata::Function=mv -> NamedTuple(),
105+
default_edge_weight::Function=(src, dst) -> one(U),
106+
default_edge_metadata::Function=(src, dst) -> NamedTuple(),
107+
) where {T<:Integer,U<:Real}
108+
109+
Constructor for `Layer`.
110+
111+
# ARGUMENTS
112+
113+
- `name::Symbol`: The name of the Layer;
114+
- `vertices::Vector{ <: MultilayerVertex}`: The `MultilayerVertex`s of the Layer;
115+
- `edge_list::Vector{ <: MultilayerEdge}`: The list of `MultilayerEdge`s;
116+
- `null_graph::G`: the Layer's underlying graph type, which must be passed as a null graph. If it is not, an error will be thrown;
117+
- `weighttype::Type{U}`: The type of the `MultilayerEdge` weights (even when the underlying Layer's graph is unweighted, we need to specify a weight type since the `MultilayerGraph`s will always be weighted)
118+
119+
# KWARGS
120+
121+
"""
122+
function simple_layer(
123+
name::Symbol,
124+
vertices::Vector{<:MultilayerVertex},
125+
edge_list::Vector{<:MultilayerEdge};
126+
vertextype::Type{T} = Int64,
127+
weighttype::Type{U} = Float64
128+
) where {T<:Integer,U<:Real}
129+
130+
descriptor = LayerDescriptor(
131+
name,
132+
SimpleGraph{vertextype}(),
133+
weighttype;
134+
#= default_vertex_metadata=mv -> NamedTuple(),
135+
default_edge_weight=(src, dst) -> one(U),
136+
default_edge_metadata=(src, dst) -> NamedTuple(), =#
137+
)
138+
139+
return Layer(descriptor, vertices, edge_list)
140+
end
141+
97142
"""
98143
Layer(descriptor::LayerDescriptor{T}, vertices::Vector{<: MultilayerVertex}, edge_list::Vector{<:MultilayerEdge}) where {T <: Integer}
99144
@@ -175,7 +220,7 @@ Return a random `Layer`.
175220
"""
176221
function Layer(
177222
name::Symbol,
178-
vertices::Vector{<:MultilayerVertex},
223+
vertices::Vector{MultilayerVertex{ <: Union{Val{name}, Val{nothing}}}},
179224
ne::Int64,
180225
null_graph::G,
181226
weighttype::Type{U};

0 commit comments

Comments
 (0)