This project implements two variants of Temporal Graph Network (TGN) architectures for community detection and link prediction in dynamic graphs. The implementation is based on the original TGN paper from Twitter Research: Temporal Graph Networks for Deep Learning on Dynamic Graphs.
The project provides:
- Standard TGN Model: Complete implementation of the original TGN architecture with configurable temporal attention mechanisms.
- Decay TGN Model: Enhanced TGN with decay-based temporal attention that models how the importance of historical interactions decreases over time.
- Comparative Analysis: Framework for comparing the performance of both models on community detection and link prediction tasks.
- Graph Visualization: Comprehensive visualization capabilities to analyze temporal evolution of communities and network structures.
This work is published in IEEE: Community Detection and Link Prediction with Temporal Graph Networks
This paper is a comparative analysis of temporal decay mechanisms in Temporal Graph Networks (TGN) for dynamic social network modeling. Using the Reddit Hyperlinks dataset from Stanford SNAP, which comprises more than 858K timestamped subreddit interactions from 2014–2017, we evaluate the impact of incorporating fixed and adaptive decay factors into the TGN attention framework. In order to modulate historical influence while maintaining the original memory module from the Twitter Research implementation, our modified architecture adds exponential time decay. Standard TGN, fixed-decay TGN, and adaptive-decay TGN with learnable parameters are the three model variations taken into consideration. According to the results, fixed decay can have a detrimental effect on modularity, adaptive decay provides benefits for community detection in sparse-node settings, and link prediction performance is similar across models. These results emphasize the significance of context-aware temporal mechanisms and the complex role of temporal decay in dynamic graph modeling. Instead of recommending universal decay applications, this study offers methodological insights for temporal graph learning through hybrid approaches. The study contributes to our knowledge of how memory retention works in dynamic social networks, which has ramifications for anomaly detection and recommendation systems.
-
Clone the repository:
git clone https://github.com/mohak34/CommDec-DBTA cd CommunityDetection -
Install dependencies:
pip install -r requirements.txt
The main implementation is available in src/enhanced_tgn.py. This file contains the complete implementation of the standard Temporal Graph Network with the Reddit dataset.
The enhanced Decay TGN model with temporal attention decay is implemented in src/decay_tgn.py. This model includes:
- Configurable decay factors for temporal attention
- Memory modules with decay-based temporal attention
- Adaptive decay mechanisms for learning temporal patterns
To compare both models:
- Use the standard TGN implementation in
notebooks/Enhanced_TGN.ipynb - Use the Decay TGN implementation with different decay factors via
src/decay_tgn.py - Run experiments with various decay factors to analyze their impact on performance
The standard TGN implementation includes:
- Temporal attention mechanisms for modeling dynamic graph interactions
- Memory modules for storing and updating node states over time
- Message passing and aggregation for community detection
- Link prediction capabilities
The Decay TGN model extends the standard TGN with:
- Configurable decay factors for temporal attention weights
- Adaptive decay mechanisms that learn optimal decay rates
- Enhanced memory modules with temporal decay consideration
- Comprehensive decay analysis and visualization tools
Both models can be evaluated on:
- Community Detection: Identifying clusters of related nodes in temporal graphs
- Link Prediction: Predicting future connections between nodes
- Temporal Pattern Analysis: Understanding how relationships evolve over time
The project uses the Reddit Hyperlinks dataset, which represents connections between subreddit communities. Each edge represents a hyperlink from one subreddit to another, with timestamps indicating when the hyperlink was created.