# pnevyk/gryf architecture

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

- Interactive diagram: https://gitdiagram.com/pnevyk/gryf
- Repository: https://github.com/pnevyk/gryf

## Overview

##### Component Details

a) Storage Implementations (Bottom Layer):

- Storage Layer     |

- AdjList             |
- AdjMatrix           |
- EdgeList            |
- Stable              |
- Frozen              |

b) Core Components (Middle Layer):

- Core Layer       |

- Graph Operations    |
- Property System     |
- Weight Handling     |
- ID Management       |

c) Algorithm Layer:

- Algorithm Layer     |

- Shortest Paths      |
- Connected Components|
- Topological Sort    |
- Cycle Detection     |

##### Relationships and Interactions

- Double lines for trait implementations

##### Special Features to Highlight

- Builder pattern implementation
- Algorithm selection mechanism
- Storage abstraction system
- Graph property system

##### Implementation Details

- Visitor System     |

- BFS                 |
- DFS                 |
- Raw Visit           |

##### Additional Elements

Include:
- Version information
- External dependency interfaces
- Testing and fuzzing infrastructure

Key Architectural Points to Emphasize:

##### Storage Abstraction
- How different storage implementations can be plugged in
- Demonstrate the separation between storage and semantics

##### Algorithm Selection
- Automatic algorithm selection mechanism
- How problems map to specific implementations

##### Builder Pattern
- Demonstrate the configuration flow
- Optional parameter handling

##### Type System
- How Rust's type system ensures correctness
- Trait relationships

Remember to add notes about:
- Fuzzing capabilities
- Property-based testing
- Performance considerations
- Extension points

This will create a comprehensive yet understandable representation of the Gryf library's architecture while maintaining the balance between abstraction and detail that a principal software engineer would need.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Title
    title[Gryf Graph Library Architecture]:::title

    %% Main Layers
    subgraph API["Public API Layer"]
        GraphInterface["Main Graph Interface"]
        PathRep["Path Representations"]
        Builder["Builder Patterns"]
    end

    subgraph Algorithms["Algorithm Layer"]
        ShortestPaths["Shortest Paths"]
        Connected["Connected Components"]
        TopoSort["Topological Sort"]
        CycleDetect["Cycle Detection"]
    end

    subgraph Core["Core Layer"]
        BaseTraits["Base Traits"]
        GraphOps["Graph Operations"]
        MarkerProps["Markers & Properties"]
        WeightHandle["Weight Handling"]
        IDManage["ID Management"]
    end

    subgraph Storage["Storage Layer"]
        AdjList["AdjList"]
        AdjMatrix["AdjMatrix"]
        EdgeList["EdgeList"]
        Stable["Stable"]
        Frozen["Frozen"]
    end

    subgraph Visit["Visitor System"]
        BFS["BFS"]
        DFS["DFS"]
        RawVisit["Raw Visit"]
    end

    subgraph Adapters["Adapters"]
        Complement["Complement"]
        Subgraph["Subgraph"]
        Transpose["Transpose"]
        Undirect["Undirect"]
    end

    subgraph Testing["Testing Infrastructure"]
        Fuzzing["Fuzzing Targets"]
        PropTest["Property Testing"]
        TestUtils["Testing Utilities"]
    end

    %% Relationships
    GraphInterface --> BaseTraits
    GraphInterface --> GraphOps
    PathRep --> GraphOps
    Builder --> GraphOps

    Algorithms --> Visit
    Algorithms --> Core
    Core --> Storage
    Visit --> Storage
    Adapters --> Core

    Testing --> GraphInterface
    Testing --> Algorithms

    %% Click Events
    click GraphInterface "https://github.com/pnevyk/gryf/blob/main/gryf/src/graph/generic.rs"
    click PathRep "https://github.com/pnevyk/gryf/blob/main/gryf/src/graph/path.rs"
    click ShortestPaths "https://github.com/pnevyk/gryf/tree/main/gryf/src/algo/shortest_paths/"
    click Connected "https://github.com/pnevyk/gryf/tree/main/gryf/src/algo/connected/"
    click TopoSort "https://github.com/pnevyk/gryf/tree/main/gryf/src/algo/toposort/"
    click CycleDetect "https://github.com/pnevyk/gryf/tree/main/gryf/src/algo/cycle/"
    click BaseTraits "https://github.com/pnevyk/gryf/blob/main/gryf/src/core/base.rs"
    click GraphOps "https://github.com/pnevyk/gryf/blob/main/gryf/src/core/graph.rs"
    click MarkerProps "https://github.com/pnevyk/gryf/blob/main/gryf/src/core/marker.rs"
    click WeightHandle "https://github.com/pnevyk/gryf/tree/main/gryf/src/core/weight/"
    click IDManage "https://github.com/pnevyk/gryf/tree/main/gryf/src/core/id/"
    click AdjList "https://github.com/pnevyk/gryf/blob/main/gryf/src/storage/adj_list.rs"
    click AdjMatrix "https://github.com/pnevyk/gryf/blob/main/gryf/src/storage/adj_matrix.rs"
    click EdgeList "https://github.com/pnevyk/gryf/blob/main/gryf/src/storage/edge_list.rs"
    click Stable "https://github.com/pnevyk/gryf/blob/main/gryf/src/storage/stable.rs"
    click Frozen "https://github.com/pnevyk/gryf/blob/main/gryf/src/storage/frozen.rs"
    click BFS "https://github.com/pnevyk/gryf/blob/main/gryf/src/visit/bfs.rs"
    click DFS "https://github.com/pnevyk/gryf/blob/main/gryf/src/visit/dfs.rs"
    click RawVisit "https://github.com/pnevyk/gryf/blob/main/gryf/src/visit/raw.rs"
    click Complement "https://github.com/pnevyk/gryf/blob/main/gryf/src/adapt/complement.rs"
    click Subgraph "https://github.com/pnevyk/gryf/blob/main/gryf/src/adapt/subgraph.rs"
    click Transpose "https://github.com/pnevyk/gryf/blob/main/gryf/src/adapt/transpose.rs"
    click Undirect "https://github.com/pnevyk/gryf/blob/main/gryf/src/adapt/undirect.rs"
    click Fuzzing "https://github.com/pnevyk/gryf/tree/main/fuzz/fuzz_targets/"
    click PropTest "https://github.com/pnevyk/gryf/blob/main/gryf/src/infra/proptest.rs"
    click TestUtils "https://github.com/pnevyk/gryf/blob/main/gryf/src/infra/testing.rs"

    %% Styling
    classDef default fill:#f9f9f9,stroke:#333,stroke-width:1px
    classDef title fill:none,stroke:none,color:#333,font-size:18px
    classDef api fill:#e1f5fe,stroke:#01579b
    classDef core fill:#e8f5e9,stroke:#1b5e20
    classDef storage fill:#fff3e0,stroke:#e65100
    classDef visit fill:#f3e5f5,stroke:#4a148c
    classDef testing fill:#fafafa,stroke:#424242
    classDef adapters fill:#fff8e1,stroke:#ff6f00

    class title title
    class GraphInterface,PathRep,Builder api
    class BaseTraits,GraphOps,MarkerProps,WeightHandle,IDManage core
    class AdjList,AdjMatrix,EdgeList,Stable,Frozen storage
    class BFS,DFS,RawVisit visit
    class Fuzzing,PropTest,TestUtils testing
    class Complement,Subgraph,Transpose,Undirect adapters
```
