## General description:
These materials contain all necessary codes to implement all numerical experiments in the paper "Structure-Preserving Embedding of Multi-layer Networks".


## Required packages:
To implement the codes, one may need the following packages:
numpy, tensorly, sklearn, itertools, scipy, multiprocessing, time, rpy2, pickle.


## Implementation environment:
We suggest running the codes under the environment Python 3.8.


## Usage:
After downloading all files, one can run the files with numbers 1, 2, 3, 4, 7, 9, 11, 12, and 20 in the following file Architecture directly.


## File architecture:

# Within the folder "Ablation studies":
1. "ablation_penalty.py" contains the implementation of the ablation studies on the community-inducing regularizer.
2. "ablation_s_n_ble.py" contains the implementation of the ablation studies on the sparsity factor with various values of s_n.
3. "ablation_s_n_red.py" contains the implementation of the ablation studies on the sparsity factor with s_n estimated from the proposed data-adapted estimation scheme.


# Within the folder "Real applications":
4. "aucs.py" contains the implementations of all methods on the AUCS dataset.
5. "aucs_edgelist.txt" contains the edge information of the AUCS dataset.
6. "aucs_nodelist.txt" contains the node information of the AUCS dataset.

7. "wat.py" contains the link prediction experiments on the WAT network by TLSM, MASE, and HOSVD-Tucker.
8. "wat_edge.npy" is the original WAT network data.
9. "wat_lse.py" contains the link prediction experiments on the WAT network by LSE.
10. "wat_node.npy" contains all country names in the original WAT network data.
11. "wat_speck.py" contains the link prediction experiments on the WAT network by SEPCK.

12. "yeast.py" contains the implementations of all methods on the YSCGC dataset.
13. "yeast_expression.npy" contains the gene expression information in the YSCGC dataset.
14. "yeast_label.npy" contains the community labels of the genes in the YSCGC dataset.


# Other files:
15. "Codes_Spectral_Matrix.r" contains the SPECK algorithm and is obtained from the paper "Spectral and matrix factorization methods for consistent community detection in multi-layer networks".
16. "Data_generation.py" contains functions to generate a multi-layer network according to the proposed TLSM.
17. "Hamming_error.py" contains functions to compute the Hamming error of two lists of community assignments.
18. "hosvd_tucker.py" contains the HOSVD-Tucker algorithm.
19. "LSM.r" is the LSE algorithm obtained from the paper "Consistent community detection in multi-layer network data".
20. "simulation_all_methods.py" contains the implementation of a simulation study with all 5 approaches, and one can adjust the model parameters to the desired setup before running.  
21. "spectral_aggregation.py" contains the MASE algorithm.
22. "TLSM_fun.py" contains the transformed HOOI algorithm for initialization.
23. "TLSM_method.py" defines the class TLSM for the proposed projected gradient descent algorithm.


