This is an official implementation for paper titled "DANI: Fast Diffusion Aware Network Inference with Preserving Topological Structure Property".
The default implementation of DANI is in C++, which is way faster than the python version due to C++ characteristics.
To compile the code, run the command below.
makeOnly input required for the code is a file containing nodes names and cascades sorted in ascending order regarding infection timestamps. The input file contains two parts which are separated by a blank line:
-
The first
$n$ lines of the file contain the name of nodes in the network. Each line contain<id>and<name>where node ids are integers starting from 0 to$n-1$ .<id>,<name> -
The next
$m$ lines contains$m$ cascades, each on a line. Each cascade is represented by a sequence of<id>and the corresponding<timestamp>of infection pairs where<id>and<timestamp>are separated by a comma and pairs are separated by a semi-colon. The cascades are sorted in ascending order regarding infection timestamps.<id>,<timestamp>;<id>,<timestamp>;<id>,<timestamp>;...;<id>,<timestamp>An example of input file is in file
cascades.txtwhich contains 10000 cascades generated on the network indataset/groundtruth/network.txt.Here is the list of arguments that can be passed to the code:
-i:which is the address of input file.-Y:which is the address of output file.
Run the code using following command:
./main -i:<input_file> -Y:<output_file>
To run the code on the example input file, run the command below:
./main -i:dataset/cascades.txt -Y:dataset/inferred/network.txt
The output of the model is in Tab Separated Triples format. Each line contains a triple in format of
$u\space v\space \alpha$ in which alpha is scored assigned to directed edge$(u,\space v)$ by the model. Note that edges are sorted in descending order.DANI has also a python version. If you want to use the python version, follow the instructions in README.md in
pythondirectory.We use OSLOM2 [2] for the community detection. You have to download OSLOM2 and unpack it in the
./OSLOM2and compile it to do the evaluation. You can use the script below to do these works.wget http://www.oslom.org/code/OSLOM2.tar.gz tar -xvzf OSLOM2.tar.gz cd OSLOM2 chmod 744 compile_all.sh ./compile_all.sh cd ..
Note: Compiling OSLOM may result in some errors but it is OK for our usage.
To do the evaluation, run the evaluation code as below.
cd evaluation python3 main.py --gt <gt> --pr <pr>
Where
<gt>is a path to a directory contatining a file namednetwork.txtcontaining true underlying network and<pr>is a path to a directory contatining a file namednetwork.txtcontaining inferred network. For example, you can use the following command to run the evaluation on the example dataset.cd evaluation python3 main.py --gt ../dataset/groundtruth --pr ../dataset/inferredThis code has been compiled and tested on Ubuntu 22.04 LTS using Python 3.10.
@article{DANI, title = {{DANI}: fast diffusion aware network inference with preserving topological structure property}, author = {Ramezani, Maryam and Ahadinia, Aryan and Farhadi, Erfan and Rabiee, Hamid R.}, journal = {Scientific Reports}, volume = {14}, pages = {31053}, year = {2024}, doi = {10.1038/s41598-024-82286-X}, url = {https://www.nature.com/articles/s41598-024-82286-x} }
We have used SNAP library and OSLOM2 to develop this method.
[1] Leskovec, J. and Sosič, R., 2016. Snap: A general-purpose network analysis and graph-mining library. ACM Transactions on Intelligent Systems and Technology (TIST), 8(1), pp.1-20.
[2] Lancichinetti, A., Radicchi, F., Ramasco, J.J. and Fortunato, S., 2011. Finding statistically significant communities in networks. PloS one, 6(4), p.e18961.