Reference

Utilities

MLNABCDGraphGenerator.MLNConfigType
MLNConfig(
    seed::Union{Int,Nothing},
    n::Int,
    edges_cor::String,
    layer_params::String,
    d_max_iter::Int,
    c_max_iter::Int,
    t::Int,
    eps::Float64,
    d::Int,
    edges_filename::String,
    communities_filename::String)
    ::MLNConfig

Creates MLNABCD configuration struct.

Arguments

  • filename::String configuration file name
source
MLNABCDGraphGenerator.parse_configFunction
parse_config(filename::String)::MLNConfig

Parse configuration file into MLNABCD configuration struct.

Arguments

  • filename::String configuration file name
source
MLNABCDGraphGenerator.write_edgesFunction
write_edges(cfg::MLNConfig, edges::Vector{Set{Tuple{Int,Int}}})

Saves edges of multilayer network in cfg.edges_filename file.

Arguments

  • cfg::MLNConfig MLNABCD configuration
  • edges::Vector{Set{Tuple{Int,Int}}} edges between agents in each layer
source
MLNABCDGraphGenerator.write_communitiesFunction
write_communities(cfg::MLNConfig, coms::Vector{Vector{Int}})

Saves communities of multilayer network in cfg.communities_filename file.

Arguments

  • cfg::MLNConfig MLNABCD configuration
  • coms::Vector{Vector{Int}} assignment of agents to communities for each layer
source

Phase 1 - Active Nodes

Phase 2 - Degrees Correlation

MLNABCDGraphGenerator.sample_rankingFunction
sample_ranking(vs::Vector{Int}, n::Int, sigma::AbstractFloat)::Vector{Vector{Int}}

Returns ranking of samples of random variables N(v/n,sigma).

Arguments

  • vs::Vector{Int} vector with IDs of active agents
  • n::Int number of agents
  • sigma::AbstractFloat standard deviation of normal distribution N(v/n,sigma)
source
MLNABCDGraphGenerator.find_rankingFunction
find_ranking(ns::Int, n::Int, tau::AbstractFloat, verbose::Bool=false, limit::Int=20)

Finds ordering of labels of agents which has tau Kendall-tau correlation with ordered labels sequence.

Arguments

  • ns::Int number of active agents
  • n::Int number of agents
  • tau::AbstractFloat desired Kendall-tau correlation value
  • verbose::Bool=false verbose logging flag
  • limit::Int=20 number of rankings sampled to find the best correlation match
source
MLNABCDGraphGenerator.degrees_correlationFunction
degrees_correlation(
    cfg::MLNConfig,
    degs::Vector{Vector{Int}},
    active_nodes::Vector{Vector{Int}},
    verbose::Bool=false)
    ::Vector{Vector{Int}}

Creates correlated sequences of degrees for all layers of the network.

Arguments

  • cfg::MLNConfig MLNABCD configuration
  • degs::Vector{Vector{Int}} sorted (input) sequences of degrees
  • active_nodes::Vector{Vector{Int}} IDs of active nodes
  • verbose::Bool=false verbose logging flag
source
MLNABCDGraphGenerator.generate_degreesFunction
generate_degrees(cfg::MLNConfig,
    active_nodes::Vector{Vector{Int}},
    verbose::Bool=false)
    ::Vector{Vector{Int}}

Samples sequences of degrees from truncated power-law distribution and reorder the sequences to correlate layers.

Arguments

  • cfg::MLNConfig MLNABCD configuration
  • active_nodes::Vector{Vector{Int}} IDs of active nodes
  • verbose::Bool=false verbose logging flag
source

Phase 3 - Communities Correlation

MLNABCDGraphGenerator.sample_pointsFunction
sample_points(n::Int, d::Int)::Matrix{Float64}

Samples normalized points in d-dimensional space.

Arguments

  • n::Int number of points
  • d::Int number of dimensions
source
MLNABCDGraphGenerator.assign_pointsFunction
assign_points(x::Matrix{Float64}, c::Vector{Int})::Vector{Vector{Int}}

Assigns points to communities based on the proximity in Euclidian space.

Arguments

  • x::Matrix{Float64} coordinates of points
  • c::Vector{Int} sizes of communities
source
MLNABCDGraphGenerator.shuffle_communitiesFunction
shuffle_communities(r::Float64, a::Vector{Vector{Int}})::Vector{Vector{Int}}

Shuffles assignment of nodes to communities to introduce correlation r between the layer and reference layer

Arguments

  • r::Float64 desired correlation between the layer and reference layer
  • a::Vector{Vector{Int}} assignment of nodes to communities
source
MLNABCDGraphGenerator.communities_correlationFunction
communities_correlation(
    n::Int,
    coms_sizes::Vector{Vector{Int}},
    rs::Vector{Float64},
    active_nodes::Vector{Vector{Int}},
    d::Int)
    ::Vector{Vector{Int}}

Shuffles communities assignment to match correlations rs between network layers and hidden reference layer.

Arguments

  • n::Int number of agents
  • coms_sizes::Vector{Vector{Int}} sizes of communities
  • rs::Vector{Float64} vector of desired correlations between each network layer and reference layer
  • active_nodes::Vector{Vector{Int}} IDs of active nodes
  • d::Int number of dimensions in reference space
source
MLNABCDGraphGenerator.generate_communitiesFunction
generate_communities(cfg::MLNConfig, active_nodes::Vector{Vector{Int}})

Samples sequences of community sizes from truncated power-law distribution. Then, assigns nodes to communities and shuffles the assignment to correlate layers. Returns sizes of communities and assignment of nodes to communities.

Arguments

  • cfg::MLNConfig MLNABCD configuration
  • active_nodes::Vector{Vector{Int}} IDs of active nodes
source

Phase 4 and 5 - Edges generation

MLNABCDGraphGenerator.generate_abcdFunction
generate_abcd(cfg::MLNConfig, degs::Vector{Vector{Int}},
    coms_sizes::Vector{Vector{Int}}, coms::Vector{Vector{Int}})
    ::Vector{Set{Tuple{Int,Int}}}

Generates edges of multilayer network using ABCD model.

Arguments

  • cfg::MLNConfig MLNABCD configuration
  • degs::Vector{Vector{Int}} degree sequences for active nodes
  • coms_sizes::Vector{Vector{Int}} community sizes
  • coms::Vector{Vector{Int}} assignment of active nodes to communities
source

Phase 6 - Edges correlation

MLNABCDGraphGenerator.map_edges_to_agentsFunction
map_edges_to_agents(edges::Vector{Set{Tuple{Int64,Int64}}}, active_nodes::Vector{Vector{Int64}})

Translates edges to agent-based representation.

Arguments

  • edges::Vector{Set{Tuple{Int64,Int64}}} edges based on layer-specific node labels
  • active_nodes::Vector{Vector{Int64}} IDs of active agents
source
MLNABCDGraphGenerator.map_communities_to_agentsFunction
map_communities_to_agents(
    n_agents::Int,
    communities::Vector{Vector{Int64}},
    active_nodes::Vector{Vector{Int64}})

Translates communities assignment to agent-based representation and imputes 0 for non-active agents.

Arguments

  • n_agents::Int number of agents
  • communities::Vector{Vector{Int64}} assignment of nodes to communities
  • active_nodes::Vector{Vector{Int64}} IDs of active agents
source
MLNABCDGraphGenerator.common_agents_dictFunction
common_agents_dict(active_nodes::Vector{Vector{Int64}})

Finds common active agents between all pairs of layers.

Arguments

  • active_nodes::Vector{Vector{Int64}} IDs of active agents
source
MLNABCDGraphGenerator.common_agents_edgesFunction
common_agents_edges(
    edges_agents::Vector{Set{Tuple{Int64,Int64}}},
    common_agents_dict::Dict{Tuple{Int,Int},Set{Int}})

Finds edges including only common active agents for all pairs of layers.

Arguments

  • edges_agents::Vector{Set{Tuple{Int64,Int64}}} agent-based edges of multilayer network
  • common_agents_dict::Dict{Tuple{Int,Int},Set{Int}} mapping of common active agents between layers
source
MLNABCDGraphGenerator.map_neighboursFunction
map_neighbours(edges::Set{Tuple{Int,Int}}, coms::Vector{Int})

Finds neigbhours of each agent within and outside of given node community.

Arguments

  • edges::Set{Tuple{Int,Int}} agent-based edges of multilayer network
  • coms::Vector{Int} assignment of nodes to communities
source
MLNABCDGraphGenerator.map_communitiesFunction
map_communities(edges::Set{Tuple{Int,Int}}, coms::Vector{Int})

Finds edges within communities and background graph.

Arguments

  • edges::Set{Tuple{Int,Int}} agent-based edges of multilayer network
  • coms::Vector{Int} assignment of nodes to communities
source
MLNABCDGraphGenerator.neighbours_common_agents_edgesFunction
neighbours_common_agents_edges(
    edges_common_agents::Dict{Tuple{Int,Int},Vector{Set{Tuple{Int,Int}}}},
    coms_agents::Vector{Vector{Int64}})

Finds neighbours of each agent in graphs induced by common agents between layers.

Arguments

  • edges_common_agents::Dict{Tuple{Int,Int},Vector{Set{Tuple{Int,Int}}}} graphs induced by common agents between layers
  • coms_agents::Vector{Vector{Int64}} assignment of nodes to communities in each layer
source
MLNABCDGraphGenerator.edges_in_communities_common_agents_edgesFunction
edges_in_communities_common_agents_edges(
    edges_common_agents::Dict{Tuple{Int,Int},Vector{Set{Tuple{Int,Int}}}},
    coms_agents::Vector{Vector{Int64}})

Finds edges within communities and background graph in graphs induced by common agents between layers.

Arguments

  • edges_common_agents::Dict{Tuple{Int,Int},Vector{Set{Tuple{Int,Int}}}} graphs induced by common agents between layers
  • coms_agents::Vector{Vector{Int64}} assignment of nodes to communities in each layer
source
MLNABCDGraphGenerator.calculate_edges_corFunction
calculate_edges_cor(
    edges_common_agents::Dict{Tuple{Int,Int},Vector{Set{Tuple{Int,Int}}}},
    desired_cor::Matrix{Float64})

Calculates correlation between edges in each pair of layers, difference between desired correlation and distance between desired correlation matrix and current correlation matrix.

Arguments

  • edges_common_agents::Dict{Tuple{Int,Int},Vector{Set{Tuple{Int,Int}}}} graphs induced by common agents between layers
  • desired_cor::Matrix{Float64} input correlation matrix between layers
source
MLNABCDGraphGenerator.pick_cor_to_improveFunction
pick_cor_to_improve(cor_diff::Matrix{Float64}, method::String="weighted")

Selects entry of correlation matrix to improve in next batch.

Arguments

  • cor_diff::Matrix{Float64} difference between desired and current correlation matrices
  • method::String="weighted" method of entry selection
source
MLNABCDGraphGenerator.write_cor_diff_to_fileFunction
write_cor_diff_to_file(io::IOStream, cor_diff::Matrix{Float64}, cor_dist::Float64)

Writes differences between current and desired correlation matrices entries to file. Used to track changes in empirical correlation between batches.

Arguments

  • io::IOStream IO handler to a file
  • cor_diff::Matrix{Float64} difference between desired and current correlation matrices
  • cor_dist::Float64 distance between desired and current correlation matrices
source
MLNABCDGraphGenerator.increase_edges_correlation!Function
increase_edges_correlation!(layers::Tuple{Int,Int},
    edges::Vector{Set{Tuple{Int,Int}}},
    edges_common::Vector{Set{Tuple{Int,Int}}},
    neighbours::Vector{Dict{Int,Set{Int}}},
    coms_agents::Vector{Vector{Int}},
    perc_rewire::Float64,
    verbose::Bool=false)

Increases correlation between edges in two selected layers.

Arguments

  • layers::Tuple{Int,Int} IDs of modified layers
  • edges::Vector{Set{Tuple{Int,Int}}} edges of multilayer network modified in-place to keep state between batches
  • edges_common::Vector{Set{Tuple{Int,Int}}} edges on common active agents between layers
  • neighbours::Vector{Dict{Int,Set{Int}}} mapping of neighbours of agents
  • coms_agents::Vector{Vector{Int}} assignment of agents to communities
  • perc_rewire::Float64 fraction of edges to be used for rewiring attempt
  • verbose::Bool=false verbose logging flag
source
MLNABCDGraphGenerator.decrease_edges_correlation!Function
decrease_edges_correlation!(layers::Tuple{Int,Int},
    edges::Vector{Set{Tuple{Int,Int}}},
    edges_common::Vector{Set{Tuple{Int,Int}}},
    neighbours::Vector{Dict{Int,Set{Int}}},
    coms_agents::Vector{Vector{Int}},
    perc_rewire::Float64,
    verbose::Bool=false)

Decreases correlation between edges in two selected layers.

Arguments

  • layers::Tuple{Int,Int} IDs of modified layers
  • edges::Vector{Set{Tuple{Int,Int}}} edges of multilayer network modified in-place to keep state between batches
  • edges_common::Vector{Set{Tuple{Int,Int}}} edges on common active agents between layers
  • edges_in_coms::Vector{Dict{Int,Set{Tuple{Int,Int}}}} mapping of edges withing communities and background graph
  • coms_agents::Vector{Vector{Int}} assignment of agents to communities
  • perc_rewire::Float64 fraction of edges to be used for rewiring attempt
  • verbose::Bool=false verbose logging flag
source
MLNABCDGraphGenerator.adjust_edges_correlationFunction
adjust_edges_correlation(cfg::MLNConfig,
    edges::Vector{Set{Tuple{Int,Int}}},
    coms::Vector{Vector{Int}},
    active_nodes::Vector{Vector{Int}},
    verbose::Bool=false,
    save_cor_change_to_file::Bool=false)

Run cfg.t rewiring batches to match edges correlation between layers with desired cfg.edges_cor_matrix correlation matrix.

Arguments

  • cfg::MLNConfig MLNABCD configuration
  • edges::Vector{Set{Tuple{Int,Int}}} agent-based edges of multilayer network before rewiring
  • coms::Vector{Vector{Int}} assignment of nodes to communities in each layer
  • active_nodes::Vector{Vector{Int}} IDs of active agents
  • verbose::Bool=false verbose logging flag
  • save_cor_change_to_file::Bool=false correlation changes file logging flag
source