CXXGraph Prerequisites
masterBefore using CXXGraph, ensure your environment meets the following requirements:
- C++ Standard: Minimum C++17.
- Compiler:
- GCC version 7.3.0 or later.
- OR an MSVC compiler that supports C++17.
repository·master·Indexed 20 days ago
https://github.com/zigrazor/cxxgraphA comprehensive, header-only C++17 library for managing graph algorithms, designed as a developer-friendly alternative to the Boost Graph Library (BGL). It provides a wide range of implementations for graph traversal (BFS, DFS), shortest paths (Dijkstra, Bellman-Ford, Floyd-Warshall), MST (Prim, Kruskal, Borůvka), network flow, connectivity, topological sorting, and network dynamics matrices such as Adjacency and Laplacian matrices.
Before using CXXGraph, ensure your environment meets the following requirements:
To run benchmarks, you need Google Benchmark, which depends on GoogleTest.
git clone https://github.com/google/benchmark.gitgit clone https://github.com/google/googletest.git benchmark/googletestcd benchmarkmkdir buildcmake -DCMAKE_BUILD_TYPE=Release -S . -B build (or cmake -E chdir "build" cmake -DCMAKE_BUILD_TYPE=Release ../)cmake --build "build" --config Releasesudo cmake --build "build" --config Release --target installgit clone https://github.com/google/benchmark.git
git clone https://github.com/google/googletest.git benchmark/googletest
cd benchmark
cmake -E make_directory "build"
cmake -E chdir "build" cmake -DCMAKE_BUILD_TYPE=Release ../
cmake --build "build" --config Release
sudo cmake --build "build" --config Release --target installUse dpkg to install the Debian package on Debian or Ubuntu systems. Use apt-get to remove it.
# Install
$ sudo dpkg -i CXXGraph_{version}.deb
# Uninstall
$ sudo apt-get remove CXXGraphCXXGraph unit tests require GoogleTest. To install it from source:
git clone https://github.com/google/googletest.gitmkdir -p build && cd buildcmake ..makesudo make install (installs to /usr/local/ by default).git clone https://github.com/google/googletest.git
cd googletest
mkdir -p build
cd build
cmake ..
make
sudo make installTo install CXXGraph on Unix/Linux systems using tarballs, extract the archive to your system using tar with sudo privileges.
To uninstall, manually remove the header files from /usr/include/.
# Install
$ sudo tar xjf CXXGraph-{version}.tar.bz2
# Uninstall
$ sudo rm -f /usr/include/Graph.hpp /usr/include/CXXGraph*CXXGraph is a header-only library. To use it, include the main header file at the top of your source code. Ensure the library's include directory is added to your compiler's include path.
The core abstraction is the graph object, which contains nodes and edges. You can manipulate this object using the library's various algorithms.
#include <CXXGraph/CXXGraph.hpp>
// Your code hereIf you are building from source using CMake, run the following command after the compilation process is complete to install the library to your system.
$ sudo make installTo generate a JSON file containing benchmark results, execute the ./benchmark binary with the following flags:
--benchmark_out=<filename>: Specifies the output filename.--benchmark_out_format=json: Sets the output format to JSON.--benchmark_repetitions=20: Runs the benchmark 20 times to ensure statistical relevance.Ensure you provide a valid filename for the output.
./benchmark --benchmark_out=<filename> --benchmark_out_format=json --benchmark_repetitions=20To compile a C++ file using CXXGraph, use g++ with the C++17 standard. You must provide the include paths for both the main CXXGraph header and the build-generated headers.
Assuming you are in the directory containing your example.cpp:
g++ <path_to/folder/example.cpp> -I <path_to/CXXGraph/include> -I <path_to/CXXGraph/build/include> -std=c++17./a.out# Compile
g++ <path_to/folder/example.cpp> -I <path_to/CXXGraph/include> \
-I <path_to/CXXGraph/build/include> -std=c++17
# Run
./a.outTo generate project documentation, run the doxygen command and provide the path to your Doxygen configuration file.
doxygen <config-file>Use the rpm package manager to install or uninstall CXXGraph on Fedora, CentOS, or RedHat systems.
# Install
$ sudo rpm -ivh CXXGraph-{version}.noarch.rpm
# Uninstall
$ sudo rpm -e CXXGraph-{version}To compare the results of two different benchmark runs, use the compare.py script. The script requires the directory where benchmarks are stored and the absolute paths to the two JSON files you wish to compare.
Usage pattern:
./compare.py <benchmark_dir> <path_to_file1.json> <path_to_file2.json>
./compare.py benchmarks /workspaces/CXXGraph/benchmark/results/file1.json /workspaces/CXXGraph/benchmark/results/file2.json