# snap-stanford/snap architecture

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

- Interactive diagram: https://gitdiagram.com/snap-stanford/snap
- Repository: https://github.com/snap-stanford/snap

## Overview

##### Main Components
- Core Libraries: The heart of SNAP is found in the “snap-core” directory. It contains fundamental graph algorithms, data structures, and utility functions (e.g., graph traversals, network statistics, serialization, and input/output functions).
- Advanced Modules: “snap-adv” includes additional functionality such as community detection, clustering, clique finding, and other advanced graph operations that build on the core.
- Experimental Components: “snap-exp” contains experimental code that is still under development. These components explore new ideas or extensions to SNAP, such as epidemic models and specialized graph generators.
- Utility Libraries: “glib-core” and “glib-adv” provide STL-like data structures (vectors, hash tables, strings), basic algorithms, and other foundational utilities that support SNAP’s components.
- Example Applications and Tutorials: The “examples” and “tutorials” directories host sample applications and demonstration programs. These illustrate how the SNAP libraries can be used in practice.
- Testing and Documentation: The “test” directory holds the unit tests, while “doxygen” provides the means to auto-generate documentation. These represent critical support infrastructure.
- Build/Configuration Files: Files like Makefiles, Visual Studio project files, and config files (e.g., Makefile.config) show how the components are compiled and integrated, highlighting multiple build environments (Linux, Windows, Mac OS X).

##### Relationships and Interactions
- Example and Tutorial Consumers: Represent “examples” and “tutorials” as client applications that use the SNAP APIs provided by the libraries. They interact directly with snap-core (and, indirectly, with snap-adv/snap-exp).

##### Architectural Patterns and Design Principles
- Modular Design: Emphasize the separation between core functionality (snap-core), extensions (snap-adv, snap-exp) and lower-level utilities (glib-core, glib-adv). This modularity supports scalability and independent evolution of components.
- Layered Architecture: Illustrate layers starting from the utility layer (glib), through the core framework (snap-core), then additional capability layers (snap-adv and snap-exp), and finally the application layer (examples, tutorials).
- Clear API Boundaries: The design implicitly uses well-defined interfaces. For example, graph types (e.g., TNGraph, TUNGraph, TNEGraph) are exposed to client applications and tests.

##### Relevant Technologies and Frameworks
- C++ as the programming language.
- Build tools: Makefiles for Unix-like systems and Visual Studio project files for Windows.
- External dependencies: Paths to GraphViz and GnuPlot for visualization and plotting.
- Documentation generation using Doxygen.

##### Elements
- Clear labels for each component:
– “glib-core” and “glib-adv” (utility layer)
– “snap-core” (core graph library)
– “snap-adv” (advanced functionalities)
– “snap-exp” (experimental modules)
– “Examples & Tutorials” (client applications/demos)
– “Tests” and “Documentation” (supporting infrastructure)
– From “glib” libraries to “snap-core”
– From “snap-core” to “snap-adv” and “snap-exp”
– From “snap-*” modules to “Examples/Tutorials”
– Clearly denote boundaries between layers.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Build/Configuration"
        Makefile("Makefile"):::build
        MakefileConfig("Makefile.config"):::build
    end

    subgraph "Utility Layer"
        glibCore("glib-core"):::utility
        glibAdv("glib-adv"):::utility
    end

    subgraph "Core Layer"
        snapCore("snap-core"):::core
    end

    subgraph "Extensions"
        snapAdv("snap-adv"):::extension
        snapExp("snap-exp"):::extension
    end

    subgraph "Application Layer"
        Examples("Examples"):::client
        Tutorials("Tutorials"):::client
    end

    subgraph "Support"
        Test("Testing"):::support
        Documentation("Documentation"):::support
    end

    %% Build/Configuration feeds into the Utility Layer
    Makefile --> glibCore
    Makefile --> glibAdv
    MakefileConfig --> glibCore
    MakefileConfig --> glibAdv

    %% Utility Layer supports Core Layer
    glibCore --> snapCore
    glibAdv --> snapCore

    %% Core Layer is the base for Extensions
    snapCore --> snapAdv
    snapCore --> snapExp

    %% Core and Extensions provide APIs to Applications
    snapCore --> Examples
    snapCore --> Tutorials
    snapAdv --> Examples
    snapAdv --> Tutorials
    snapExp --> Examples
    snapExp --> Tutorials

    %% Support components feed back into Utility, Core and Extensions
    Test -.-> glibCore
    Test -.-> glibAdv
    Test -.-> snapCore
    Test -.-> snapAdv
    Test -.-> snapExp
    Documentation -.-> glibCore
    Documentation -.-> snapCore
    Documentation -.-> snapAdv
    Documentation -.-> snapExp

    %% Click Events
    click snapCore "https://github.com/snap-stanford/snap/tree/master/snap-core"
    click snapAdv "https://github.com/snap-stanford/snap/tree/master/snap-adv"
    click snapExp "https://github.com/snap-stanford/snap/tree/master/snap-exp"
    click glibCore "https://github.com/snap-stanford/snap/tree/master/glib-core"
    click glibAdv "https://github.com/snap-stanford/snap/tree/master/glib-adv"
    click Examples "https://github.com/snap-stanford/snap/tree/master/examples"
    click Tutorials "https://github.com/snap-stanford/snap/tree/master/tutorials"
    click Test "https://github.com/snap-stanford/snap/tree/master/test"
    click Documentation "https://github.com/snap-stanford/snap/tree/master/doxygen"
    click Makefile "https://github.com/snap-stanford/snap/tree/master/Makefile"
    click MakefileConfig "https://github.com/snap-stanford/snap/blob/master/Makefile.config"

    %% Styles
    classDef build fill:#f9a,stroke:#333,stroke-width:2px;
    classDef utility fill:#bbf,stroke:#333,stroke-width:2px;
    classDef core fill:#aaf,stroke:#333,stroke-width:2px;
    classDef extension fill:#dda,stroke:#333,stroke-width:2px;
    classDef client fill:#cfc,stroke:#333,stroke-width:2px;
    classDef support fill:#fcc,stroke:#333,stroke-width:2px;
```
