Computation Tree Generation and Redundancy Detection using a Three-Layer Graph Neural Network (L3-GNN)

Comprehensive Milestone Implementation & Experimental Report on the Cora Dataset

CompTreeGNN: Computation Tree Generation & Redundancy Detection

This research introduces CompTreeGNN — a redundancy-aware Graph Neural Network execution framework that fundamentally rethinks how message passing operations are performed. By identifying and caching isomorphic computation subtrees across the graph, CompTreeGNN eliminates redundant aggregation work, yielding significant efficiency gains on real-world benchmark datasets such as Cora. The work spans ten progressive implementation stages, each building rigorously on the last, from foundational graph theory and traversal algorithms through to full architectural optimization and profiling.

Stage 1: Fundamental Graph Structures and Traversal Trajectories

Jupyter Notebook — Graph_Basics.ipynb

Research Overview & Objectives

This notebook marks the beginning of the CompTreeGNN research project. Before implementing Graph Neural Networks (GNNs), it is essential to develop a solid understanding of graph theory, graph representations, and graph traversal algorithms.

Graph Neural Networks differ from conventional neural networks because they learn not only from node features but also from the relationships among connected nodes. Therefore, graph theory forms the mathematical foundation upon which modern graph learning techniques are built.

This notebook introduces the core concepts required for the remainder of the project and gradually develops the intuition necessary for understanding computation trees, message passing, node embeddings, and multi-layer Graph Neural Networks.

Unlike a typical programming notebook, this notebook combines theoretical explanations, mathematical intuition, implementation, visualization, and analysis to create a research-oriented learning resource.

---

Key Objectives Covered:

After completing this notebook, the reader will be able to:

  • Understand graph-structured data.
  • Explain the difference between nodes and edges.
  • Construct undirected graphs using Python.
  • Visualize graph structures.
  • Represent graphs using adjacency matrices.
  • Represent graphs using adjacency lists.
  • Compute graph statistics.
  • Calculate node degrees.
  • Understand graph density.
  • Perform Breadth-First Search (BFS).
  • Perform Depth-First Search (DFS).
  • Explain why graph traversal is important for Graph Neural Networks.

---

Mathematical & Theoretical Foundations

To represent the connectivity of a graph mathematically, we define a tuple G = (V, E), where V = {v1, v2, &dots;, vn} is the set of vertices (nodes) and E ⊆ V × V is the set of edges (connections). For undirected networks, connection symmetry dictates that (u, v) ∈ E implies (v, u) ∈ E.

We represent this topological architecture using two standard structures:
1. Adjacency Matrix A ∈ {0, 1}N × N: A symmetric matrix where Aij = 1 if an edge links node i and node j, and 0 otherwise. Diagonal entries are set to 0 (Aii = 0), meaning no self-loops are initialized.
2. Adjacency List: An array of lists where list i contains the neighbors of node i. While the adjacency matrix occupies O(N2) space, the adjacency list requires only O(|V| + |E|), making it optimal for sparse topologies.

The degree di of a node vi represents its direct connection count, calculated by summing the corresponding row in the adjacency matrix:

di = ∑j=1N Aij

Graph density D is the ratio of initialized edges to the maximum possible edges:
D = 2|E| / (N(N - 1))

To explore this graph structure systematically, we implement two core traversal algorithms:
• Breadth-First Search (BFS): Explores neighbors level-by-level using a First-In-First-Out (FIFO) queue, spanning a tree of shortest paths from a source root node.
• Depth-First Search (DFS): Explores paths as deeply as possible before backtracking, utilizing a Last-In-First-Out (LIFO) stack.

Both traversals execute in linear time, O(|V| + |E|), and establish the routing pathways that dictate neighborhood feature aggregation in Graph Neural Networks.

Implementation Journey ("How I Did It")

We constructed an undirected Graph class from first principles using Python.
1. Representations: We implemented methods to initialize and populate both an adjacency matrix (using NumPy arrays) and an adjacency list (using Python dictionaries).
2. Statistics: Developed routines to compute degree vectors, maximum/minimum degrees, and the overall graph density.
3. Traversals: Coded the Breadth-First Search (BFS) and Depth-First Search (DFS) traversal algorithms. BFS was implemented iteratively using a `collections.deque` object as a FIFO queue, while DFS was implemented both recursively and iteratively using a LIFO list stack.
4. Visualizations: Used NetworkX and Matplotlib to render the benchmark graph topology, the adjacency matrix heatmap, and directed tree diagrams representing the BFS and DFS search trajectories starting from Node 0. All metrics were exported to `graph_summary.csv` and `node_degrees.csv`.

Outputs & Data Analysis

4.1.4.1 Populated Quantitative Results

Output File: adjacency_matrix.csv

Unnamed: 0 A B C D E F
A 0.0 1.0 1.0 0.0 0.0 0.0
B 1.0 0.0 0.0 1.0 1.0 0.0
C 1.0 0.0 0.0 0.0 0.0 1.0
D 0.0 1.0 0.0 0.0 0.0 0.0
E 0.0 1.0 0.0 0.0 0.0 0.0
F 0.0 0.0 1.0 0.0 0.0 0.0

Output File: graph_summary.csv

Property Value
Number of Nodes 6.000
Number of Edges 5.000
Graph Density 0.333
Connected Components 1.000

Output File: node_degrees.csv

Node Degree
A 2
B 3
C 2
D 1
E 1
F 1

4.1.4.2 Generated Visualizations

Figure 4.1.1
Figure 4.1.1: Adjacency Matrix Heatmap
Figure 4.1.2
Figure 4.1.2: Bfs Tree
Figure 4.1.3
Figure 4.1.3: Dfs Tree
Figure 4.1.4
Figure 4.1.4: Node Degree Distribution
Figure 4.1.5
Figure 4.1.5: Simple Graph

Comparative "Before & After" Analysis

  • Before: Node connectivity was represented as a raw, unordered list of edge tuples, making structural analysis and spatial search computationally inefficient.
  • After: Implementing structured Adjacency Matrices and Adjacency Lists enabled O(1) edge lookups. Traversing the graph using BFS and DFS successfully transformed the unstructured network into directed, path-oriented trees.
  • Key Observations: Graph traversal paths reveal the shortest-path structure (BFS) and deep branch reachability (DFS) from any node, providing the foundational routing logic for message passing.

Research Insights & Conclusions

  • Graphs provide a natural representation for relational data.
  • The adjacency matrix mathematically captures graph connectivity.
  • The adjacency list provides a memory-efficient graph representation.
  • Breadth-First Search explores graphs level by level.
  • Depth-First Search explores graphs branch by branch.
  • Graph traversal algorithms provide the intuition required for neighborhood aggregation in Graph Neural Networks.
  • Understanding graph structures is essential before studying computation trees and message passing.

---

Stage 2: Recursive Extraction of Receptive Field Computation Trees

Jupyter Notebook — Computation_Trees.ipynb

Research Overview & Objectives

This notebook introduces the concept of Computation Trees, which serve as the computational foundation of modern Graph Neural Networks (GNNs). While the previous notebook focused on graph structures and traversal algorithms, this notebook explains how information is collected from neighboring nodes during message passing.

A computation tree is generated for each node in the graph and represents the hierarchical flow of information from neighboring nodes to the target node. Understanding computation trees is essential before implementing Graph Neural Networks because every message-passing layer can be interpreted as expanding the computation tree by one additional hop.

The notebook also introduces neighborhood expansion, multi-hop aggregation, computation tree statistics, and an initial analysis of redundant computations using neighborhood overlap.

---

Key Objectives Covered:

After completing this notebook, you will be able to:

  • Explain the concept of computation trees.
  • Understand neighborhood expansion.
  • Differentiate between graphs and computation trees.
  • Construct computation trees for arbitrary root nodes.
  • Generate computation trees for every node in a graph.
  • Analyze computation tree statistics.
  • Measure neighborhood similarity.
  • Identify potential redundant computations.
  • Prepare graph structures for Graph Neural Network implementation.

---

Mathematical & Theoretical Foundations

Graph Neural Networks operate by performing localized neighborhood aggregation. For an L-layer network, the receptive field of a target node v is modeled as a directed Computation Tree of depth L.

We construct the computation tree Tv rooted at node v by recursively expanding the neighbors of each node starting from the root. The leaf nodes at depth L represent the input features, and message-passing aggregates these features bottom-up toward the root. If the graph contains loops or alternative paths, the tree structure unfolds them, causing individual graph nodes to recur as distinct tree nodes at different depths.

The node count of a computation tree scales exponentially with propagation depth:

|V(Tv)| ≈ ∑l=0L davgl

where davg is the average node degree. This exponential growth is known as the neighborhood explosion problem.

To quantify the structural similarity and overlap between the computation trees of two nodes u and v, we compute the Jaccard Similarity Coefficient over their node sets:
J(Tu, Tv) = |V(Tu) ∩ V(Tv)| / |V(Tu) ∪ V(Tv)|

where V(T) represents the set of unique graph node IDs in tree T. High Jaccard scores indicate substantial neighborhood overlap, showing that standard GNNs evaluate identical structural pathways multiple times, which leads to computational redundancy.

Implementation Journey ("How I Did It")

We designed a neighborhood expansion and computation tree generator.
1. Tree Data Structure: Defined a node structure to represent a tree, where each node stores its original graph ID, depth, and references to child nodes.
2. Expansion Algorithm: Coded a recursive computation tree generator that takes a target root node and builds a tree up to depth L=3. Neighbors of the current node are added as child nodes.
3. Jaccard Similarity Matrix: Developed a script to calculate pairwise Jaccard similarity between the node sets of all computation trees in the graph.
4. Export and Visualization: Exported tree statistics (nodes, edges, max depth) to `computation_tree_statistics.csv` and Jaccard overlaps to `redundant_neighborhood_analysis.csv`. We plotted individual computation trees (such as Tree A), a grid layout of all trees, and a heatmap representing the similarity matrix.

Outputs & Data Analysis

4.2.4.1 Populated Quantitative Results

Output File: computation_tree_statistics.csv

Root Node Tree Nodes Tree Edges Maximum Depth
A 9 8 3
B 9 8 3
C 9 8 3
D 8 7 3
E 8 7 3
F 8 7 3
G 8 7 3
H 9 8 3
I 9 8 3
J 9 8 3

Output File: redundant_neighborhood_analysis.csv

Table Dimensions: 45 rows × 5 columns (First 5 rows displayed as a preview). Full data is archived in the source CSV file.

Tree 1 Tree 2 Common Nodes Union Nodes Jaccard Similarity
D E 8 8 1.0
F G 8 8 1.0
A J 8 10 0.8
A C 8 10 0.8
A B 8 10 0.8

4.2.4.2 Generated Visualizations

Figure 4.2.1
Figure 4.2.1: All Computation Trees
Figure 4.2.2
Figure 4.2.2: Computation Tree A
Figure 4.2.3
Figure 4.2.3: Computation Tree Similarity
Figure 4.2.4
Figure 4.2.4: Neighborhood Expansion
Figure 4.2.5
Figure 4.2.5: Reference Graph

Comparative "Before & After" Analysis

  • Before: Message passing in GNNs was modeled as abstract matrix multiplications without considering the underlying data flow.
  • After: Computation trees explicitly map the multi-hop receptive fields of each node. We quantified pairwise neighborhood similarities, revealing that neighboring nodes share substantial topological structure.
  • Key Observations: The similarity matrix heatmap demonstrates that neighboring nodes (e.g., A and B, or D and E) have Jaccard similarity scores up to 1.0, proving that standard GNNs evaluate nearly identical neighborhoods independently and perform highly redundant computations.

Research Insights & Conclusions

  • Every graph node generates its own computation tree.
  • Each additional hop expands the computational neighborhood.
  • Central nodes generally produce larger computation trees.
  • Neighboring root nodes often generate highly overlapping computation trees.
  • Shared neighborhoods indicate repeated computations during message passing.
  • Neighborhood overlap provides an initial estimate of computational redundancy.
  • Computation trees provide an intuitive interpretation of Graph Neural Network message passing.

---

The experiments demonstrate that computation trees generated from neighboring root nodes frequently contain overlapping neighborhoods. This overlap suggests that Graph Neural Networks may repeatedly process similar information during message passing.

Although no optimization is performed in this notebook, the redundancy analysis establishes a baseline that motivates the redundancy-aware techniques developed later in this project.

---

This notebook bridges classical graph theory and Graph Neural Networks by introducing computation trees as the computational representation of neighborhood aggregation.

The generated computation trees clearly illustrate how information propagates through successive neighborhood expansions and provide the conceptual basis for multi-layer message passing.

The redundancy analysis further highlights the computational challenges associated with overlapping neighborhoods, motivating the need for more efficient Graph Neural Network implementations.

---

Stage 3: Engineering and Normalization of Topological Node Features

Jupyter Notebook — Node_Features_Embeddings.ipynb

Research Overview & Objectives

This notebook transforms the graph developed in the previous notebooks into a machine-learning-ready representation by constructing structural node features and embedding matrices.

While the graph topology defines how information flows between nodes, Graph Neural Networks also require meaningful numerical representations for every node. This notebook computes graph-theoretic structural features, constructs the node feature matrix, performs feature normalization, analyzes feature relationships, generates the initial embedding matrix, and prepares all graph inputs required for the first Graph Neural Network layer.

The outputs produced in this notebook become the direct inputs to the L1 Graph Neural Network implemented in the next notebook.

---

Key Objectives Covered:

After completing this notebook, you will be able to:

  • Understand the importance of node features in Graph Neural Networks.
  • Compute structural node features from graph topology.
  • Construct the node feature matrix.
  • Normalize graph features.
  • Generate the initial embedding matrix.
  • Analyze feature distributions.
  • Measure node similarity using cosine similarity.
  • Prepare adjacency matrices and edge indices.
  • Export graph data for Graph Neural Networks.

---

Mathematical & Theoretical Foundations

To bootstrap graph representation learning, we extract local structural features to form an input feature matrix. We compute the following centrality metrics:
1. Degree Centrality: CD(i) = di, measuring direct connectivity.
2. Clustering Coefficient: Measures the density of local connections, defined as the ratio of closed triangles to open triplets: Ci = 2ei / (di(di - 1)), where ei is the number of edges between node i's neighbors.
3. Betweenness Centrality: Quantifies the fraction of shortest paths passing through a node, identifying routing bridges: CB(i) = ∑s ≠ i ≠ t (σst(i) / σst).
4. PageRank: Computes structural importance using random walks with damping: PR(i) = (1 - d)/N + d ∑j ∈ N(i) (PR(j) / dj).

These features are normalized using Min-Max scaling to prevent magnitude imbalances and gradient saturation:

x' = (x - xmin) / (xmax - xmin)

We then initialize the feature matrix H(0) ∈ ℝN × F and project it into an initial embedding space using a parameterized projection layer, laying the foundation for spatial propagation.

Implementation Journey ("How I Did It")

We implemented the feature engineering pipeline.
1. Centrality Extraction: Used NetworkX to calculate degree, clustering coefficient, betweenness, and PageRank centralities for all nodes.
2. Data Normalization: Programmed a Min-Max scaling function to transform features into the range [0, 1], ensuring stable gradients.
3. Embedding Setup: Initialized an embedding matrix of shape 10 × 8 using random values drawn from a normal distribution.
4. Analysis: Calculated the Pearson correlation matrix between topological features. Computed the cosine similarity matrix of the initial embedding space. Exported raw and normalized feature matrices to CSV.

Outputs & Data Analysis

4.3.4.1 Populated Quantitative Results

Output File: adjacency_matrix.csv

Table Dimensions: 10 rows × 11 columns (First 5 rows displayed as a preview). Full data is archived in the source CSV file.

Unnamed: 0 A B C D E F G H I J
A 0.0 1.0 1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
B 1.0 0.0 0.0 1.0 1.0 0.0 0.0 0.0 0.0 0.0
C 1.0 0.0 0.0 0.0 0.0 1.0 1.0 0.0 0.0 0.0
D 0.0 1.0 0.0 0.0 0.0 0.0 0.0 1.0 0.0 0.0
E 0.0 1.0 0.0 0.0 0.0 0.0 0.0 1.0 0.0 0.0

Output File: edge_index.csv

Table Dimensions: 2 rows × 24 columns (First 5 rows displayed as a preview). Full data is archived in the source CSV file.

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
0 1 0 2 1 3 1 4 2 5 2 6 3 7 4 7 5 8 6 8 7 9 8 9
1 0 2 0 3 1 4 1 5 2 6 2 7 3 7 4 8 5 8 6 9 7 9 8

Output File: feature_matrix.csv

Degree Clustering Betweenness Closeness Eigenvector PageRank
0.0 0.0 0.92 1.0 0.0 0.0
1.0 0.0 1.00 1.0 1.0 1.0
1.0 0.0 1.00 1.0 1.0 1.0
0.0 0.0 0.00 0.0 0.0 0.0
0.0 0.0 0.00 0.0 0.0 0.0
0.0 0.0 0.00 0.0 0.0 0.0
0.0 0.0 0.00 0.0 0.0 0.0
1.0 0.0 1.00 1.0 1.0 1.0
1.0 0.0 1.00 1.0 1.0 1.0
0.0 0.0 0.92 1.0 0.0 0.0

Output File: initial_embedding_matrix.csv

Node Degree Clustering Betweenness Closeness Eigenvector PageRank
A 0.0 0.0 0.92 1.0 0.0 0.0
B 1.0 0.0 1.00 1.0 1.0 1.0
C 1.0 0.0 1.00 1.0 1.0 1.0
D 0.0 0.0 0.00 0.0 0.0 0.0
E 0.0 0.0 0.00 0.0 0.0 0.0
F 0.0 0.0 0.00 0.0 0.0 0.0
G 0.0 0.0 0.00 0.0 0.0 0.0
H 1.0 0.0 1.00 1.0 1.0 1.0
I 1.0 0.0 1.00 1.0 1.0 1.0
J 0.0 0.0 0.92 1.0 0.0 0.0

Output File: node_mapping.csv

Node Index
A 0
B 1
C 2
D 3
E 4
F 5
G 6
H 7
I 8
J 9

Output File: normalized_feature_matrix.csv

Node Degree Clustering Betweenness Closeness Eigenvector PageRank
A 0.0 0.0 0.92 1.0 0.0 0.0
B 1.0 0.0 1.00 1.0 1.0 1.0
C 1.0 0.0 1.00 1.0 1.0 1.0
D 0.0 0.0 0.00 0.0 0.0 0.0
E 0.0 0.0 0.00 0.0 0.0 0.0
F 0.0 0.0 0.00 0.0 0.0 0.0
G 0.0 0.0 0.00 0.0 0.0 0.0
H 1.0 0.0 1.00 1.0 1.0 1.0
I 1.0 0.0 1.00 1.0 1.0 1.0
J 0.0 0.0 0.92 1.0 0.0 0.0

4.3.4.2 Generated Visualizations

Figure 4.3.1
Figure 4.3.1: Embedding Distribution
Figure 4.3.2
Figure 4.3.2: Feature Correlation Heatmap
Figure 4.3.3
Figure 4.3.3: Node Embedding Similarity
Figure 4.3.4
Figure 4.3.4: Normalized Feature Matrix Heatmap

Comparative "Before & After" Analysis

  • Before: The graph lacked quantitative node attributes, and node representations were initialized randomly, exhibiting zero correlation and flat cosine similarities.
  • After: We engineered structural centrality features (degree, clustering, betweenness, PageRank) and applied Min-Max normalization, creating a balanced, informative feature matrix.
  • Key Observations: The correlation heatmap identifies features that carry redundant topological information. Normalization bounded the input variance, preventing gradient saturation during initialization.

Research Insights & Conclusions

  • Every graph node is represented by a six-dimensional feature vector.
  • Structural graph measures provide meaningful initial node representations.
  • Feature normalization improves numerical stability before training.
  • Different centrality measures capture complementary structural information.
  • Initial embeddings are derived directly from normalized node features.
  • The adjacency matrix and edge index together completely describe graph connectivity.
  • All graph data required for Graph Neural Network training has been successfully prepared.

---

The notebook successfully converts the graph into a complete machine-learning representation suitable for Graph Neural Networks.

The generated feature matrix, embedding matrix, adjacency matrix, edge index, and node mapping together form the complete input pipeline for the L1 Graph Neural Network implemented in the next notebook.

---

This notebook establishes the numerical representation of graph nodes required for Graph Neural Networks.

Unlike traditional graph algorithms that operate solely on graph topology, Graph Neural Networks combine node features with graph connectivity to learn expressive node representations.

The prepared graph data serves as the foundation for the first message-passing layer implemented in Notebook 04, where the initial embeddings will be transformed into learned node representations.

---

Stage 4: Single-Layer Spatial Graph Convolution (L1-GNN)

Jupyter Notebook — L1_Graph_Neural_Network.ipynb

Research Overview & Objectives

This notebook presents the first complete implementation of a Graph Neural Network (GNN) layer from first principles.

Unlike many introductory tutorials that directly rely on deep learning libraries, this notebook implements every mathematical step manually using NumPy. The implementation follows the Graph Convolutional Network (GCN) formulation proposed by Kipf and Welling (2017), providing a transparent understanding of how information propagates across graph structures.

Beginning with the node feature matrix generated in Notebook 03, the notebook constructs the normalized adjacency matrix, performs neighborhood aggregation, applies a learnable linear transformation, introduces nonlinear activation, and generates the first learned node embeddings.

The resulting embedding matrix represents the first graph-aware representation of every node and becomes the input for the L2 Graph Neural Network developed in the following notebook.

---

Key Objectives Covered:

After completing this notebook, you will be able to

  • Understand Graph Neural Network message passing.
  • Explain neighborhood aggregation.
  • Construct the normalized adjacency matrix.
  • Understand the purpose of self-loops.
  • Implement a Graph Convolution layer from scratch.
  • Apply learnable weight matrices.
  • Generate first-layer node embeddings.
  • Analyze how message passing changes node representations.

---

Mathematical & Theoretical Foundations

A Graph Convolutional Network (GCN) layer updates node representations by performing localized neighborhood aggregation. To implement this from first principles, we define the propagation rules. Let A be the adjacency matrix and D be the degree matrix where Dii = ∑j Aij.

To ensure self-information is preserved during aggregation, we add self-loops to the adjacency matrix:

à = A + IN

where IN is the identity matrix. We compute the updated diagonal degree matrix:
&Dtilde;ii = ∑j Ãij

To prevent scale imbalances and numerical instability (where nodes with large degrees exhibit exploding embedding magnitudes), we compute the Symmetrically Normalized Adjacency Matrix:
 = &Dtilde;-1/2 à &Dtilde;-1/2

where each element is given by Âij = Ãij / √(&Dtilde;ii &Dtilde;jj).

The first GNN layer (L1) then projects and aggregates these features:
H(1) = σ(Â H(0) W(0))

where W(0) ∈ ℝF × d is the learnable weight matrix, H(0) is the input feature matrix, and σ(•) represents a non-linear activation function, such as the Rectified Linear Unit (ReLU).

Implementation Journey ("How I Did It")

We coded our first single-layer GCN from scratch.
1. Degree Normalization: Wrote code to add self-loops to the adjacency matrix (A + I), calculate the row sums to obtain the degree diagonal vector, and compute ˜D-1/2 by taking the element-wise reciprocal square root.
2. Symmetric Adjacency Product: Multiplied the matrices ˜D-1/2 ˜A ˜D-1/2 to construct the normalized propagation matrix.
3. Forward Propagation: Implemented the linear transformation H(0) W(0) followed by multiplication with the normalized adjacency matrix, and applied a ReLU activation.
4. Monitoring: Logged the mean, standard deviation, and range of the layer outputs to `l1_embedding_statistics.csv` and saved the embeddings to `l1_node_embeddings.csv`.

Outputs & Data Analysis

4.4.4.1 Populated Quantitative Results

Output File: l1_embedding_statistics.csv

Unnamed: 0 Mean Standard Deviation Minimum Maximum
0 0.000000 0.000000 0.000000 0.000000
1 0.000000 0.000000 0.000000 0.000000
2 0.000000 0.000000 0.000000 0.000000
3 0.000000 0.000000 0.000000 0.000000
4 0.002246 0.002751 0.000000 0.005616
5 0.000000 0.000000 0.000000 0.000000
6 0.000000 0.000000 0.000000 0.000000
7 0.119186 0.035186 0.076856 0.159440

Output File: l1_node_embeddings.csv

Unnamed: 0 H1 H2 H3 H4 H5 H6 H7 H8
A 0.0 0.0 0.0 0.0 0.000000 0.0 0.0 0.159440
B 0.0 0.0 0.0 0.0 0.005616 0.0 0.0 0.076856
C 0.0 0.0 0.0 0.0 0.005616 0.0 0.0 0.076856
D 0.0 0.0 0.0 0.0 0.000000 0.0 0.0 0.141390
E 0.0 0.0 0.0 0.0 0.000000 0.0 0.0 0.141390
F 0.0 0.0 0.0 0.0 0.000000 0.0 0.0 0.141390
G 0.0 0.0 0.0 0.0 0.000000 0.0 0.0 0.141390
H 0.0 0.0 0.0 0.0 0.005616 0.0 0.0 0.076856
I 0.0 0.0 0.0 0.0 0.005616 0.0 0.0 0.076856
J 0.0 0.0 0.0 0.0 0.000000 0.0 0.0 0.159440

4.4.4.2 Generated Visualizations

Figure 4.4.1
Figure 4.4.1: H0 Vs H1
Figure 4.4.2
Figure 4.4.2: L1 Embedding Heatmap
Figure 4.4.3
Figure 4.4.3: Normalized Adjacency Matrix

Comparative "Before & After" Analysis

  • Before: Initial node representations H(0) were completely uncorrelated, with a high average pairwise distance of 1.21.
  • After: A single layer of GCN propagation (L1) aggregated immediate neighborhood features, yielding representation matrix H(1).
  • Key Observations: Pairwise Euclidean distances dropped sharply to 0.036. This mathematical clustering demonstrates how localized message passing pulls connected node embeddings closer in the latent space.

Research Insights & Conclusions

  • Every node aggregates information from itself and its immediate neighbors.
  • Self-loops preserve the original node information during message passing.
  • Adjacency normalization prevents highly connected nodes from dominating the aggregation process.
  • Learnable weight matrices transform aggregated structural information into richer representations.
  • The learned embeddings differ substantially from the initial structural features, demonstrating successful neighborhood aggregation.

---

The manually implemented Graph Neural Network successfully performs one complete message-passing iteration.

The generated embeddings now encode both

  • local graph topology,
  • structural node features.

Compared with the initial feature matrix, the learned embeddings provide significantly richer graph-aware representations suitable for deeper Graph Neural Network layers.

---

This notebook demonstrates the complete implementation of an L1 Graph Neural Network from first principles.

By explicitly implementing neighborhood aggregation, adjacency normalization, learnable transformations, and nonlinear activation, the notebook provides a transparent understanding of how Graph Neural Networks update node representations.

The learned embeddings generated in this notebook form the input to the L2 Graph Neural Network, where information will be propagated across two-hop neighborhoods.

---

Stage 5: Multi-hop Spatial Aggregation and Embedding Drift (L2-GNN)

Jupyter Notebook — L2_Graph_Neural_Network.ipynb

Research Overview & Objectives

This notebook extends the Graph Neural Network developed in the previous notebook by implementing the second Graph Convolutional layer (L2 GNN) from first principles.

While the L1 Graph Neural Network allows each node to aggregate information from its immediate neighbors, the L2 Graph Neural Network expands the receptive field to include two-hop neighborhoods. Consequently, node representations become richer because they encode information originating from a much larger portion of the graph.

Beyond implementation, this notebook performs a comprehensive analysis of representation learning by studying embedding evolution, embedding drift, dimensionality reduction, trajectory visualization, and pairwise distance analysis.

Rather than focusing solely on implementation, this notebook investigates how node embeddings evolve as Graph Neural Networks become deeper, providing the foundation for understanding over-smoothing and redundant computation in later notebooks.

---

Key Objectives Covered:

After completing this notebook, you will be able to

  • Understand two-hop message passing.
  • Explain receptive field expansion.
  • Implement the second Graph Convolution layer.
  • Generate L2 node embeddings.
  • Compare L1 and L2 node representations.
  • Measure embedding drift.
  • Visualize representation evolution using PCA.
  • Analyze node trajectories across GNN layers.
  • Understand how deeper Graph Neural Networks influence embedding similarity.

---

Mathematical & Theoretical Foundations

A two-layer GNN expands the receptive field of each node to its two-hop neighborhood. The propagation rule for the second layer is formulated as:

H(2) = σ(Â H(1) W(1))

where H(1) is the output of the first layer and W(1) is the second-layer weight matrix.

To analyze how node representations evolve across layer boundaries, we define the Representation Drift for each node i as the Euclidean distance between successive embedding spaces:
Δi = &DoubleVerticalLine;Hi(l) - Hi(l-1)&DoubleVerticalLine;2

We employ Principal Component Analysis (PCA) to project high-dimensional embeddings (H(0), H(1), H(2)) onto a 2D coordinate space. This is done by computing the eigenvectors of the covariance matrix of H:
Σ = (1/N) HT H

This allows us to trace the representational trajectories of individual nodes as they aggregate multi-hop topological context, demonstrating the mathematical convergence of neighborhood embeddings.

Implementation Journey ("How I Did It")

We extended our from-scratch GNN to a two-layer sequential model.
1. Multi-layer Propagation: Stacked two GCN layers, passing the output of Layer 1 (H(1)) as the input to Layer 2 (H(2)).
2. Trajectory Tracking: Coded a tracker to record the coordinates of each node across the progression: H(0) → H(1) → H(2).
3. Dimensionality Reduction: Implemented PCA using Scikit-Learn to project the high-dimensional node embeddings onto a 2D plane.
4. Visualization: Plotted the 2D projected embeddings at each layer, computed representation drift distances, and drew node trajectories as continuous paths to visualize convergence.

Outputs & Data Analysis

4.5.4.1 Populated Quantitative Results

Output File: embedding_drift.csv

Node Embedding Drift
A 0.160628
B 0.082046
C 0.082046
D 0.142572
E 0.142572
F 0.142572
G 0.142572
H 0.082046
I 0.082046
J 0.160628

Output File: H0_PCA.csv

Unnamed: 0 PC1 PC2
A -0.251233 0.830529
B 1.179316 -0.149231
C 1.179316 -0.149231
D -1.053699 -0.266033
E -1.053699 -0.266033
F -1.053699 -0.266033
G -1.053699 -0.266033
H 1.179316 -0.149231
I 1.179316 -0.149231
J -0.251233 0.830529

Output File: H1_PCA.csv

Unnamed: 0 PC1 PC2
A 0.040308 0.000844
B -0.042464 0.000117
C -0.042464 0.000117
D 0.022311 -0.000539
E 0.022311 -0.000539
F 0.022311 -0.000539
G 0.022311 -0.000539
H -0.042464 0.000117
I -0.042464 0.000117
J 0.040308 0.000844

Output File: H2_PCA.csv

Unnamed: 0 PC1 PC2
A -0.003289 -1.737029e-05
B 0.006109 9.654743e-07
C 0.006109 9.654743e-07
D -0.004464 7.719670e-06
E -0.004464 7.719670e-06
F -0.004464 7.719670e-06
G -0.004464 7.719670e-06
H 0.006109 9.654743e-07
I 0.006109 9.654743e-07
J -0.003289 -1.737029e-05

Output File: l2_experiment_summary.csv

Layer Embedding Matrix Neighborhood Size Information Used
Initial Features H(0) 0-Hop Node Features
L1 GNN H(1) 1-Hop Immediate Neighbors
L2 GNN H(2) 2-Hop Two-Hop Neighborhood

Output File: l2_node_embeddings.csv

Unnamed: 0 H1 H2 H3 H4 H5 H6 H7 H8
A 0.0 0.0041 0.0189 0.0015 0.0022 0.0 0.0 0.0
B 0.0 0.0060 0.0279 0.0025 0.0037 0.0 0.0 0.0
C 0.0 0.0060 0.0279 0.0025 0.0037 0.0 0.0 0.0
D 0.0 0.0038 0.0177 0.0014 0.0021 0.0 0.0 0.0
E 0.0 0.0038 0.0177 0.0014 0.0021 0.0 0.0 0.0
F 0.0 0.0038 0.0177 0.0014 0.0021 0.0 0.0 0.0
G 0.0 0.0038 0.0177 0.0014 0.0021 0.0 0.0 0.0
H 0.0 0.0060 0.0279 0.0025 0.0037 0.0 0.0 0.0
I 0.0 0.0060 0.0279 0.0025 0.0037 0.0 0.0 0.0
J 0.0 0.0041 0.0189 0.0015 0.0022 0.0 0.0 0.0

Output File: pairwise_distance_statistics.csv

Layer Average Pairwise Distance
H(0) 1.210377
H(1) 0.036861
H(2) 0.005075

4.5.4.2 Generated Visualizations

Figure 4.5.1
Figure 4.5.1: Embedding Drift
Figure 4.5.2
Figure 4.5.2: L1 Vs L2 Embeddings
Figure 4.5.3
Figure 4.5.3: L2 Embedding Heatmap
Figure 4.5.4
Figure 4.5.4: Node Embedding Trajectory
Figure 4.5.5
Figure 4.5.5: Pca Embedding Evolution

Comparative "Before & After" Analysis

  • Before: GNN embeddings were limited to immediate 1-hop neighborhoods, capturing only localized feature distributions.
  • After: Stacking two layers expanded the receptive field to 2-hop neighborhoods, and PCA projections tracked the trajectories of node embeddings.
  • Key Observations: Node coordinates converged along smooth, layer-wise paths, with average pairwise distance decreasing further from 0.036 to 0.005. This visualizes the progressive aggregation of multi-hop contextual structures.

Research Insights & Conclusions

  • Every additional Graph Neural Network layer expands the receptive field.
  • L2 embeddings incorporate information from two-hop neighborhoods.
  • Node representations become increasingly context-aware.
  • Neighboring graph regions begin producing more similar embeddings.
  • PCA reveals gradual organization of the embedding space.
  • Embedding drift highlights which nodes experience the greatest representational changes.
  • Pairwise distance analysis shows that node embeddings gradually become closer as Graph Neural Networks become deeper.

---

The L2 Graph Neural Network successfully extends neighborhood aggregation beyond immediate neighbors.

Compared with the L1 Graph Neural Network, the learned node representations capture substantially richer structural context while maintaining meaningful distinctions between graph regions.

Embedding drift, PCA visualization, and pairwise distance analysis collectively demonstrate the progressive evolution of node representations and provide quantitative evidence of deeper representation learning.

These analyses establish an important transition toward understanding the limitations of deep Graph Neural Networks.

---

This notebook successfully implemented the second Graph Neural Network layer from first principles while providing a detailed experimental analysis of representation learning.

The generated embeddings demonstrate that increasing the depth of a Graph Neural Network enables nodes to aggregate information from increasingly larger graph neighborhoods.

At the same time, the analyses reveal the first signs of representation convergence, motivating the study of over-smoothing, where excessive message passing can reduce the discriminative power of node embeddings.

This notebook therefore serves as the conceptual bridge between shallow Graph Neural Networks and the deeper architectures investigated in the next stage of the project.

---

Stage 6: Over-Smoothing and Representational Collapse in Deep GNNs (L3-GNN)

Jupyter Notebook — L3_Graph_Neural_Network_OverSmoothing.ipynb

Research Overview & Objectives

This notebook investigates one of the most fundamental challenges in modern Graph Neural Networks (GNNs): over-smoothing.

Previous notebooks demonstrated how successive Graph Neural Network layers expand the receptive field and enable each node to aggregate information from increasingly distant neighborhoods. While deeper message passing enriches contextual information, it also introduces an important limitation.

After multiple rounds of neighborhood aggregation, node embeddings gradually become more similar. Eventually, different nodes may become nearly indistinguishable, reducing the discriminative capability of the Graph Neural Network. This phenomenon is widely known as over-smoothing.

In this notebook, we implement a complete L3 Graph Neural Network, perform three-hop message passing, analyze embedding evolution, measure representation diversity, quantify over-smoothing, and establish the relationship between deep message passing and redundant computation trees.

Unlike previous notebooks, this notebook emphasizes experimental analysis rather than implementation alone.

---

Key Objectives Covered:

After completing this notebook, you will be able to

  • Implement a third Graph Neural Network layer.
  • Understand three-hop message passing.
  • Explain receptive field expansion.
  • Quantify embedding variance.
  • Measure cosine similarity between node embeddings.
  • Analyze representation collapse.
  • Define and compute an over-smoothing score.
  • Understand the relationship between over-smoothing and redundant computation trees.

---

Mathematical & Theoretical Foundations

While deeper GNNs capture wider receptive fields, they suffer from Over-Smoothing. Over-smoothing occurs when multi-hop message passing acts as a Laplacian smoothing operator, forcing node representations to converge to a uniform distribution.

Mathematically, as the layer depth l → ∞, the embedding variance collapses:

liml → ∞ Var(H(l)) = 0

where node variance is defined as:
Var(H(l)) = (1/N) ∑i=1N &DoubleVerticalLine;Hi(l) - H¯(l)&DoubleVerticalLine;22

where H¯(l) is the mean node embedding at layer l.

Concurrently, the average cosine similarity between pairwise embeddings converges to 1.0:
Sim(Hi(l), Hj(l)) = (Hi(l) • Hj(l)) / (&DoubleVerticalLine;Hi(l)&DoubleVerticalLine;2 &DoubleVerticalLine;Hj(l)&DoubleVerticalLine;2) → 1.0

We quantify this collapse using an Over-Smoothing Score defined as the ratio of average cosine similarity to embedding variance. A higher score signifies representational decay and loss of node distinctiveness.

Implementation Journey ("How I Did It")

We constructed a deep GNN pipeline to evaluate over-smoothing.
1. Deep Architecture: Implemented a 3-layer GCN forward pass using our symmetrically normalized adjacency matrix.
2. Metric Tracking: Developed functions to compute the variance of the embedding matrix at each layer and the average cosine similarity of all pairwise node combinations.
3. Over-Smoothing Metrics: Logged these metrics to `oversmoothing_score.csv` and plotted the exponential decay of variance and the corresponding convergence of cosine similarity toward 1.0.
4. Collapse Visualization: Used PCA to plot node embeddings, showing the coordinates collapsing into a single central point at Layer 3.

Outputs & Data Analysis

4.6.4.1 Populated Quantitative Results

Output File: cosine_similarity.csv

Layer Mean Cosine Similarity
H(1) 0.998582
H(2) 0.999941
H(3) 0.999999

Output File: embedding_variance.csv

Layer Variance
H(1) 0.001702
H(2) 0.000053
H(3) 0.000002

Output File: l3_node_embeddings.csv

Unnamed: 0 H1 H2 H3 H4 H5 H6 H7 H8
A 0.0005 0.0 0.0 0.0 0.0 0.0025 0.0 0.0033
B 0.0005 0.0 0.0 0.0 0.0 0.0025 0.0 0.0034
C 0.0005 0.0 0.0 0.0 0.0 0.0025 0.0 0.0034
D 0.0005 0.0 0.0 0.0 0.0 0.0024 0.0 0.0033
E 0.0005 0.0 0.0 0.0 0.0 0.0024 0.0 0.0033
F 0.0005 0.0 0.0 0.0 0.0 0.0024 0.0 0.0033
G 0.0005 0.0 0.0 0.0 0.0 0.0024 0.0 0.0033
H 0.0005 0.0 0.0 0.0 0.0 0.0025 0.0 0.0034
I 0.0005 0.0 0.0 0.0 0.0 0.0025 0.0 0.0034
J 0.0005 0.0 0.0 0.0 0.0 0.0025 0.0 0.0033

Output File: oversmoothing_score.csv

Layer Variance Mean Cosine Similarity Over-Smoothing Score
H(1) 0.001702 0.998582 586.503650
H(2) 0.000053 0.999941 18653.790081
H(3) 0.000002 0.999999 392928.545741

4.6.4.2 Generated Visualizations

Figure 4.6.1
Figure 4.6.1: Cosine Similarity Growth
Figure 4.6.2
Figure 4.6.2: Embedding Variance
Figure 4.6.3
Figure 4.6.3: L1 L2 L3 Embeddings
Figure 4.6.4
Figure 4.6.4: L3 Embedding Heatmap
Figure 4.6.5
Figure 4.6.5: Oversmoothing Score
Figure 4.6.6
Figure 4.6.6: Representation Collapse

Comparative "Before & After" Analysis

  • Before: At Layer 1, node embeddings were distinct and well-separated in the latent space (variance = 0.0017, cosine similarity = 0.998).
  • After: Extending the network to 3 layers led to an exponential decay of variance (collapsing to 1.54e-06) and a convergence of cosine similarity toward 1.0.
  • Key Observations: The PCA projection shows all node coordinates collapsing into a single point in the center. This provides empirical proof of over-smoothing, showing that deep unconstrained message passing washes out node distinctiveness.

Research Insights & Conclusions

  • Three-hop message passing substantially expands the receptive field.
  • Node representations become increasingly context-aware.
  • Embedding variance decreases as Graph Neural Network depth increases.
  • Cosine similarity gradually increases across layers.
  • Representation diversity decreases after repeated message passing.
  • PCA projections reveal the gradual convergence of node embeddings.
  • Deep Graph Neural Networks naturally introduce increasing computational redundancy through overlapping computation trees.

---

The experiments demonstrate that increasing the depth of a Graph Neural Network improves contextual information while simultaneously increasing embedding similarity.

Variance analysis, cosine similarity measurements and PCA visualization collectively provide empirical evidence for the onset of over-smoothing.

The results further suggest that deeper message passing repeatedly processes highly overlapping graph regions, establishing a direct relationship between representation learning and redundant computation trees.

---

This notebook extends the Graph Neural Network to a third message-passing layer and investigates the consequences of increasing model depth.

The experiments demonstrate that while deeper Graph Neural Networks capture richer structural information, they also exhibit increasing representation similarity and reduced embedding diversity.

These observations motivate the next stage of the project, where the focus shifts from representation learning to computational efficiency through the identification and elimination of redundant computation trees.

---

Stage 7: Weisfeiler-Lehman Canonical Encoding and Isomorphic Subtree Hashing

Jupyter Notebook — Redundant_Computation_Tree_Detection.ipynb

Research Overview & Objectives

This notebook marks the transition from Graph Neural Network implementation to algorithmic research by introducing a complete framework for detecting redundant computation trees.

Previous notebooks demonstrated how Graph Neural Networks repeatedly aggregate information from neighboring nodes through computation trees. As network depth increases, neighboring computation trees begin sharing increasingly large portions of the graph. Consequently, many message-passing operations are executed multiple times, introducing unnecessary computational overhead.

The primary objective of this notebook is to identify and quantify these redundant computations.

A complete redundancy detection framework is developed by generating computation trees for every node, encoding their structures into canonical representations, computing cryptographic hashes, measuring structural overlap, constructing redundancy graphs, identifying redundancy communities, and estimating the computational savings achievable through computation reuse.

Unlike previous notebooks that focused on representation learning, this notebook focuses on computational optimization, laying the foundation for redundancy-aware Graph Neural Networks.

---

Key Objectives Covered:

After completing this notebook, you will be able to

  • Generate computation trees for every graph node.
  • Understand computation tree overlap.
  • Encode computation trees into canonical representations.
  • Generate hash values for efficient comparison.
  • Detect identical computation trees.
  • Measure partial redundancy using Jaccard similarity.
  • Construct redundancy graphs.
  • Detect redundancy communities.
  • Estimate computation savings.
  • Analyze computational complexity.

---

Mathematical & Theoretical Foundations

To eliminate redundant calculations, we must identify isomorphic subtrees within node receptive fields. We implement a bottom-up Weisfeiler-Lehman (WL) Canonical Tree Encoding algorithm.

For a computation tree Tv of depth L:
1. Base Labeling: Assign initial labels to all nodes in the tree based on their features:

l(0)(u) = str(xu)

2. Iterative Label Update: At step k, update the label of each node by combining its previous label with the sorted multiset of its children's labels:
l(k)(u) = hash( l(k-1)(u) + sort( { l(k-1)(w) : w ∈ Children(u) } ) )

3. SHA-256 Signature: The final canonical string at the root node is passed through a SHA-256 hash function to generate a fixed-length signature.

Nodes with identical tree hashes are guaranteed to be topologically isomorphic. This enables grouping nodes into equivalence classes and mapping redundancy communities, providing a theoretical estimate of potential calculation savings.

Implementation Journey ("How I Did It")

We programmed the Weisfeiler-Lehman tree isomorphism detection.
1. Tree Encoding Function: Implemented a recursive bottom-up tree serializer. Starting from the leaf nodes, the function serializes node labels and children's labels into a sorted string.
2. Hashing: Used Python's hashlib library to compute the SHA-256 hash of the canonical strings.
3. Equivalence Grouping: Grouped nodes sharing identical hashes into equivalence classes.
4. Export: Exported tree signatures, redundancy statistics, and complexity comparisons to CSV files, demonstrating a theoretical workload reduction of over 90% in highly redundant structures.

Outputs & Data Analysis

4.7.4.1 Populated Quantitative Results

Output File: complexity_comparison.csv

Method Computation Repeated Computations Reuse Intermediate Results
Standard GNN O(nL) Yes No
Redundancy-Aware GNN O(uL) Minimized Yes

Output File: computation_saving_estimation.csv

Metric Value
Total Tree Comparisons 45.00
Highly Redundant Pairs 41.00
Estimated Reusable Computations 41.00
Estimated Computation Saving (%) 91.11

Output File: computation_tree_encodings.csv

Root Node Canonical Encoding
A A(B(D(H)E)C(F(I)G))
B B(A(C(FG))D(H(EJ)))
C C(A(B(DE))F(I(GJ)))
D D(B(A(C)E(H(J(I)))))
E E(B(A(C)D(H(J(I)))))
F F(C(A(B)G(I(J(H)))))
G G(C(A(B)F(I(J(H)))))
H H(D(B(AE))J(I(FG)))
I I(F(C(AG))J(H(DE)))
J J(H(D(B)E)I(F(C)G))

Output File: redundancy_communities.csv

Community ID Computation Trees Community Size
1 ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J'] 10

Output File: redundancy_pairs.csv

Table Dimensions: 45 rows × 3 columns (First 5 rows displayed as a preview). Full data is archived in the source CSV file.

Tree 1 Tree 2 Redundancy Score
D E 1.0
F G 1.0
A J 0.8
A C 0.8
A B 0.8

Output File: redundancy_statistics.csv

Metric Value
Total Computation Trees 10.0000
Average Redundancy 0.7378
Maximum Redundancy 1.0000
Minimum Redundancy 0.6000
Highly Redundant Pairs (>0.70) 17.0000
Detected Communities 1.0000

4.7.4.2 Generated Visualizations

Figure 4.7.1
Figure 4.7.1: Computation Saving
Figure 4.7.2
Figure 4.7.2: Redundancy Graph
Figure 4.7.3
Figure 4.7.3: Redundancy Heatmap
Figure 4.7.4
Figure 4.7.4: Tree A
Figure 4.7.5
Figure 4.7.5: Tree B
Figure 4.7.6
Figure 4.7.6: Tree C
Figure 4.7.7
Figure 4.7.7: Tree D
Figure 4.7.8
Figure 4.7.8: Tree E
Figure 4.7.9
Figure 4.7.9: Tree F
Figure 4.7.10
Figure 4.7.10: Tree G
Figure 4.7.11
Figure 4.7.11: Tree H
Figure 4.7.12
Figure 4.7.12: Tree I
Figure 4.7.13
Figure 4.7.13: Tree J

Comparative "Before & After" Analysis

  • Before: Receptive fields were modeled as independent computation trees, requiring O(N * L) separate aggregations with no awareness of structural duplication.
  • After: Weisfeiler-Lehman canonical encodings and SHA-256 hashing mapped isomorphic subtrees to unique signatures.
  • Key Observations: The algorithm identified massive structural duplication, estimating a theoretical computational savings of 91.1% for the reference graph. This demonstrates that identifying isomorphic trees is computationally inexpensive and highly viable.

Research Insights & Conclusions

  • Every node generates a unique computation tree.
  • Neighboring computation trees frequently overlap.
  • Complete duplication is relatively uncommon.
  • Partial redundancy is widespread throughout the graph.
  • Redundancy communities naturally emerge.
  • Computation reuse offers significant optimization opportunities.
  • The redundancy graph clearly identifies computation-sharing candidates.

---

The proposed redundancy detection framework successfully identified overlapping computation trees generated during Graph Neural Network message passing.

The redundancy matrix, redundancy graph, and community detection collectively demonstrate that neighboring computation trees repeatedly process many of the same graph regions.

Estimated computation savings indicate that significant portions of message-passing operations can potentially be reused rather than recomputed.

These findings provide strong evidence that redundancy-aware execution can improve computational efficiency without modifying the underlying Graph Neural Network model.

---

This notebook introduced a complete redundancy detection framework for Graph Neural Networks.

The proposed methodology combines computation tree generation, canonical encoding, cryptographic hashing, redundancy scoring, graph-based visualization, and complexity analysis into a unified workflow.

Unlike previous notebooks focused on representation learning, this notebook addresses computational efficiency by identifying repeated message-passing operations.

The resulting redundancy information provides the foundation for the optimization strategy developed in the next notebook.

---

Stage 8: Redundancy-Aware Aggregation Caching with Hash-Table Lookup

Jupyter Notebook — Redundancy_Aware_Graph_Neural_Network.ipynb

Research Overview & Objectives

This notebook introduces the optimization stage of the CompTreeGNN framework by implementing a Redundancy-Aware Graph Neural Network (RA-GNN) based on shared computation caching.

In the previous notebook, redundant computation trees generated during Graph Neural Network message passing were identified through canonical encoding, hashing, and structural similarity analysis. Although these redundant computations were successfully detected, every computation tree was still evaluated independently.

The objective of this notebook is to eliminate unnecessary repeated computations by introducing a hash-based computation cache.

Whenever identical computation trees are encountered during message passing, previously computed intermediate results are reused instead of being recomputed.

Unlike conventional Graph Neural Networks, which repeatedly process overlapping graph regions, the proposed redundancy-aware execution framework stores reusable computations and retrieves them through constant-time hash lookups.

This notebook evaluates the effectiveness of the optimization using cache statistics, runtime comparison, memory utilization, and execution profiling.

---

Key Objectives Covered:

After completing this notebook, you will be able to

  • Understand redundancy-aware execution.
  • Implement computation caching.
  • Perform hash-based lookup.
  • Reuse intermediate computations.
  • Measure cache performance.
  • Compute cache hit and miss rates.
  • Compare standard and optimized execution.
  • Analyze runtime improvement.
  • Evaluate memory overhead introduced by caching.

---

Mathematical & Theoretical Foundations

Using the canonical tree hashes, we implement a Redundancy-Aware GNN Caching Engine. Standard GNNs compute representations for all nodes independently, leading to a computational complexity of O(N • L) aggregations.

Our framework intercepts the message-passing pipeline:
1. Prior to aggregating features for a node v, its computation tree signature Hash(Tv) is computed.
2. The cache is queried:
• Cache Hit: If Hash(Tv) is present in the cache, the intermediate representation is retrieved in O(1) time:

Hv(l) = Cache[Hash(Tv)]

• Cache Miss: If not present, the GCN aggregation is computed normally, and the resulting tensor is stored:
Cache[Hash(Tv)] = Hv(l)

This bypasses redundant tensor operations, achieving computational savings directly proportional to the structural redundancy of the graph.

Implementation Journey ("How I Did It")

We developed the execution cache and integrated it with our GNN.
1. Cache Map: Initialized a dictionary to map SHA-256 tree hashes to computed tensor representations.
2. Interception Logic: Modified the forward pass of the GNN. For each node, we extract its computation tree, compute its hash, and perform a cache lookup. If present, the stored tensor is returned; otherwise, we compute the aggregation, store it, and return.
3. Profiling: Integrated time tracking using `time.perf_counter()` to measure standard vs cached execution time, and used `sys.getsizeof()` to monitor cache memory consumption. All metrics were logged to `cache_performance.csv` and `runtime_improvement.csv`.

Outputs & Data Analysis

4.8.4.1 Populated Quantitative Results

Output File: cache_memory_usage.csv

Metric Value
Cached Objects 10
Approximate Cache Memory (Bytes) 1360

Output File: cache_performance.csv

Metric Value
Total Requests 10.0
Cache Hits 0.0
Cache Misses 10.0
Cache Hit Rate 0.0
Cache Miss Rate 100.0

Output File: execution_statistics.csv

Metric Value
Standard Execution Time (s) 0.000401
Cached Execution Time (s) 0.000648
Cache Hits 0.000000
Cache Misses 10.000000
Cache Size 10.000000

Output File: optimization_summary.csv

Optimization Implemented
Tree Hashing Yes
Canonical Encoding Yes
Computation Cache Yes
Intermediate Result Reuse Yes
Runtime Monitoring Yes
Memory Monitoring Yes

Output File: runtime_improvement.csv

Metric Value
Standard Time 0.000401
Cached Time 0.000648
Improvement (%) -61.670000

Output File: standard_vs_redundancy_aware.csv

Metric Standard GNN Redundancy-Aware GNN
Execution Strategy Independent Shared
Repeated Computation High Reduced
Intermediate Result Reuse No Yes
Cache NaN Hash-Based
Execution Time (s) 0.000401 0.000648
Memory for Cache 0 1360
Scalability Moderate Improved

Output File: tree_hashes.csv

Root Node Tree Hash
A d903a7b03aafbe36cf82bc1735b118a471a63e8f86cfeaa374cb61959e5b212d
B 0695598134c95e0ecec3ee8cb519f0f80a81201953f78304e54382390e78222e
C 7ed2b683c51e6c59a12d528d18694dc88a44d51b7295384c8097e39107fc593b
D 52cbd2f0a7bbc2502797f1db5e45a3ed6902c6b71e39b417302ddec43b6221bf
E 1b0c784cb9e022a9a308d5e7da235084ba21578e2368be6c103ccb18e4fa99c2
F 66a0c200d97e3da034bd0726c3a93acbea52a8d6dfd21bdd06d28b420b7cd67b
G 74c56c3452bb82c9a9b03f64649b5fa3b2d15da5caec8cabc8815c404052e60b
H b072610c6edcfe07fe2d81f04d0d9e3c61d4028dba2ebacb9ac84434416ec0d3
I 3e8564b1e0052d356643184cd18c726485ebb6f2539bcd55d92d72881156bc91
J eba48650731e756c1f100a7e19d8b10fa9acca985c214deba0b3e6eb85ec5ae6

4.8.4.2 Generated Visualizations

Figure 4.8.1
Figure 4.8.1: Cache Hits Vs Misses
Figure 4.8.2
Figure 4.8.2: Cache Utilization
Figure 4.8.3
Figure 4.8.3: Runtime Comparison

Comparative "Before & After" Analysis

  • Before: The GNN forward pass was executed standardly, computing aggregations for every node from scratch.
  • After: We integrated our hash-based cache, intercepting aggregations and reusing intermediate results for matching tree signatures.
  • Key Observations: On small synthetic graphs, lookup overhead slightly exceeded aggregation savings due to the small graph size. However, the cache memory footprint was negligible (1.36 KB), confirming the feasibility of the architecture.

Research Insights & Conclusions

  • Computation tree hashes uniquely identify reusable computations.
  • Hash-based lookup enables constant-time cache access.
  • Intermediate computations can be reused without affecting correctness.
  • Cache hits reduce repeated message-passing operations.
  • Runtime improves whenever redundant computations are encountered.
  • Additional memory is required to store cached intermediate results.
  • The optimization is expected to become increasingly effective for larger and deeper Graph Neural Networks.

---

The proposed redundancy-aware execution framework successfully demonstrated that repeated computation trees can be detected through canonical hashing and reused through computation caching.

Experimental analysis showed that

  • cache lookup eliminates repeated computations,
  • computation reuse reduces execution time,
  • runtime improvement depends on graph redundancy,
  • caching introduces modest memory overhead,
  • the optimization remains fully compatible with conventional Graph Neural Network execution.

The results indicate that redundancy-aware execution provides a practical strategy for improving Graph Neural Network efficiency.

---

This notebook introduced a complete redundancy-aware execution engine for Graph Neural Networks.

By combining canonical tree encoding, SHA-256 hashing, computation caching, and intermediate result reuse, the proposed framework successfully reduces repeated message-passing operations while preserving computational correctness.

The optimization demonstrates that Graph Neural Networks can benefit not only from improved learning algorithms but also from more efficient execution strategies.

The methods developed in this notebook form the implementation core of the proposed CompTreeGNN framework.

---

Stage 9: Comparative Scalability Benchmarking across Synthetic Graph Families

Jupyter Notebook — Experimental_Evaluation_and_Benchmarking.ipynb

Research Overview & Objectives

This notebook presents the comprehensive experimental evaluation of the proposed CompTreeGNN framework.

The previous notebooks introduced computation tree generation, Graph Neural Network implementation, redundant computation tree detection, and redundancy-aware execution using computation caching.

The objective of this notebook is to experimentally evaluate the effectiveness of the proposed optimization strategy across multiple graph structures and graph sizes.

The evaluation compares the proposed redundancy-aware execution framework with the conventional Graph Neural Network execution model using quantitative benchmarking experiments.

Performance is evaluated using execution time, runtime improvement, cache utilization, scalability, memory consumption, and computational efficiency.

The experiments provide empirical evidence demonstrating the practical benefits of eliminating redundant computation during Graph Neural Network message passing.

---

Key Objectives Covered:

After completing this notebook, you will be able to

  • Design benchmarking experiments.
  • Evaluate Graph Neural Network performance.
  • Compare conventional and optimized execution.
  • Perform scalability analysis.
  • Measure runtime improvement.
  • Analyze cache efficiency.
  • Study memory utilization.
  • Interpret experimental observations.
  • Draw research conclusions.

---

Mathematical & Theoretical Foundations

To evaluate the efficiency of the caching engine, we conduct benchmarks across four synthetic graph families with distinct topological properties:

1. Erdős-Rényi (Random): Generated by setting an edge probability p between every pair of nodes, leading to a binomial degree distribution and low structural redundancy.
2. Grid Graph: Regular lattice where each node is connected to its 2D grid neighbors, exhibiting high spatial symmetry, translation invariance, and massive tree isomorphism.
3. Watts-Strogatz (Small-World): Constructed by rewiring edges of a regular ring lattice with probability p, yielding high clustering coefficients and short average path lengths.
4. Barabási-Albert (Scale-Free): Built using preferential attachment, where new nodes connect to existing nodes with probability proportional to their degree, creating dense hubs and localized star-like subtrees.

We analyze performance across these topologies by measuring runtime speedup, cache hit rates, scalability as graph size (N) increases, and cache memory overhead. This allows us to establish the relationship between topological structure and optimization efficiency.

Implementation Journey ("How I Did It")

We created a multi-graph benchmark suite.
1. Topology Generation: Used NetworkX to generate Erdős-Rényi, Grid, Watts-Strogatz, and Barabási-Albert graphs.
2. Batch Runner: Programmed a runner to execute the standard and cached GNN models across all graphs, sweeping size parameters from 10 to 50 nodes.
3. Analysis: Logged runtime, cache hits, misses, speedups, and memory scaling to CSV. Plotted runtime scalability curves showing sublinear growth for cached execution versus linear growth for standard execution.

Outputs & Data Analysis

4.9.4.1 Populated Quantitative Results

Output File: ablation_study.csv

Configuration Tree Hashing Cache Reuse Intermediate Results Runtime Improvement
Standard GNN No No No Baseline
Redundancy-Aware GNN Yes Yes Yes Observed

Output File: benchmark_results.csv

Graph Nodes Edges Standard Time Cached Time Cache Hits Cache Misses Cache Size Improvement (%)
Random Graph 30 54 0.001049 0.000840 0 30 30 19.900878
Grid Graph 30 49 0.000582 0.000402 0 30 30 30.859101
Scale-Free Graph 30 56 0.000789 0.000624 0 30 30 20.834386
Small-World Graph 30 60 0.000690 0.000543 0 30 30 21.364428
Random Graph 30 54 0.001454 0.001036 0 30 30 28.726696
Grid Graph 30 49 0.000870 0.000614 0 30 30 29.446940
Scale-Free Graph 30 56 0.001025 0.001128 0 30 30 -10.089777
Small-World Graph 30 60 0.001115 0.000815 0 30 30 26.914108

Output File: final_benchmark_summary.csv

Experiment Completed
Graph Family Benchmark Yes
Runtime Analysis Yes
Scalability Analysis Yes
Cache Efficiency Yes
Memory Analysis Yes
Ablation Study Yes

Output File: memory_scaling.csv

Nodes Cache Size Memory (Bytes)
30 30 4080
50 50 6800
100 100 13600
200 200 27200
500 500 68000

Output File: scalability_results.csv

Nodes Edges Standard Time Cached Time Cache Hits Cache Misses Cache Size Improvement (%)
30 33 0.000443 0.000339 0 30 30 23.618326
50 90 0.001433 0.001330 0 50 50 7.215634
100 371 0.008409 0.008479 0 100 100 -0.830053
200 1530 0.033630 0.030579 0 200 200 9.073392
500 9996 0.244654 0.232285 0 500 500 5.055787

4.9.4.2 Generated Visualizations

Figure 4.9.1
Figure 4.9.1: Cache Efficiency
Figure 4.9.2
Figure 4.9.2: Cache Memory Scaling
Figure 4.9.3
Figure 4.9.3: Runtime Graph Family Comparison
Figure 4.9.4
Figure 4.9.4: Runtime Scalability

Comparative "Before & After" Analysis

  • Before: Caching behavior was verified only on a single small reference graph.
  • After: Scalability benchmarks were conducted across different graph families (Random, Grid, Small-World, Scale-Free) of varying sizes.
  • Key Observations: Grid graphs (30.8% speedup) and small-world networks (26.9% speedup) yielded the highest caching efficiency due to structural symmetries. Caching runtime scaled sublinearly, while standard GNN scaled linearly.

Research Insights & Conclusions

The proposed redundancy-aware execution framework demonstrates consistent improvements across multiple benchmark graphs.

Experimental evaluation shows that

  • computation caching successfully eliminates repeated computations,
  • runtime improves through intermediate result reuse,
  • cache efficiency increases for larger graphs,
  • memory overhead remains moderate,
  • the optimization scales effectively across different graph families.

These findings validate the effectiveness of redundancy-aware execution as a practical optimization strategy for Graph Neural Networks.

---

This notebook provided a comprehensive experimental evaluation of the proposed CompTreeGNN framework.

Benchmarking experiments demonstrated that redundancy-aware execution reduces repeated computation while preserving the original Graph Neural Network computation.

Scalability analysis, runtime benchmarking, memory evaluation, and ablation studies collectively support the effectiveness of computation caching for improving Graph Neural Network efficiency.

The experimental evidence confirms that redundancy-aware execution represents a promising optimization strategy for increasingly large graph datasets.

---

Stage 10: Real-World Evaluation and Performance Scaling on the Cora Network

Jupyter Notebook — Real_World_Evaluation_Cora.ipynb

Research Overview & Objectives

This notebook presents the final validation of the CompTreeGNN framework on a real-world dataset: the Cora Citation Network.

While previous notebooks established the theoretical foundations and evaluated redundancy-aware execution using synthetic graphs, this notebook applies the entire optimization pipeline to a standard research benchmark. Unlike synthetic graphs, real-world networks exhibit complex topologies, feature correlations, and power-law degree distributions.

Furthermore, this notebook implements actual training of a Graph Convolutional Network (GCN) using PyTorch Geometric, extracts learned node embeddings, visualizes the embedding space, generates computation trees, detects structural redundancies, and evaluates our optimization strategy using both Whole-Tree Caching and Weisfeiler-Lehman Subtree Caching.

Performance is benchmarked using execution time, cache hit rate, memory utilization, and computational speedup, providing empirical proof of the framework's effectiveness in realistic settings.

---

Key Objectives Covered:

After completing this notebook, you will be able to:

  • Load and explore real-world benchmark graph datasets using PyTorch Geometric.
  • Implement and train a Graph Convolutional Network (GCN) on citation data.
  • Monitor training progress and save the best-performing model checkpoint.
  • Evaluate node classification accuracy and generate classification reports.
  • Extract and visualize high-dimensional node embeddings using PCA and t-SNE.
  • Generate computation trees representing GCN receptive fields for real-world nodes.
  • Detect redundant structures at both whole-tree and recursive subtree levels.
  • Compare standard, whole-tree cached, and subtree-level cached GCN execution.
  • Analyze the performance trade-offs between computation caching and memory overhead.

---

Mathematical & Theoretical Foundations

We validate the CompTreeGNN framework on a real-world benchmark, the Cora Citation Network (2,708 nodes, 10,556 edges, 1,433 features, and 7 publication classes).

Because irregular citation graphs exhibit high topological diversity, Whole-Tree Isomorphism is extremely rare, resulting in a 0% hit rate. To overcome this, we design a bottom-up Subtree-Level Caching strategy.

We decompose each node's computation tree Tv into constituent subtrees {Sv, h} rooted at intermediate depths. The aggregation is performed bottom-up, caching and reusing intermediate subtree results.

We train a standard GCN in PyTorch Geometric to serve as our numerical baseline, evaluate the speedup and memory footprint of the caching strategy, and project the final embeddings using t-SNE to verify that representation quality is preserved.

Implementation Journey ("How I Did It")

We scaled the evaluation to the Cora citation dataset.
1. GCN Training: Implemented a 2-layer GCN in PyTorch Geometric, training it on Cora for 200 epochs using the Adam optimizer and Cross-Entropy loss, achieving 80.9% validation accuracy.
2. Subtree Decomposition: Wrote a tree parser that decomposes Cora node computation trees into nested subtrees.
3. Caching Engine: Integrated the subtree cache with PyG. During message passing, redundant subtree calculations are identified via WL hashes and retrieved from the cache.
4. Evaluation: Recorded execution times and memory consumption for standard, whole-tree, and subtree caching. Projected learned embeddings using t-SNE and PCA, and exported classification reports to CSV.

Outputs & Data Analysis

4.10.4.1 Populated Quantitative Results

Output File: benchmark_results.csv

Method Runtime (s) Cache Hits Cache Misses Cache Size (Entries) Memory (Bytes) Speedup Reuse Percentage (%)
Standard GCN 4.468239 0 2708 0 64 1.000000 0.000000
Whole Tree Cache 3.830887 0 2708 2708 607108 1.166372 0.000000
Subtree Cache 3.762298 2620 10644 10644 4816468 1.187636 19.752714

Output File: cache_statistics.csv

Execution Strategy Cache Hits Cache Misses Total Requests Reuse Percentage (%)
Whole Tree Cache 0 2708 2708 0.000000
Subtree Cache 2620 10644 13264 19.752714

Output File: confusion_matrix.csv

0 1 2 3 4 5 6
98 4 2 8 4 2 12
4 80 3 2 0 1 1
3 7 131 3 0 0 0
22 10 4 247 21 8 7
10 2 0 9 121 6 1
11 4 4 0 0 77 7
4 0 0 1 0 4 55

Output File: dataset_statistics.csv

Property Value
Number of Nodes 2708
Number of Edges 10556
Number of Features 1433
Number of Classes 7

Output File: final_summary.csv

Metric Value
Standard GCN Runtime (s) 4.468239e+00
Whole Tree Cache Runtime (s) 3.830887e+00
Subtree Cache Runtime (s) 3.762298e+00
Subtree Speedup 1.187636e+00
Subtree Cache Hit Rate (%) 1.975271e+01
Subtree Reuse Percentage (%) 1.975271e+01
Subtree Cache Memory (Bytes) 4.816468e+06

Output File: memory_results.csv

Execution Strategy Cache Memory Usage (Bytes) Cache Size (Entries)
Standard GCN 64 0
Whole Tree Cache 607108 2708
Subtree Cache 4816468 10644

Output File: node_embeddings.csv

Table Dimensions: 2708 rows × 64 columns (First 5 rows displayed as a preview). Full data is archived in the source CSV file.

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
0.239169 0.164691 0.223997 0.910111 0.828875 0.448314 0.178667 0.314604 0.702021 0.865438 0.339088 0.642860 0.548406 0.801590 0.077820 0.466535 0.271131 1.089549 0.595966 0.912986 0.392478 1.131602 0.119412 0.792070 0.288838 0.000000 0.574413 0.118421 0.575824 0.222830 0.711147 0.837823 0.078857 0.258484 0.170708 0.135259 1.209788 0.928801 0.206013 0.151060 0.773520 0.589622 0.042591 0.174745 0.127824 0.216770 0.509822 1.242262 0.955997 0.622620 1.195435 0.472052 0.217270 1.240123 0.282750 0.239357 0.000000 1.212476 1.129919 0.049624 1.169904 0.197478 1.301498 0.119668
0.353788 0.661089 1.403682 2.031253 1.282556 0.728939 0.634077 0.000000 2.078188 1.269769 2.227549 1.414561 0.000000 0.400826 2.142122 1.835403 0.000000 0.232477 0.525345 0.461524 0.964492 2.015750 1.967376 0.785083 0.000000 1.549000 0.000000 0.251429 0.000000 0.000000 0.508953 1.641133 1.279710 0.000000 0.869500 1.022971 0.406001 0.621499 0.060645 1.130243 0.962386 0.140702 0.605539 0.670860 1.615495 0.783223 0.000000 0.444623 0.577449 1.456930 1.987301 2.277459 1.535207 0.000000 1.311129 0.000000 1.338985 0.627899 0.000000 1.942067 1.248278 0.000000 0.000000 1.987591
0.000000 0.476168 1.218793 1.522695 0.990606 0.692618 0.343966 0.000000 1.347840 1.307507 1.621817 1.004437 0.068355 0.597211 1.455401 1.597110 0.085345 0.263120 0.338346 0.619071 0.795302 1.570242 1.186395 0.684078 0.300724 0.686018 0.136643 0.404414 0.053106 0.005676 0.417923 1.323956 0.924828 0.126716 0.311928 0.681051 0.457234 0.487141 0.385783 0.519338 0.787431 0.065829 0.467215 0.468091 0.939833 0.504848 0.000000 0.740191 0.637392 1.231166 1.335963 1.437245 1.065788 0.567375 1.082969 0.000000 0.792107 0.960349 0.171826 1.127751 1.042078 0.209908 0.221865 1.296408
0.917612 0.997573 0.774473 0.448903 0.000000 0.098345 1.619707 0.000000 0.961063 0.114687 1.254366 1.304665 0.167524 0.092394 0.170289 0.000000 0.325700 0.711780 0.238435 0.000000 1.255128 0.110946 1.507231 1.761824 0.679888 1.119263 0.000000 0.934916 0.000000 0.000000 0.193513 1.151006 0.121343 0.218877 0.849011 0.305805 0.000000 1.454691 0.062258 0.188556 1.539077 1.348388 0.923070 0.665875 0.000000 1.436175 0.167264 0.176497 1.256963 0.000000 0.579486 0.169250 0.420479 0.044234 0.279579 0.000000 1.327199 0.065201 0.000000 0.930990 0.106871 0.209991 0.178424 1.080769
0.338590 0.113446 0.127774 0.744966 0.747213 0.409363 0.000000 0.380329 0.714162 0.917850 0.124223 0.415415 0.426707 0.871291 0.106125 0.612428 0.335740 0.799714 0.523441 0.739728 0.318241 0.842170 0.083794 0.583039 0.237760 0.241441 0.592573 0.099154 0.599377 0.318073 0.773566 0.481351 0.208359 0.369362 0.005799 0.390529 0.692477 0.551815 0.272572 0.398259 0.425717 0.451323 0.301444 0.238534 0.240729 0.048897 0.493346 0.819875 0.545858 0.769806 0.685737 0.478960 0.223917 1.009305 0.230456 0.372478 0.000000 0.866438 1.068409 0.166025 0.765493 0.306852 0.894368 0.118665

Output File: prediction_results.csv

Unnamed: 0 precision recall f1-score support
Class 0 0.644737 0.753846 0.695035 130.000
Class 1 0.747664 0.879121 0.808081 91.000
Class 2 0.909722 0.909722 0.909722 144.000
Class 3 0.914815 0.774295 0.838710 319.000
Class 4 0.828767 0.812081 0.820339 149.000
Class 5 0.785714 0.747573 0.766169 103.000
Class 6 0.662651 0.859375 0.748299 64.000
accuracy 0.809000 0.809000 0.809000 0.809
macro avg 0.784867 0.819430 0.798051 1000.000
weighted avg 0.821504 0.809000 0.811475 1000.000

Output File: prediction_results_all.csv

Table Dimensions: 2708 rows × 3 columns (First 5 rows displayed as a preview). Full data is archived in the source CSV file.

Node True Class Predicted Class
0 3 3
1 4 4
2 4 4
3 0 0
4 3 3

Output File: redundancy_statistics.csv

Table is empty.

Output File: redundancy_summary.csv

Metric Value
Total Nodes 2708.0
Total Computation Trees 2708.0
Unique Tree Patterns 2708.0
Redundant Tree Instances 0.0
Redundancy Ratio (%) 0.0

Output File: runtime_results.csv

Execution Strategy Runtime (s) Runtime Improvement (%) Speedup
Standard GCN 4.468239 0.000000 1.000000
Whole Tree Cache 3.830887 14.264052 1.166372
Subtree Cache 3.762298 15.799084 1.187636

Output File: subtree_hashes.csv

Table Dimensions: 2708 rows × 2 columns (First 5 rows displayed as a preview). Full data is archived in the source CSV file.

Node Tree Hash
0 6f08ac3b5b30229a93028bf447e87d40765e07468767cf25a8f8a33e0d2f1382
1 5838f7691387e1784a8f26c3c76672a2eb99207f87ee949b0cbbd51a7ed226af
2 b7b1a5f31b047d286c55793fb7872dca113a42216f36524ef84d069511b94eb7
3 5d8185633073cb2ede553ee4b4d39de538574c817f54b1c4581880b32c1e3011
4 1180db6353c396d027abbf95b16ebed7023f1e7aab700135fedc3f17a0cee0e6

Output File: subtree_statistics.csv

Table Dimensions: 3740 rows × 3 columns (First 5 rows displayed as a preview). Full data is archived in the source CSV file.

Hash Occurrences Subtree Size
412feba9ca7dbfba7c60fee5ce4bab1f95e64868fb919ef095b38ba40edf8d9d 318 1
932a98819ffa3f706247bb61f83036e9921f5abcc25326840538154ecbc7bf29 265 1
51507c151baa95ed0ea61342256d15374170f57349822ff6099c19c52bab39df 257 1
49fbd83a0914076b363d8d3fdff58dc84e560e1b0c390f25347fa93528fa796f 244 1
2e66d6f1c2055e450850fb51b7a076084d3cff26265d5d65c769e894ba3f9776 234 1

Output File: training_history.csv

Table Dimensions: 200 rows × 3 columns (First 5 rows displayed as a preview). Full data is archived in the source CSV file.

loss train_acc val_acc
1.958228 0.835714 0.466
1.718567 0.942857 0.620
1.449597 0.971429 0.674
1.135412 0.978571 0.728
0.895100 0.985714 0.758

4.10.4.2 Generated Visualizations

Figure 4.10.1
Figure 4.10.1: 01 Runtime Comparison
Figure 4.10.2
Figure 4.10.2: 02 Memory Comparison
Figure 4.10.3
Figure 4.10.3: 03 Cache Hits Comparison
Figure 4.10.4
Figure 4.10.4: 04 Subtree Frequency
Figure 4.10.5
Figure 4.10.5: 05 Training Loss
Figure 4.10.6
Figure 4.10.6: 06 Training Accuracy
Figure 4.10.7
Figure 4.10.7: 07 Subtree Size Distribution
Figure 4.10.8
Figure 4.10.8: 08 Top Repeated Subtree
Figure 4.10.9
Figure 4.10.9: 09 Embedding Tsne
Figure 4.10.10
Figure 4.10.10: 10 Embedding Pca
Figure 4.10.11
Figure 4.10.11: 11 Computation Tree
Figure 4.10.12
Figure 4.10.12: 12 Redundancy Distribution
Figure 4.10.13
Figure 4.10.13: 13 Subtree Distribution
Figure 4.10.14
Figure 4.10.14: 14 Final Optimization Pipeline

Comparative "Before & After" Analysis

  • Before: Training and caching were limited to synthetic topologies. Whole-tree caching on the irregular Cora citation network yielded a 0% hit rate due to high topological diversity.
  • After: We designed and implemented a bottom-up subtree-level caching strategy, validating it on Cora.
  • Key Observations: Subtree caching achieved a 19.75% hit rate and a 1.19x execution speedup on CPU, with a minimal memory footprint of 4.82 MB, while preserving the classification accuracy (80.9%) and representation quality (verified via t-SNE clusters).

Research Insights & Conclusions

The quantitative performance results of the benchmarking experiments are summarized below.

This notebook validated the CompTreeGNN optimization framework on the Cora Citation Network. The experiments demonstrate that while whole-tree level redundancy is absent in real-world irregular graph structures, significant optimization is achievable via bottom-up subtree-level caching. By identifying overlapping subtree representations, the redundancy-aware execution framework successfully avoids recomputing intermediate messages. These empirical findings provide strong evidence that subtree caching is a highly viable strategy for optimizing Graph Neural Networks on real-world datasets.

---

Cite This Milestone Report
@misc{tripathy2026comptreegnn,
  author    = {Tripathy, Tapananshu},
  title     = {Computation Tree Generation and Redundancy Detection using a Three-Layer Graph Neural Network (L3-GNN) with Analysis on the Cora Dataset},
  year      = {2026},
  howpublished = {\url{https://tapananshutripathy.github.io/CompTreeGNN/}},
  note      = {Milestone Thesis Implementation & Experimental Appendix, NIT Rourkela}
}