← Projects
NMBU
Software2025

Graph Analytics Framework in C++

High-performance graph processing library in C++ featuring strongly connected component detection, diamond pattern analysis, and benchmarked graph representations.

Developed as part of INF205 at NMBU, this project focused on designing efficient graph data structures and implementing graph algorithms that operate independently of the underlying storage representation. The framework supports both incidence-list and adjacency-matrix graph implementations through a common abstract interface, enabling algorithms to run unchanged on either backend.

Graph framework architecture diagram

Architecture

Architecture of the graph framework showing the AbstractGraph interface, linked-list and adjacency-matrix implementations, and algorithm modules for Tarjan SCC detection and diamond pattern search.

The Challenge

The objective was to build a flexible graph framework capable of storing large directed graphs, supporting multiple internal representations, and running analysis algorithms without coupling to a specific backend. A key design requirement was ensuring that algorithms depended only on an abstract graph interface rather than a specific data structure implementation.

Graph Representations

The framework contains two independent graph implementations sharing a common abstract interface:

  • Incidence List Graph — linked Node and Edge objects with incoming/outgoing edge lists; efficient traversal, supports multi-edges
  • Adjacency Matrix Graph — 3D matrix structure with constant-time edge lookup; supports directed multigraphs

Algorithms Implemented

  • Tarjan's Strongly Connected Components (SCC)
  • Diamond pattern detection
  • Depth-First Search (DFS) traversal
  • Graph reachability queries

Tarjan's Strongly Connected Components

Tarjan's algorithm finds all groups of nodes where every node can reach every other node in the group:

SCC #1: {A, B, C} via A → B → C → A
SCC #2: {D, E} via D → E → D

Implemented from scratch using depth-first search, discovery indices, low-link values, and an explicit stack. The algorithm runs in O(V + E) time and operates transparently on both graph implementations through a shared abstract interface.

Diamond Pattern Detection

Diamond detection finds pairs of nodes connected by two parallel paths that diverge and then converge — a structure common in knowledge graphs and dependency analysis:

A → B → D
A → C → D

Two distinct paths connect A and D: A → B → D and A → C → D. The query engine searches for this structure across the full graph using DFS-based path enumeration, supporting custom edge-label sequences for flexible pattern matching.

Tarjan SCC runtime benchmark

Performance Analysis

Runtime comparison of Tarjan's strongly connected components algorithm using adjacency-list and adjacency-matrix graph representations. The same algorithm shows significantly different scaling behaviour depending on the underlying data structure.

Diamond pattern detection benchmark

Benchmarking diamond-pattern detection across graph sizes using both graph implementations. Results were visualized using log-log plots to analyze asymptotic behaviour and compare theoretical and observed complexity growth.

Memory Management

The linked graph implementation manages dynamically allocated nodes and edges using raw pointers. To ensure safe ownership semantics, the project implements the full Rule of Five: destructor, copy constructor, copy assignment operator, move constructor, and move assignment operator. Deep-copy functionality reconstructs all node-edge relationships while move operations efficiently transfer ownership.

Key Contributions

  • Designed an extensible graph framework using abstract interfaces and polymorphism
  • Implemented adjacency-list and adjacency-matrix graph representations
  • Developed Tarjan's SCC algorithm from scratch
  • Implemented diamond-pattern detection using DFS
  • Conducted runtime benchmarking and complexity analysis
  • Implemented full Rule of Five memory management
  • Created graph import/export functionality

Stack

C++Object-Oriented ProgrammingGraph TheoryTarjan's AlgorithmDepth-First Search (DFS)Adjacency ListsAdjacency MatricesPolymorphismRule of FivePerformance AnalysisGNU MakeSTL