GraphDom is a modern C++17 library for graph data structures designed around a hierarchy of abstract interfaces and concrete implementations.
The main goal of the project is to separate graph algorithms from graph implementations. Algorithms can therefore be written against the abstract interfaces, while users are free to choose the concrete graph implementation that best fits their needs.
The library is header-oriented, CMake-friendly, and provides both static and shared builds.
- Modern C++17 API
- Header-oriented public interface
- Abstract graph hierarchy
- Concrete graph implementations
- Directed and undirected graphs
- Set graphs and multiset graphs
- Vertex labels
- Edge labels
- Generic algorithms can target the abstract interfaces
- CMake package support
- Static and shared library installation
- CMake ≥ 3.20
- A C++17 compatible compiler
The project uses CMake.
To build the library without the unit tests:
cmake -S . -B build \
-DBUILD_TESTING=OFF
cmake --build buildAfter building:
cmake --install buildThe installation exports a CMake package that can later be found with
find_package(GraphDom REQUIRED)The package exports a single public target:
GraphDom::GraphDomA minimal CMakeLists.txt looks like:
cmake_minimum_required(VERSION 3.20)
project(MyProject)
find_package(GraphDom REQUIRED)
add_executable(MyExecutable
main.cpp
)
target_link_libraries(
MyExecutable
PRIVATE
GraphDom::GraphDom
)Both the static and the shared versions are installed.
The package exposes a single imported target whose implementation depends on the variable
GraphDom_USE_STATIC_LIBSset(GraphDom_USE_STATIC_LIBS ON)
find_package(GraphDom REQUIRED)
target_link_libraries(
MyExecutable
PRIVATE
GraphDom::GraphDom
)set(GraphDom_USE_STATIC_LIBS OFF)
find_package(GraphDom REQUIRED)
target_link_libraries(
MyExecutable
PRIVATE
GraphDom::GraphDom
)If the variable is not specified, the shared library is selected.
The complete public API can be included with
#include <graphdom/graphdom.h>Alternatively, the library is organized into two aggregate headers:
#include <graphdom/abstract_classes.h>containing the abstract interfaces, and
#include <graphdom/concrete_classes.h>containing the concrete implementations.
The library is divided into two conceptual layers.
The abstract interfaces describe graph capabilities independently from any particular implementation.
Examples include:
- graph
- set graph
- multiset graph
- labeled vertex graph
- labeled edge graph
- mixed graph variants
These interfaces are intended to be the primary abstraction layer for writing reusable graph algorithms.
Concrete classes provide actual graph containers implementing combinations of the abstract interfaces.
Current implementations include fully labeled
- directed set graphs
- undirected set graphs
- directed multiset graphs
- undirected multiset graphs
Future implementations will extend the available combinations without changing the abstract API.
There are two equally valid ways to explore the documentation.
This approach is ideal for understanding the architecture of the library.
Recommended order:
- Start from the abstract interfaces.
- Understand the relationships between the different graph concepts.
- Explore the concrete implementations.
- Finally study the algorithms using those abstractions.
This path emphasizes the design philosophy behind GraphDom.
This approach is convenient if you simply want to use the library immediately.
Recommended order:
- Start from the concrete graph classes.
- Learn how to create and manipulate graphs.
- Afterward explore the abstract interfaces to understand how generic algorithms are built.
GraphDom is designed around the idea that graph algorithms should depend on capabilities, not on specific graph containers.
Instead of writing an algorithm for one concrete graph class, algorithms should be written against the smallest abstract interface that provides the required operations.
This promotes:
- code reuse;
- implementation independence;
- easier testing;
- future extensibility.
The project is still under active development.
Planned milestones include:
- Implement the remaining concrete graph classes covering every meaningful combination of the available abstract interfaces.
- Introduce an
unordered_set-like container specialized for storingvertex_handleobjects. - Develop the first collection of graph algorithms written exclusively against the abstract interfaces, maximizing portability across concrete graph implementations.
GraphDom is distributed under the Apache-2.0 License.