|
4 | 4 | </a> |
5 | 5 | </p> |
6 | 6 |
|
7 | | -<br /> |
8 | | - |
9 | 7 | <div align="center"> |
10 | 8 |
|
11 | 9 | [](https://github.com/SpectraL519/cpp-gl/actions/workflows/gpp.yaml) |
12 | 10 | [](https://github.com/SpectraL519/cpp-gl/actions/workflows/clang.yaml) |
| 11 | + |
| 12 | +</div> |
| 13 | + |
| 14 | +<div align="center"> |
| 15 | + |
13 | 16 | [](https://github.com/SpectraL519/cpp-gl/actions/workflows/format.yaml) |
14 | 17 | [](https://github.com/SpectraL519/cpp-gl/actions/workflows/benchmarks.yaml) |
| 18 | +[](https://github.com/SpectraL519/cpp-gl/releases) |
15 | 19 |
|
16 | 20 | </div> |
17 | 21 |
|
18 | 22 | <br /> |
19 | 23 |
|
| 24 | +## Documentation |
| 25 | + |
| 26 | +The complete, versioned documentation, including detailed tutorials, quick start guides, and architectural overviews, is hosted online: |
| 27 | + |
| 28 | +**[Explore the CPP-GL Documentation](https://spectral519.github.io/cpp-gl/latest/)** |
| 29 | + |
| 30 | +--- |
| 31 | + |
20 | 32 | ## Overview |
21 | 33 |
|
22 | | -- The goal of the project was to create a higlhy customizable, intuitive and easy to work with graph library for the modern C++ standards. |
23 | | -- The `CPP-GL` library's implementation relies solely on the C++ standard library (it does not require installing any additional tools) and is designed to be compatible with the C++ standard tools, e.g. range-based loops, std algorithms, the [ranges library](https://en.cppreference.com/w/cpp/ranges), stream operations, etc. |
24 | | -- The library relies heavily on [concepts](https://en.cppreference.com/w/cpp/language/constraints) to acheive abstraction instead of interfaces and abstract classes to minimize the overhead associated with virtual tables and dynamic dispatch. |
| 34 | +CPP-GL is a highly customizable, intuitive, and concept-driven graph and hypergraph library designed for modern C++ standards. |
25 | 35 |
|
26 | | -> [!NOTE] |
27 | | -> `v1.0.*` and `v1.0-prerelease-*` versions of the library have been developed as the Bachelor of Engineering project at the *Wrocław University of Science and Technology* |
28 | | -> |
29 | | -> Faculty: *W04N - Faculty of Information and Communication Technology* |
30 | | -> |
31 | | -> Field of study: *Algorithmic Computer Science* |
| 36 | +Designed strictly around modern C++ paradigms, the library heavily leverages templates and concepts to deliver an API that is exceptionally fast, generic, and type-safe. It relies solely on the C++ standard library, meaning it requires no external dependencies and integrates perfectly with modern C++ tools such as range-based loops, the `<ranges>` library, standard algorithms, stream operations, and more. |
32 | 37 |
|
33 | | -<br /> |
| 38 | +## Module Architecture: GL vs. HGL |
34 | 39 |
|
35 | | -## Table of content |
| 40 | +To accommodate different mathematical models without compromising API clarity or performance, the library is strictly partitioned into two primary modules: |
36 | 41 |
|
37 | | -- [Overview](#overview) |
38 | | -- [Table of content](#table-of-content) |
39 | | -- [Installing the library](#installing-the-library) |
40 | | -- [CMake integration](#cmake-integration) |
41 | | -- [Documentation - TODO](#documentation---todo) |
42 | | -- [Dev notes - TODO](#dev-notes---todo) |
43 | | -- [Compiler support](#compiler-support) |
44 | | -- [Licence](#licence) |
| 42 | +- **GL (Graph Library):** The core module dedicated to standard graphs. It handles both directed and undirected topologies where edges represent connections between exactly two vertices. It provides a comprehensive suite of utilities including structural generators, graph modifiers, and a broad spectrum of classical graph algorithms. |
| 43 | +- **HGL (Hypergraph Library):** A specialized module dedicated to hypergraphs, where a single hyperedge represents a higher-order connection between an arbitrary number of vertices. It features generalized traversal algorithms and incidence-based memory models tailored for complex, multi-way relationships. |
45 | 44 |
|
46 | | -<br /> |
| 45 | +## Core Features |
47 | 46 |
|
48 | | -## Installing the library |
| 47 | +Because both modules share the same fundamental design philosophy, they offer a unified, symmetrical feature set tailored to their respective mathematical domains: |
49 | 48 |
|
50 | | -The use the `CPP-GL` library in your project you can download the source code from the [releases](https://github.com/SpectraL519/cpp-gl/releases) page and add the `<cpp-gl-root>/include` path to the include directories of your project. |
| 49 | +- **Shared Zero-Cost Infrastructure:** By relying on C++20 concepts instead of virtual interfaces and dynamic dispatch, CPP-GL eliminates vtable overhead while enforcing strict compile-time contracts. Crucially, the **HGL module is built strictly on top of the GL module**, directly reusing its core infrastructure (ID types, traits, memory structures) to ensure maximum code reuse, while allowing the GL module to remain completely standalone for standard graph use cases. |
| 50 | +- **Unified Topology APIs:** The `gl::graph` and `hgl::hypergraph` classes offer consistent interfaces that completely abstract away the underlying memory models. Users can seamlessly swap between different backend representations without rewriting traversal logic, property accesses, or algorithm calls. |
| 51 | +- **Flexible Memory Layouts:** The library provides a comprehensive suite of memory-efficient representations. Users can choose between dynamic container-based layouts (Lists and Matrices) and highly optimized, cache-friendly contiguous array structures (Flat Lists and Flat Matrices). The HGL module further extends this by allowing users to specify the orientation of the memory models to optimize generalized incidence queries. |
| 52 | +- **Customizable Element Properties:** Vertices, edges, and hyperedges can carry arbitrary, user-defined payloads. Whether assigning standard metric weights and colors or attaching complex, application-specific data structures, the library's traits system ensures that property injection and access remain strictly type-safe and performant. |
| 53 | +- **Extensible Algorithmic Engines:** The library features a strictly decoupled algorithm design. Powerful, generic search templates serve as the underlying engines, allowing custom algorithms to be built on the fly by simply injecting zero-cost callbacks. Built upon these generic engines is a rich, out-of-the-box library of concrete algorithms—covering everything from classic pathfinding to advanced, multi-way reachability semantics for directed hypergraphs. |
| 54 | +- **Robust I/O Facilities:** Native serialization and formatting tools make it simple to pipe topologies directly to and from standard C++ streams and files. Both the GL and HGL modules share a unified set of stream options for visual output, while relying on dedicated, easily parsable flat-text formats (GSF and HGSF) to ensure fast and predictable data serialization. |
51 | 55 |
|
52 | | -<br /> |
| 56 | +--- |
53 | 57 |
|
54 | | -## CMake integration |
| 58 | +## Compiler Support |
55 | 59 |
|
56 | | -The `CPP-GL` library can also be included in a `CMake` project by adding the following to the `CMakeLists.txt` file of your project: |
| 60 | +| Compiler | Min version | |
| 61 | +| :-: | :-: | |
| 62 | +| GNU G++ | 14 | |
| 63 | +| Clang | 18 | |
57 | 64 |
|
58 | | -```cmake |
59 | | -cmake_minimum_required(VERSION 3.12) |
| 65 | +> [!NOTE] C++23 Support |
| 66 | +> |
| 67 | +> Although currently the project has been properly verified using only the G++ and Clang compilers, it should work fine with other compilers with C++23 support like MSVC. |
| 68 | +
|
| 69 | +--- |
60 | 70 |
|
| 71 | +## Installation & Integration |
| 72 | + |
| 73 | +CPP-GL is a header-only template library. It can be integrated into a project either by directly including the headers or via CMake. |
| 74 | + |
| 75 | +### Option A: CMake `FetchContent` (Recommended) |
| 76 | + |
| 77 | +The easiest way to integrate CPP-GL is to fetch it directly from the GitHub repository during the CMake configuration phase: |
| 78 | + |
| 79 | +```cmake |
| 80 | +cmake_minimum_required(VERSION 3.14) |
61 | 81 | project(my_project LANGUAGES CXX) |
62 | 82 |
|
63 | | -# Include FetchContent module |
64 | 83 | include(FetchContent) |
65 | 84 |
|
66 | | -# Fetch the CPP-GL library |
67 | 85 | FetchContent_Declare( |
68 | 86 | cpp-gl |
69 | | - GIT_REPOSITORY https://github.com/SpectraL519/cpp-gl.git |
70 | | - GIT_TAG <tag> # here you can specify the desired tag or branch |
| 87 | + GIT_REPOSITORY [https://github.com/SpectraL519/cpp-gl.git](https://github.com/SpectraL519/cpp-gl.git) |
| 88 | + GIT_TAG <tag> # Specify the desired version tag, branch, or specific commit. |
71 | 89 | ) |
72 | 90 |
|
73 | 91 | FetchContent_MakeAvailable(cpp-gl) |
74 | 92 |
|
75 | | -# Define the executable for the project |
76 | 93 | add_executable(my_project main.cpp) |
77 | 94 |
|
78 | 95 | set_target_properties(my_project PROPERTIES |
79 | | - CXX_STANDARD 23 # or newer |
| 96 | + CXX_STANDARD 23 # The CPP-GL library requires C++23. |
80 | 97 | CXX_STANDARD_REQUIRED YES |
81 | 98 | ) |
82 | 99 |
|
83 | | -# Link against the cpp-gl library |
84 | 100 | target_link_libraries(my_project PRIVATE cpp-gl) |
85 | 101 | ``` |
86 | 102 |
|
87 | | -<br /> |
| 103 | +### Option B: Including the Headers Directly |
88 | 104 |
|
89 | | -## Documentation - TODO |
| 105 | +If CMake is not being used, simply download the desired version of the library from the [Releases Page](https://github.com/SpectraL519/cpp-gl/releases) and add the `include` directory of the library to the project via the `-I<cpp-gl-dir>/include` flag. |
90 | 106 |
|
91 | | -<br /> |
| 107 | +--- |
92 | 108 |
|
93 | | -## Dev notes - TODO |
| 109 | +## Benchmarks |
94 | 110 |
|
95 | | -<br /> |
| 111 | +Performance and zero-cost abstraction are primary goals of this library. A comprehensive evaluation suite built on top of **Google Benchmark** provides a structured way to measure, filter, and report the library's performance across various graph algorithms and memory layouts. |
96 | 112 |
|
97 | | -## Compiler support |
| 113 | +For detailed performance metrics, configuration instructions (including BGL integration), and CLI usage, please refer to the **[Benchmarks Guide](benchmarks/README.md)**. |
98 | 114 |
|
99 | | -| Compiler | Min version | |
100 | | -| :-: | :-: | |
101 | | -| GNU G++ | 14 | |
102 | | -| Clang | 18 | |
| 115 | +--- |
103 | 116 |
|
104 | | -> [!NOTE] C++23 Support |
| 117 | +## Developer Notes |
| 118 | + |
| 119 | +To build the testing and documentation suites locally, follow the guides below. |
| 120 | + |
| 121 | +### Running Tests |
| 122 | + |
| 123 | +The library features a comprehensive test suite powered by **Doctest** and orchestrated via CMake. The test executables for both the `gl` and `hgl` modules can be built and run as follows: |
| 124 | + |
| 125 | +```bash |
| 126 | +# Configure the project with tests enabled |
| 127 | +cmake -B build -DBUILD_TESTS=ON |
| 128 | + |
| 129 | +# Build the test executables (replace <n> with the core count) |
| 130 | +cmake --build build/ -j<n> |
| 131 | + |
| 132 | +# Execute the tests |
| 133 | +./build/tests/gl |
| 134 | +./build/tests/hgl |
| 135 | +``` |
| 136 | + |
| 137 | +### Code Formatting |
| 138 | + |
| 139 | +The project enforces strict code formatting using `clang-format-18`. A custom Python script is provided to streamline the formatting process across the repository. |
| 140 | + |
| 141 | +To format the entire repository: |
| 142 | + |
| 143 | +```bash |
| 144 | +python scripts/format.py -exe clang-format-18 |
| 145 | +``` |
| 146 | + |
| 147 | +To format only the files modified in the last commit: |
| 148 | + |
| 149 | +```bash |
| 150 | +python scripts/format.py -m -exe clang-format-18 |
| 151 | +``` |
| 152 | + |
| 153 | +> [!NOTE] If `clang-format-18` is your system's default, you can omit the `-exe` flag. |
| 154 | +
|
| 155 | +### Building the Documentation |
| 156 | + |
| 157 | +The documentation is generated using Doxygen (for XML extraction), a custom Python script for concept parsing, and MkDocs (via `mike` for versioning). The process is automated via a Makefile. |
| 158 | + |
| 159 | +To build and serve the documentation locally: |
| 160 | + |
| 161 | +```bash |
| 162 | +make serve-docs |
| 163 | +``` |
| 164 | + |
| 165 | +To clean the documentation build directories: |
| 166 | +```bash |
| 167 | +make clean-docs |
| 168 | +``` |
| 169 | + |
| 170 | +> [!NOTE] Python Dependency Management |
105 | 171 | > |
106 | | -> Although currently the project has been properly verified using only the G++ and Clang compilers it should work fine with other compilers with C++23 support like MSVC. |
| 172 | +> The documentation build scripts rely on **[uv](https://docs.astral.sh/uv/)** to simplify Python dependency management within the project. Ensure `uv` is installed on the system before attempting to build the documentation. |
107 | 173 |
|
108 | | -<br /> |
| 174 | +--- |
109 | 175 |
|
110 | | -## Licence |
| 176 | +## License |
111 | 177 |
|
112 | | -The `CPP-GL` project uses the [MIT Licence](https://mit-license.org/) which can be found in the [LICENCE](/LICENSE.md#mit-licence) file |
| 178 | +The `CPP-GL` project uses the [MIT License](https://mit-license.org/) which can be found in the [LICENSE](LICENSE.md) file. |
0 commit comments