Home

Awesome

CommunityGAN

CommunityGAN: Community Detection with Generative Adversarial Nets

Files in the folder

Data format

The input file for CommunityGAN (data/community_detection/*_train.txt): An undirected graph in which vertex IDs start from 0 to N-1 (N is the number of nodes in the graph). Each line contains two node IDs indicating an edge in the graph.

The input file for the pre-train model (data/community_detection/*_agm.txt): Similar to the input file for CommunityGAN. The only difference is that in this file one edge need occur twice: node1 node2 and node2 node1

The community file (data/community_detection/*.sampled.cmty.txt): Each line means a community and the numbers indicate the vertices in the community.

CommunityGAN

Requirements

The code of CommunityGAN has been tested running under Python 3.6.1, with the following packages installed (along with their dependencies):

Basic usage

The basic usage of CommunityGAN is as follow:

cd src/CommunityGAN
python community_gan.py

The parameters for CommunityGAN can be changed by editing src/CommunityGAN/config.py or passing through the command line. An example of running CommunityGAN on the three datasets are written in scripts/run.py, which can be called by:

cd scripts
python run.py

Pre-train model

Compile

Get into the src/PreTrain directory and use make command to compile. Has been tested on Ubuntu with g++ 5.3.0, and on Windows with MinGW-w64 5.3.0.

Basic usage

A basic usage example of the pre-train model has been written in scripts/prepare_pretrain_embedding.py. The following commands can be used to re-prepare the pre-train embeddings for CommunityGAN on the three datasets:

cd scripts
python prepare_pretrain_embedding.py