Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bobluppes/graaf
A general-purpose lightweight C++ graph library
https://github.com/bobluppes/graaf
algorithm algorithms bfs bfs-algorithm cpp cpp-library cpp20 dfs dfs-algorithm graph graph-algorigthms header-only header-only-library search-algorithm shortest-path-algorithm
Last synced: 9 days ago
JSON representation
A general-purpose lightweight C++ graph library
- Host: GitHub
- URL: https://github.com/bobluppes/graaf
- Owner: bobluppes
- License: mit
- Created: 2023-01-31T22:14:33.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-10-27T11:08:43.000Z (12 days ago)
- Last Synced: 2024-10-27T12:51:10.443Z (12 days ago)
- Topics: algorithm, algorithms, bfs, bfs-algorithm, cpp, cpp-library, cpp20, dfs, dfs-algorithm, graph, graph-algorigthms, header-only, header-only-library, search-algorithm, shortest-path-algorithm
- Language: C++
- Homepage: https://bobluppes.github.io/graaf/
- Size: 3.42 MB
- Stars: 147
- Watchers: 4
- Forks: 38
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
Graaf Library
Graaf is a general-purpose header-only graph library implemented in C++. It is designed as a lightweight alternative to the Boost Graph Library (BGL).
# About
Graph is an abstract data type that is widely used in computer science. It is a collection of vertices (nodes) and edges
that connect these vertices. Graphs are used to model many real-world problems, such as social networks, road networks,
and computer networks. As such, graph algorithms are used in many applications, including route planning, network
analysis, and data mining.Graaf: A Lightweight, Header-Only C++20 Graph Library
**Key Features**:
- **Header-only**: No separate compilation or linking required.
- **Generality**: Supports user-defined vertex and edge classes.
- **Algorithm Support**: Provides a range of graph algorithms.**Purpose**:
Graaf is designed with the goal of simplifying graph-related tasks. It offers a lightweight alternative to the [Boost Graph Library (BGL)](https://www.boost.org/doc/libs/1_82_0/libs/graph/doc/index.html) and is built for simplicity and extensibility. With Graaf, you can easily create, manipulate, and analyze graphs, making it suitable for a wide range of applications.# Installation
The most straightforward way to use the Graaf in your project is to include it as a header-only library. Please take a
look at the [installation guide](https://bobluppes.github.io/graaf/docs/quickstart/installation) for alternative
installation methods.## Header-Only Library
The Graaf libary can be included as a header-only library. All it requires is a compiler with **C++ 20 support**.
Download the `header-only` library from our [release page](https://github.com/bobluppes/graaf/releases) and add
the `include/graaflib` directory to your include path. You can now use Graaf in your source files:```c++
// main.cpp
#include
```For more details or alternative installation methods, see
the [installation guide](https://bobluppes.github.io/graaf/docs/quickstart/installation).# How to use Graaf
Using the Graaf library is easy! Specializations are provided for a `directed_graph` as well as for `undirected_graph`.
To create your first graph:```c++
undirected_graph my_graph{};
```This creates an undirected graph with `integer` values on the vertices and `float` weights on the edges. Graaf is
designed with generality in mind. As such, it can be used to store any user-defined vertex and edge class:```c++
struct User {
std::string name;
int age;
};// An edge type can also be unweighted if we don't derive from weighted_edge
struct Connection : public weighted_edge {
float strength;
float get_weight() const override { return strength; }
};undirected_graph my_graph{};
```Implementations for common [graph algorithms](#algorithms) are provided under the `algorithm` namespace. Combining this
with built-in `dot` format support allows us to do things like visualizing the shortest path between two vertices:
To get started, take a look at our [quickstart guide](https://bobluppes.github.io/graaf/docs/quickstart/intro).
# Algorithms
Algorithms implemented in the Graaf library include the following. For more information on individual algorithms please
take a look at the [docs](https://bobluppes.github.io/graaf/docs/algorithms/intro).1. [**Cycle Detection Algorithms**](https://bobluppes.github.io/graaf/docs/category/cycle-detection-algorithms):
- [DFS-Based Cycle Detection](https://bobluppes.github.io/graaf/docs/algorithms/cycle-detection/dfs-based)
2. [**Graph Coloring Algorithms**](https://bobluppes.github.io/graaf/docs/category/graph-coloring-algorithms):
- [Greedy Graph Coloring](https://bobluppes.github.io/graaf/docs/algorithms/coloring/greedy-graph-coloring)
- [Welsh-Powell Algorithm]
3. [**Minimum Spanning Tree (MST) Algorithms**](https://bobluppes.github.io/graaf/docs/category/minimum-spanning-tree)
- [Kruskal's Algorithm](https://bobluppes.github.io/graaf/docs/algorithms/minimum-spanning-tree/kruskal)
- [Prim's Algorithm](https://bobluppes.github.io/graaf/docs/algorithms/minimum-spanning-tree/prim)
4. [**Shortest Path Algorithms**](https://bobluppes.github.io/graaf/docs/category/shortest-path-algorithms):
- [A\* search](https://bobluppes.github.io/graaf/docs/algorithms/shortest-path/a-star)
- [Bellman-Ford Shortest Path](https://bobluppes.github.io/graaf/docs/algorithms/shortest-path/bellman-ford)
- [BFS-Based Shortest Path](https://bobluppes.github.io/graaf/docs/algorithms/shortest-path/bfs-based-shortest-path)
- [Dijkstra Shortest Path](https://bobluppes.github.io/graaf/docs/algorithms/shortest-path/dijkstra)
- [Floyd-Warshall Algorithm](https://bobluppes.github.io/graaf/docs/algorithms/shortest-path/floyd-warshall)
5. [**Strongly Connected Components Algorithms**](https://bobluppes.github.io/graaf/docs/category/strongly-connected-component-algorithms):
- [Tarjan's Strongly Connected Components](https://bobluppes.github.io/graaf/docs/algorithms/strongly-connected-components/tarjan)
- [Kosaraju's Strongly Connected Components](https://bobluppes.github.io/graaf/docs/algorithms/strongly-connected-components/kosarajus)
6. [**Topological Sorting Algorithms**](https://bobluppes.github.io/graaf/docs/algorithms/topological-sort):
7. [**Traversal Algorithms**](https://bobluppes.github.io/graaf/docs/category/traversal-algorithms):
- [Breadth-First Search (BFS)](https://bobluppes.github.io/graaf/docs/algorithms/traversal/breadth-first-search)
- [Depth-First Search (DFS)](https://bobluppes.github.io/graaf/docs/algorithms/traversal/depth-first-search)
8. [**Clique Detection**](https://bobluppes.github.io/graaf/docs/category/clique-detection)
- [Bron-Kerbosch](https://bobluppes.github.io/graaf/docs/algorithms/clique-detection/bron-kerbosch)# Contributing
The Graaf library welcomes contributions 🎊
If you're interested in improving, fixing bugs, or adding features, please refer to
the [wiki](https://github.com/bobluppes/graaf/wiki) for guidelines and have your [development environment set up](https://github.com/bobluppes/graaf/wiki/development-setup) before you start. Check out our roadmap
on [YouTrack](https://graaf.youtrack.cloud/agiles/147-2/current) to stay up to date on planned features and
improvements. We also have an [issue tracker](https://github.com/bobluppes/graaf/issues) for bug reports and feature
requests.Feel free to join our [Discord](https://discord.gg/cGczwRHJ9K) for assistance and a smooth contribution experience.
### Contributors
# Acknowledgements
Special thanks to [JetBrains](https://www.jetbrains.com/community/opensource/) for providing development tools for this
project.# License
This project is licensed under the [MIT license](LICENSE.md).