# hvmegy/icpc-notebook architecture

> Architecture diagram of the GitHub repository hvmegy/icpc-notebook, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/hvmegy/icpc-notebook
- Repository: https://github.com/hvmegy/icpc-notebook

## Overview

##### Main Components
- Dynamic Programming (DP): Contains files like “Divide and Conquer.cpp” and “SOS.cpp”.
- Data Structures: Contains implementations ranging from Fenwick trees, Segment Trees, DSU, HLD, Link-Cut Tree, Treap, Persistent Segment Tree, etc.
- Geometry: Includes fundamental routines such as “Basic.cpp”, “ConvexHull.cpp”, and “LineContainer.cpp”.
- Graph Algorithms: Encompasses algorithms such as Bellman-Ford, Maximum Flow, Minimum Cost Maximum Flow, Topological Sort, SCC, etc.
- Maths: Contains modules for matrix operations, modular arithmetic (Mod Int.cpp), and other mathematical operations.
- Strings: Hosts pattern matching algorithms and string processing routines like KMP, Aho-Corasick, and Z Function.
- Miscellaneous: Provides various utilities such as “Debug.cpp”, “time.cpp”, random number generator (mt19937.cpp), and editor integration (Clion.cpp).
- Auxiliary/Supporting Files: Files like “gen.sh” (likely a utility for generating test cases or builds) and documentation “notebook.pdf”, as well as a brief README.

##### Relationships and Interactions
- That while modules are mostly independent, they are conceptually tied together by the common use in problem solving.

##### Architectural Patterns and Design Principles
- Modularity: Each category is encapsulated, making it easy to locate relevant algorithms quickly.
- Separation of Concerns: By dividing algorithms into separate folders, the notebook separates various domains (data structures vs. graph theory vs. mathematics).
- Reusability: Many of these components are intended for reuse in multiple competitive programming problems.

##### Including Relevant Technologies and Frameworks
- That the code is written in C++.
- Tools: “gen.sh” for automation, a PDF note (“notebook.pdf”) for reference, and integration with IDEs (evidenced by “Clion.cpp” under Miscellaneous).
- There is minimal configuration or dependencies since it’s a repository of code snippets rather than a deployable system.

##### Elements
- Clear Labels: For each major component (DP, Data Structures, Geometry, Graphs, Maths, Strings, Miscellaneous).
- A high-level container representing the repository, with branches to each category of modules.

## Diagram (Mermaid)

```mermaid
flowchart TD
    Repo["ICPC-Notebook"]:::repo
    CP["ICPC Problem Solving"]:::cp

    %% Dynamic Programming Subgraph
    subgraph "Dynamic Programming"
        direction TB
        DP1["Divide and Conquer.cpp"]:::dp
        DP2["SOS.cpp"]:::dp
    end

    %% Data Structures Subgraph
    subgraph "Data Structures"
        direction TB
        DS1["DSU.cpp"]:::ds
        DS2["Fenwick.cpp"]:::ds
        DS3["HLD.cpp"]:::ds
        DS4["Link-Cut Tree.cpp"]:::ds
        DS5["Treap.cpp"]:::ds
        DS6["Persistent Segment Tree.cpp"]:::ds
    end

    %% Geometry Subgraph
    subgraph "Geometry"
        direction TB
        GEO1["Basic.cpp"]:::geo
        GEO2["ConvexHull.cpp"]:::geo
        GEO3["LineContainer.cpp"]:::geo
    end

    %% Graph Algorithms Subgraph
    subgraph "Graph Algorithms"
        direction TB
        GA1["Bellman-Ford.cpp"]:::graphs
        GA2["Maximum Flow.cpp"]:::graphs
        GA3["Minimum Cost Maximum Flow.cpp"]:::graphs
        GA4["SCC.cpp"]:::graphs
        GA5["Topological Sort.cpp"]:::graphs
    end

    %% Maths Subgraph
    subgraph "Maths"
        direction TB
        MATH1["Matrix.cpp"]:::maths
        MATH2["Mod Int.cpp"]:::maths
        MATH3["Precal Modulo Inverse.cpp"]:::maths
        MATH4["Rabin-Miller.cpp"]:::maths
    end

    %% Strings Subgraph
    subgraph "Strings"
        direction TB
        STR1["Aho Corasick.cpp"]:::strings
        STR2["KMP.cpp"]:::strings
        STR3["Hash.cpp"]:::strings
        STR4["Z Function.cpp"]:::strings
    end

    %% Miscellaneous Utilities Subgraph
    subgraph "Miscellaneous"
        direction TB
        MIS1["Clion.cpp"]:::misc
        MIS2["Debug.cpp"]:::misc
        MIS3["mt19937.cpp"]:::misc
        MIS4["time.cpp"]:::misc
    end

    %% Auxiliary/Supporting Files Subgraph
    subgraph "Auxiliary Files"
        direction TB
        AUX1["gen.sh"]:::aux
        AUX2["notebook.pdf"]:::aux
        AUX3["README.md"]:::aux
    end

    %% Connections from Repository to each category's representative (using the first node of each subgraph)
    Repo -->|"contains"| DP1
    Repo -->|"contains"| DS1
    Repo -->|"contains"| GEO1
    Repo -->|"contains"| GA1
    Repo -->|"contains"| MATH1
    Repo -->|"contains"| STR1
    Repo -->|"contains"| MIS1
    Repo -->|"contains"| AUX1

    %% Connections from each category to ICPC Problem Solving
    DP1 -->|"feeds"| CP
    DS1 -->|"feeds"| CP
    GEO1 -->|"feeds"| CP
    GA1 -->|"feeds"| CP
    MATH1 -->|"feeds"| CP
    STR1 -->|"feeds"| CP
    MIS1 -->|"feeds"| CP
    AUX1 -->|"feeds"| CP

    %% Click Events for Dynamic Programming Files
    click DP1 "https://github.com/hvmegy/icpc-notebook/blob/main/DP/Divide and Conquer.cpp"
    click DP2 "https://github.com/hvmegy/icpc-notebook/blob/main/DP/SOS.cpp"

    %% Click Events for Data Structures Files
    click DS1 "https://github.com/hvmegy/icpc-notebook/blob/main/Data Structures/DSU.cpp"
    click DS2 "https://github.com/hvmegy/icpc-notebook/blob/main/Data Structures/Fenwick.cpp"
    click DS3 "https://github.com/hvmegy/icpc-notebook/blob/main/Data Structures/HLD.cpp"
    click DS4 "https://github.com/hvmegy/icpc-notebook/blob/main/Data Structures/LinkCutTree.cpp"
    click DS5 "https://github.com/hvmegy/icpc-notebook/blob/main/Data Structures/Treap.cpp"
    click DS6 "https://github.com/hvmegy/icpc-notebook/blob/main/Data Structures/PersistentSegmentTree.cpp"

    %% Click Events for Geometry Files
    click GEO1 "https://github.com/hvmegy/icpc-notebook/blob/main/Geometry/Basic.cpp"
    click GEO2 "https://github.com/hvmegy/icpc-notebook/blob/main/Geometry/ConvexHull.cpp"
    click GEO3 "https://github.com/hvmegy/icpc-notebook/blob/main/Geometry/LineContainer.cpp"

    %% Click Events for Graph Algorithms Files
    click GA1 "https://github.com/hvmegy/icpc-notebook/blob/main/Graphs/Bellman-Ford.cpp"
    click GA2 "https://github.com/hvmegy/icpc-notebook/blob/main/Graphs/Maximum Flow.cpp"
    click GA3 "https://github.com/hvmegy/icpc-notebook/blob/main/Graphs/Minimum Cost Maximum Flow.cpp"
    click GA4 "https://github.com/hvmegy/icpc-notebook/blob/main/Graphs/SCC.cpp"
    click GA5 "https://github.com/hvmegy/icpc-notebook/blob/main/Graphs/Topological Sort.cpp"

    %% Click Events for Maths Files
    click MATH1 "https://github.com/hvmegy/icpc-notebook/blob/main/Maths/Matrix.cpp"
    click MATH2 "https://github.com/hvmegy/icpc-notebook/blob/main/Maths/Mod Int.cpp"
    click MATH3 "https://github.com/hvmegy/icpc-notebook/blob/main/Maths/Precal Modulo Inverse.cpp"
    click MATH4 "https://github.com/hvmegy/icpc-notebook/blob/main/Maths/Rabin-Miller.cpp"

    %% Click Events for Strings Files
    click STR1 "https://github.com/hvmegy/icpc-notebook/blob/main/Strings/Aho Corasick.cpp"
    click STR2 "https://github.com/hvmegy/icpc-notebook/blob/main/Strings/KMP.cpp"
    click STR3 "https://github.com/hvmegy/icpc-notebook/blob/main/Strings/Hash.cpp"
    click STR4 "https://github.com/hvmegy/icpc-notebook/blob/main/Strings/Z Function.cpp"

    %% Click Events for Miscellaneous Utilities Files
    click MIS1 "https://github.com/hvmegy/icpc-notebook/blob/main/Miscellaneous/Clion.cpp"
    click MIS2 "https://github.com/hvmegy/icpc-notebook/blob/main/Miscellaneous/Debug.cpp"
    click MIS3 "https://github.com/hvmegy/icpc-notebook/blob/main/Miscellaneous/mt19937.cpp"
    click MIS4 "https://github.com/hvmegy/icpc-notebook/blob/main/Miscellaneous/time.cpp"

    %% Click Events for Auxiliary Files
    click AUX1 "https://github.com/hvmegy/icpc-notebook/blob/main/gen.sh"
    click AUX2 "https://github.com/hvmegy/icpc-notebook/blob/main/notebook.pdf"
    click AUX3 "https://github.com/hvmegy/icpc-notebook/blob/main/README.md"

    %% Styles
    classDef repo fill:#f9e79f,stroke:#d4ac0d,stroke-width:2px;
    classDef cp fill:#d5f5e3,stroke:#27ae60,stroke-width:2px;
    classDef dp fill:#fdebd0,stroke:#e67e22,stroke-width:2px;
    classDef ds fill:#d6eaf8,stroke:#3498db,stroke-width:2px;
    classDef geo fill:#d5f5e3,stroke:#2ecc71,stroke-width:2px;
    classDef graphs fill:#fcf3cf,stroke:#f1c40f,stroke-width:2px;
    classDef maths fill:#ebdef0,stroke:#8e44ad,stroke-width:2px;
    classDef strings fill:#fcf3cf,stroke:#f39c12,stroke-width:2px;
    classDef misc fill:#e8daef,stroke:#9b59b6,stroke-width:2px;
    classDef aux fill:#f2f3f4,stroke:#7f8c8d,stroke-width:2px,stroke-dasharray: 5,5;
```
