In a nutshell, community membership hiding aims to enable a target node within a graph to elude being recognized as a member of a particular node cluster, as determined by a community detection algorithm. This objective is accomplished by granting the node in question the ability to strategically modify its connections with other nodes. Therefore, our primary focus is on making changes to the graph's structure, represented by the adjacency matrix. While the alteration of node features holds potential interest, that aspect is reserved for future exploration.
Let
The aim of community membership hiding is to formulate a function
To achieve that goal, suppose that the target node
We assume
Several similarity measures can be used to measure
This diagram describes a simplification of the Node Deception process and its various phases. Given a graph
UMl diagram of the classes used in the project.
To learn the optimal policy for our agent defined above, we use the Advantage Actor-Critic (A2C) algorithm, a popular deep reinforcement learning technique that combines the advantages of both policy-based and value-based methods.
Specifically, A2C defines two neural networks, one for the policy (
where
Below, we describe the policy network (actor) and value function network (critic) separately.
The policy network is responsible for generating a probability distribution over possible actions based on the input, which consists of a list of nodes and the graph's feature matrix.
However, some graphs may lack node features. In such cases, we can extract continuous node feature vectors (i.e., node embeddings) with graph representational learning frameworks like node2vec
. These node embeddings serve as the feature matrix.
%ensuring a consistent feature vector size, allowing the model to work with graphs of varying node counts.
Our neural network implementation comprises a primary graph convolution layer (GCNConv) for updating node features. The output of this layer, along with skip connections, feeds into a block consisting of three hidden layers. Each hidden layer includes multi-layer perception (MLP) layers, ReLU activations, and dropout layers. The final output is aggregated using a sum-pooling function.
The policy is trained to predict the probability that node
This network closely resembles the one employed for the policy, differing only in one aspect: it incorporates a global sum-pooling operation on the convolution layer's output. This pooling operation results in an output layer with a size of 1, signifying the estimated value of the value function. The role of the value function is to predict the state value when provided with a specific action
Network architecture overview of the Actor and Critic. Initially, the node's continuous feature vectors are acquired by employing node2vec
, subsequently modified through the graph convolutions and processed through non-linearities to establish the concentration parameters
Make sure to have conda installed, then run:
conda conda create --name socialnets --python=3.9.18
conda activate socialnets
Python 3.9 is required, as the package karateclub
is based on old dependencies.
Then, install the requirements:
pip install -r requirements.txt
# Optional dependencies
pip install pyg_lib torch_scatter torch_sparse -f <https://data.pyg.org/whl/torch-${TORCH}.html>
To train the model, run the following command:
python main.py --mode "train"
to modify the parameters of the model, please refer to the src/utils/utils.py
file.
While, to test the model, run the following command:
python main.py --mode "test"
to modify the parameters of the model, please refer to the main.py
file.
The A2C structure is a reimplementation of the code found in the following repository:
@inproceedings{GammelliYangEtAl2021,
author = {Gammelli, D. and Yang, K. and Harrison, J. and Rodrigues, F. and Pereira, F. C. and Pavone, M.},
title = {Graph Neural Network Reinforcement Learning for Autonomous Mobility-on-Demand Systems},
year = {2021},
note = {Submitted},
}
all the other references are in the references
folder.
├── dataset
│ ├── archives # Contains the archives of the datasets
│ │ └── ...
│ ├── data # Contains the datasets
│ │ └── ...
│ └── readme.md
├── images # Images used in the README
│ └── ...
├── notebook # Contains the notebooks used for the analysis
│ └── ...
├── references # Contains articles used for the thesis
│ └── ...
├── src # Contains the source code
│ ├── agent
│ │ ├── a2c # Contains the agent code
│ │ │ ├── a2c.py
│ │ │ ├── actor.py
│ │ │ ├── critic.py
│ │ │ ├── __init__.py
│ │ │ └── readme.md
│ │ ├── agent.py
│ │ ├── __init__.py
│ │ └── readme.md
│ ├── community_algs # Contains algorithms for community analysis
│ │ ├── baselines
│ │ │ ├── community_hiding # Community Deception algorithms
│ │ │ │ ├── __init__.py
│ │ │ │ ├── modularity.py
│ │ │ │ ├── modularity_test.py
│ │ │ │ ├── permanence.py
│ │ │ │ ├── safeness.py
│ │ │ │ └── safeness_tets.py
│ │ │ ├── node_hiding # Node Deception algorithms
│ │ │ │ ├── degree_hiding.py
│ │ │ │ ├── __init__.py
│ │ │ │ ├── random_hiding.py
│ │ │ │ └── roam_hiding.py
│ │ │ ├── __init__.py
│ │ │ └── readme.md
│ │ ├── metrics # Contains an implementation of the metrics used for the evaluation
│ │ │ ├── deception_score.py
│ │ │ ├── nmi.py
│ │ │ ├── readme.md
│ │ │ └── similarity.py
│ │ ├── detection_algs.py # Contains the community detection algorithms
│ │ ├── __init__.py
│ │ └── readme.md
│ ├── environment # Contains the environment of the agent
│ │ ├── graph_env.py
│ │ ├── __init__.py
│ │ └── readme.md
│ ├── models # Contains the trained models
│ │ └── ...
│ ├── utils # Contains utility functions
│ │ ├── hiding_community.py
│ │ ├── hiding_node.py
│ │ ├── __init__.py
│ │ ├── readme.md
│ │ └── utils.py
│ └── __init__.py
├── test # Contains the output of the test
│ └── ...
├── main.py
├── README.md
└── requirements.txt