# hvdieren/graphgrind architecture

> Architecture diagram of the GitHub repository hvdieren/graphgrind, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/hvdieren/graphgrind
- Repository: https://github.com/hvdieren/graphgrind

## Overview

#### Purpose and execution model
GraphGrind is a NUMA-aware, shared-memory graph-processing framework derived from Ligra. It builds standalone native executables for graph algorithms; each executable reads a graph, runs a templated `Compute(graph, start)` workload repeatedly, and reports timing. Primary entry points are algorithm translation units such as `BFS.C`, `BellmanFord.C`, `PageRank.C`, `Components.C`, and `BC.C`.

#### Application layer
Algorithm files define per-algorithm state and frontier update functors, then invoke Ligra-style traversal primitives:
- Unweighted traversal/centrality: `BFS.C`, `BC.C`, `Components.C`
- Weighted shortest paths: `BellmanFord.C`
- Iterative ranking: `PageRank.C`, `PageRankDelta.C`
- Sparse matrix/vector-style graph computation: `SPMV.C`
- Partition/load-balancing benchmark or implementation: `BP.C`

These are independently compiled programs rather than modules behind a shared server or API.

#### Core graph representation and ingestion
The graph abstraction is centered in `graph.h`, with input parsing and graph construction provided by `IO.h`. Inputs support PBBS text adjacency graphs and a three-file binary CSR layout (`.config`, `.idx`, `.adj`), with optional weighted text input. Vertex-ID and offset widths are compile-time choices. Sample graph datasets are included as `rMatGraph_J_5_100` and `rMatGraph_WJ_5_100`.

#### Traversal and frontier engine
`ligra.h` supplies the main programming model: `vertexSubset` frontiers plus `edgeMap`, `vertexMap`, and `vertexFilter`. `edgeMap` selects sparse or dense traversal based on active-frontier work and supports read-oriented dense and write-oriented dense-forward modes. Applications provide `update`, atomic update, and destination-condition callbacks; this is the central boundary between generic parallel traversal machinery and algorithm-specific semantics.
Grounding paths: `ligra.h`, `graph.h`, `parallel.h`.

#### NUMA-aware partitioning and memory placement
GraphGrind’s primary extension over Ligra is NUMA-conscious graph partitioning, allocation, and execution support. `ligra-numa.h` integrates NUMA-aware traversal/runtime behavior; `partitioner.h` defines partitioning responsibilities; `graph-numa.h` carries NUMA-specific graph representation or access support. Memory utilities in `mm.h` and `reuse.h` support allocation/reuse behavior relevant to high-throughput iterative processing.

#### Parallel runtime and hardware integration
Execution relies on a Clang/CilkPlus-compatible toolchain and extended Cilk runtime, using parallel loops and task execution through `parallel.h`. NUMA facilities are expected from the host/platform runtime. Optional performance-counter integration is represented by `papi_code.h`; timing support is in `gettime.h`. There is no network service dependency: computation is in-process over shared memory.

#### Driver, controls, and build boundary
Each executable obtains runtime options—graph format, symmetric-graph mode, source vertex, and timing rounds—through `parseCommandLine.h` and input code. `Makefile` is the build orchestration point that selects and compiles application targets. The `bin` directory is the expected output location for built artifacts, while root-level executable names may also be produced by the build environment.

Main entry points: [`ligra.h`](https://github.com/hvdieren/graphgrind/blob/ics17/ligra.h) (Ligra traversal API), [`Makefile`](https://github.com/hvdieren/graphgrind/tree/ics17/Makefile) (Native build orchestration), [`ligra-numa.h`](https://github.com/hvdieren/graphgrind/blob/ics17/ligra-numa.h) (NUMA traversal support), [`IO.h`](https://github.com/hvdieren/graphgrind/blob/ics17/IO.h) (Graph input and construction)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_apps["Algorithm executables"]
  node_bfs["BFS<br/>algorithm<br/>[BFS.C]"]
  node_centrality_connectivity["BC and Components<br/>algorithms<br/>[BC.C]"]
  node_shortest_paths["Bellman-Ford<br/>algorithm<br/>[BellmanFord.C]"]
  node_ranking["PageRank workloads<br/>algorithms<br/>[PageRank.C]"]
  node_sparse_compute["SPMV and BP<br/>algorithms<br/>[SPMV.C]"]
end

subgraph group_core["Graph processing core"]
  node_ligra{{"Ligra traversal API<br/>traversal engine<br/>[ligra.h]"}}
  node_graph[("Graph abstraction<br/>graph representation<br/>[graph.h]")]
  node_numa_traversal{{"NUMA traversal support<br/>NUMA engine<br/>[ligra-numa.h]"}}
  node_partitioner["Graph partitioner<br/>partitioning<br/>[partitioner.h]"]
  node_numa_graph[("NUMA graph access<br/>graph representation<br/>[graph-numa.h]")]
  node_memory["Allocation and reuse<br/>memory management<br/>[mm.h]"]
end

subgraph group_runtime["Runtime and measurement"]
  node_parallel{{"Cilk parallel runtime<br/>[parallel.h]"}}
  node_measurement["Timing and counters<br/>instrumentation<br/>[gettime.h]"]
end

subgraph group_io_build["Input and build"]
  node_cli["Runtime options<br/>command-line controls<br/>[parseCommandLine.h]"]
  node_graph_io["Graph input and construction<br/>ingestion<br/>[IO.h]"]
  node_datasets[("Sample graph datasets")]
  node_makefile["Native build orchestration<br/>build system"]
  node_bin["Built executables<br/>native binaries"]
end

node_bfs -->|"uses traversal primitives"| node_ligra
node_centrality_connectivity -->|"uses traversal primitives"| node_ligra
node_shortest_paths -->|"uses traversal primitives"| node_ligra
node_ranking -->|"uses traversal primitives"| node_ligra
node_sparse_compute -->|"uses traversal primitives"| node_ligra
node_ligra -->|"traverses"| node_graph
node_ligra -->|"parallelizes work"| node_parallel
node_numa_traversal -->|"extends"| node_ligra
node_numa_traversal -->|"uses partitions"| node_partitioner
node_numa_traversal -->|"accesses"| node_numa_graph
node_partitioner -->|"drives placement"| node_memory
node_numa_graph -->|"specializes"| node_graph
node_graph_io -->|"constructs"| node_graph
node_datasets -->|"input graphs"| node_graph_io
node_cli -->|"selects format"| node_graph_io
node_measurement -.->|"measures execution"| node_parallel
node_makefile -->|"builds"| node_bfs
node_makefile -->|"builds"| node_centrality_connectivity
node_makefile -->|"builds"| node_shortest_paths
node_makefile -->|"builds"| node_ranking
node_makefile -->|"builds"| node_sparse_compute
node_makefile -->|"outputs"| node_bin

click node_bfs "https://github.com/hvdieren/graphgrind/blob/ics17/BFS.C"
click node_centrality_connectivity "https://github.com/hvdieren/graphgrind/blob/ics17/BC.C"
click node_shortest_paths "https://github.com/hvdieren/graphgrind/blob/ics17/BellmanFord.C"
click node_ranking "https://github.com/hvdieren/graphgrind/blob/ics17/PageRank.C"
click node_sparse_compute "https://github.com/hvdieren/graphgrind/blob/ics17/SPMV.C"
click node_ligra "https://github.com/hvdieren/graphgrind/blob/ics17/ligra.h"
click node_graph "https://github.com/hvdieren/graphgrind/blob/ics17/graph.h"
click node_numa_traversal "https://github.com/hvdieren/graphgrind/blob/ics17/ligra-numa.h"
click node_partitioner "https://github.com/hvdieren/graphgrind/blob/ics17/partitioner.h"
click node_numa_graph "https://github.com/hvdieren/graphgrind/blob/ics17/graph-numa.h"
click node_memory "https://github.com/hvdieren/graphgrind/blob/ics17/mm.h"
click node_parallel "https://github.com/hvdieren/graphgrind/blob/ics17/parallel.h"
click node_measurement "https://github.com/hvdieren/graphgrind/blob/ics17/gettime.h"
click node_cli "https://github.com/hvdieren/graphgrind/blob/ics17/parseCommandLine.h"
click node_graph_io "https://github.com/hvdieren/graphgrind/blob/ics17/IO.h"
click node_datasets "https://github.com/hvdieren/graphgrind/tree/ics17/rMatGraph_J_5_100"
click node_makefile "https://github.com/hvdieren/graphgrind/tree/ics17/Makefile"
click node_bin "https://github.com/hvdieren/graphgrind/tree/ics17/bin"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_bfs,node_centrality_connectivity,node_shortest_paths,node_ranking,node_sparse_compute toneBlue
class node_ligra,node_graph,node_numa_traversal,node_partitioner,node_numa_graph,node_memory toneAmber
class node_parallel,node_measurement toneMint
class node_cli,node_graph_io,node_datasets,node_makefile,node_bin toneRose
```

## Components

### Algorithm executables

Independently compiled graph workloads.

- [BFS](https://github.com/hvdieren/graphgrind/blob/ics17/BFS.C): algorithm · Unweighted frontier traversal executable. · `BFS.C`
- [BC and Components](https://github.com/hvdieren/graphgrind/blob/ics17/BC.C): algorithms · Centrality and connectivity frontier workloads. · `BC.C`
- [Bellman-Ford](https://github.com/hvdieren/graphgrind/blob/ics17/BellmanFord.C): algorithm · Weighted shortest-path executable. · `BellmanFord.C`
- [PageRank workloads](https://github.com/hvdieren/graphgrind/blob/ics17/PageRank.C): algorithms · Iterative ranking executables. · `PageRank.C`
- [SPMV and BP](https://github.com/hvdieren/graphgrind/blob/ics17/SPMV.C): algorithms · Sparse computation and partitioning/load-balancing workloads. · `SPMV.C`

### Graph processing core

Shared graph, traversal, and NUMA mechanisms.

- [Ligra traversal API](https://github.com/hvdieren/graphgrind/blob/ics17/ligra.h): traversal engine · vertexSubset frontiers and edgeMap, vertexMap, and vertexFilter. · `ligra.h`
- [Graph abstraction](https://github.com/hvdieren/graphgrind/blob/ics17/graph.h): graph representation · Shared-memory graph structure with compile-time ID and offset widths. · `graph.h`
- [NUMA traversal support](https://github.com/hvdieren/graphgrind/blob/ics17/ligra-numa.h): NUMA engine · NUMA-aware traversal and runtime integration. · `ligra-numa.h`
- [Graph partitioner](https://github.com/hvdieren/graphgrind/blob/ics17/partitioner.h): partitioning · Defines NUMA graph partitioning responsibilities. · `partitioner.h`
- [NUMA graph access](https://github.com/hvdieren/graphgrind/blob/ics17/graph-numa.h): graph representation · NUMA-specific graph representation or access support. · `graph-numa.h`
- [Allocation and reuse](https://github.com/hvdieren/graphgrind/blob/ics17/mm.h): memory management · Memory placement, allocation, and iterative reuse utilities. · `mm.h`

### Runtime and measurement

In-process parallel execution and optional instrumentation.

- [Cilk parallel runtime](https://github.com/hvdieren/graphgrind/blob/ics17/parallel.h): parallel runtime · Parallel loops and task execution through CilkPlus-compatible support. · `parallel.h`
- [Timing and counters](https://github.com/hvdieren/graphgrind/blob/ics17/gettime.h): instrumentation · Timing with optional PAPI performance counters. · `gettime.h`

### Input and build

Graph ingestion, controls, and native build output.

- [Runtime options](https://github.com/hvdieren/graphgrind/blob/ics17/parseCommandLine.h): command-line controls · Selects graph format, symmetry, source vertex, and timing rounds. · `parseCommandLine.h`
- [Graph input and construction](https://github.com/hvdieren/graphgrind/blob/ics17/IO.h): ingestion · Parses PBBS text, weighted text, and three-file binary CSR graphs. · `IO.h`
- [Sample graph datasets](https://github.com/hvdieren/graphgrind/tree/ics17/rMatGraph_J_5_100): graph data · Includes rMatGraph_J_5_100 and rMatGraph_WJ_5_100. · `rMatGraph_J_5_100`
- [Native build orchestration](https://github.com/hvdieren/graphgrind/tree/ics17/Makefile): build system · Selects and compiles algorithm targets. · `Makefile`
- [Built executables](https://github.com/hvdieren/graphgrind/tree/ics17/bin): native binaries · Expected output directory for standalone executables. · `bin`

## Connections

- BFS → Ligra traversal API: uses traversal primitives
- BC and Components → Ligra traversal API: uses traversal primitives
- Bellman-Ford → Ligra traversal API: uses traversal primitives
- PageRank workloads → Ligra traversal API: uses traversal primitives
- SPMV and BP → Ligra traversal API: uses traversal primitives
- Ligra traversal API → Graph abstraction: traverses
- Ligra traversal API → Cilk parallel runtime: parallelizes work
- NUMA traversal support → Ligra traversal API: extends
- NUMA traversal support → Graph partitioner: uses partitions
- NUMA traversal support → NUMA graph access: accesses
- Graph partitioner → Allocation and reuse: drives placement
- NUMA graph access → Graph abstraction: specializes
- Graph input and construction → Graph abstraction: constructs
- Sample graph datasets → Graph input and construction: input graphs
- Runtime options → Graph input and construction: selects format
- Timing and counters → Cilk parallel runtime: measures execution
- Native build orchestration → BFS: builds
- Native build orchestration → BC and Components: builds
- Native build orchestration → Bellman-Ford: builds
- Native build orchestration → PageRank workloads: builds
- Native build orchestration → SPMV and BP: builds
- Native build orchestration → Built executables: outputs
