# mgold/fibonacci-heap architecture

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

- Interactive diagram: https://gitdiagram.com/mgold/fibonacci-heap
- Repository: https://github.com/mgold/fibonacci-heap

## Overview

#### Purpose and entry point
This is a C benchmark/implementation project comparing a Fibonacci heap with a naive array-based heap. `main.c` is the executable entry point; heap selection is compile-time controlled through `use.h`.

#### Heap abstraction boundary
`heap.h` defines the common heap-facing interface used by the driver, allowing `main.c` to operate independently of the chosen implementation. `use.h` selects and exposes either the Fibonacci or naive implementation.

Paths: `heap.h`, `use.h`, `main.c`

#### Fibonacci heap implementation
The primary data structure is implemented in `fiboHeap.c`. It provides Fibonacci-heap operations, including minimum removal and the amortized-efficient insertion, merge, and decrease-key behavior described by the project.

Paths: `fiboHeap.c`, `heap.h`

#### Node representation
Heap elements and Fibonacci heap tree/list links are represented separately from heap operations in `node.c` and `node.h`. This is the structural boundary for node allocation and pointer-based relationships used by the Fibonacci heap.

Paths: `node.c`, `node.h`, `fiboHeap.c`

#### Naive comparison implementation
`naiveHeap.c` provides the alternative array-based heap used as the performance baseline. It is selected through the same interface/configuration path as the Fibonacci heap.

Paths: `naiveHeap.c`, `heap.h`, `use.h`

#### Execution and measurement flow
The driver in `main.c` invokes the selected heap API, exercises heap operations, and emits benchmark data to `plotData.txt`. The supplied `compile` and `test.sh` support building/running this C program, but the core runtime is a native compiled executable with no service dependencies.

Paths: `main.c`, `plotData.txt`, `compile`

#### Reporting pipeline
Benchmark output is consumed by the Gnuplot script `plots.p`; the academic report source in `README.tex` incorporates the generated plots. The documented reporting workflow depends on Gnuplot and LaTeX/PDFLaTeX, separate from the heap executable itself.

Paths: `plotData.txt`, `plots.p`, `README.tex`

Main entry points: [`use.h`](https://github.com/mgold/fibonacci-heap/blob/master/use.h) (Implementation selector), [`main.c`](https://github.com/mgold/fibonacci-heap/blob/master/main.c) (Benchmark driver), [`fiboHeap.c`](https://github.com/mgold/fibonacci-heap/blob/master/fiboHeap.c) (Fibonacci heap), [`heap.h`](https://github.com/mgold/fibonacci-heap/blob/master/heap.h) (Heap interface)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Benchmark runtime"]
  node_compile["Build script"]
  node_main["Benchmark driver<br/>C entry point<br/>[main.c]"]
  node_use{{"Implementation selector<br/>compile-time selector<br/>[use.h]"}}
  node_heap_api["Heap interface<br/>C API<br/>[heap.h]"]
end

subgraph group_implementations["Heap implementations"]
  node_fibo_heap["Fibonacci heap<br/>heap implementation<br/>[fiboHeap.c]"]
  node_node_api["Heap node model<br/>node interface<br/>[node.h]"]
  node_node_impl["Node operations<br/>node implementation<br/>[node.c]"]
  node_naive_heap["Naive array heap<br/>heap implementation<br/>[naiveHeap.c]"]
end

subgraph group_reporting["Reporting pipeline"]
  node_plot_data["Benchmark data<br/>measurement output<br/>[plotData.txt]"]
  node_plots["Gnuplot script<br/>plot generator<br/>[plots.p]"]
  node_report["Academic report<br/>LaTeX source<br/>[README.tex]"]
end

node_compile -->|"builds"| node_main
node_main -->|"includes"| node_use
node_use -->|"exposes"| node_heap_api
node_use -.->|"selects"| node_fibo_heap
node_use -.->|"selects"| node_naive_heap
node_fibo_heap -->|"implements"| node_heap_api
node_naive_heap -->|"implements"| node_heap_api
node_fibo_heap -->|"uses"| node_node_api
node_node_impl -->|"implements"| node_node_api
node_main -->|"writes"| node_plot_data
node_plot_data -->|"input"| node_plots
node_plots -->|"generated plots"| node_report

click node_compile "https://github.com/mgold/fibonacci-heap/blob/master/compile"
click node_main "https://github.com/mgold/fibonacci-heap/blob/master/main.c"
click node_use "https://github.com/mgold/fibonacci-heap/blob/master/use.h"
click node_heap_api "https://github.com/mgold/fibonacci-heap/blob/master/heap.h"
click node_fibo_heap "https://github.com/mgold/fibonacci-heap/blob/master/fiboHeap.c"
click node_node_api "https://github.com/mgold/fibonacci-heap/blob/master/node.h"
click node_node_impl "https://github.com/mgold/fibonacci-heap/blob/master/node.c"
click node_naive_heap "https://github.com/mgold/fibonacci-heap/blob/master/naiveHeap.c"
click node_plot_data "https://github.com/mgold/fibonacci-heap/blob/master/plotData.txt"
click node_plots "https://github.com/mgold/fibonacci-heap/blob/master/plots.p"
click node_report "https://github.com/mgold/fibonacci-heap/blob/master/README.tex"

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_compile,node_main,node_use,node_heap_api toneBlue
class node_fibo_heap,node_node_api,node_node_impl,node_naive_heap toneAmber
class node_plot_data,node_plots,node_report toneMint
```

## Components

### Benchmark runtime

- [Build script](https://github.com/mgold/fibonacci-heap/blob/master/compile): build script · Builds the native benchmark executable. · `compile`
- [Benchmark driver](https://github.com/mgold/fibonacci-heap/blob/master/main.c): C entry point · Exercises the selected heap and emits measurements. · `main.c`
- [Implementation selector](https://github.com/mgold/fibonacci-heap/blob/master/use.h): compile-time selector · Exposes the chosen heap implementation. · `use.h`
- [Heap interface](https://github.com/mgold/fibonacci-heap/blob/master/heap.h): C API · Common heap-facing interface for the driver. · `heap.h`

### Heap implementations

- [Fibonacci heap](https://github.com/mgold/fibonacci-heap/blob/master/fiboHeap.c): heap implementation · Supports amortized-efficient insert, merge, decrease-key, and min removal. · `fiboHeap.c`
- [Heap node model](https://github.com/mgold/fibonacci-heap/blob/master/node.h): node interface · Defines node structure and pointer relationships. · `node.h`
- [Node operations](https://github.com/mgold/fibonacci-heap/blob/master/node.c): node implementation · Allocates and manages Fibonacci heap nodes. · `node.c`
- [Naive array heap](https://github.com/mgold/fibonacci-heap/blob/master/naiveHeap.c): heap implementation · Array-based performance baseline. · `naiveHeap.c`

### Reporting pipeline

- [Benchmark data](https://github.com/mgold/fibonacci-heap/blob/master/plotData.txt): measurement output · `plotData.txt`
- [Gnuplot script](https://github.com/mgold/fibonacci-heap/blob/master/plots.p): plot generator · Turns benchmark data into plots. · `plots.p`
- [Academic report](https://github.com/mgold/fibonacci-heap/blob/master/README.tex): LaTeX source · Incorporates generated benchmark plots. · `README.tex`

## Connections

- Build script → Benchmark driver: builds
- Benchmark driver → Implementation selector: includes
- Implementation selector → Heap interface: exposes
- Implementation selector → Fibonacci heap: selects
- Implementation selector → Naive array heap: selects
- Fibonacci heap → Heap interface: implements
- Naive array heap → Heap interface: implements
- Fibonacci heap → Heap node model: uses
- Node operations → Heap node model: implements
- Benchmark driver → Benchmark data: writes
- Benchmark data → Gnuplot script: input
- Gnuplot script → Academic report: generated plots
