maths
Geometry, graphs and interpolation
Loading...
Searching...
No Matches
graph.hpp File Reference

Generic graph with optional node dedup, optional edge weighting, directed/undirected modes, and common algorithms (MST, components, BFS). More...

#include <algorithm>
#include <concepts>
#include <cstddef>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <type_traits>
#include <utility>
#include <vector>
Include dependency graph for graph.hpp:

Go to the source code of this file.

Classes

struct  Link
 
class  Graph< T, Equal, Kind >
 

Concepts

concept  EqualityFn
 
concept  WeightFn
 

Enumerations

enum class  GraphKind { GraphKind::Directed , GraphKind::Undirected }
 

Detailed Description

Generic graph with optional node dedup, optional edge weighting, directed/undirected modes, and common algorithms (MST, components, BFS).

Author
Perry Chouteau
Date
2025-11-05

Usage examples

// 1) Plain integer graph (undirected by default) auto g = Graph<int>::fromPairs({{0,1},{1,2},{2,0}});

// 2) With node deduplication struct EqInt { bool operator()(int a, int b) const { return a == b; } }; auto g = Graph<int, EqInt>::fromPairs({{1,2},{2,3}});

// 3) With weighted edges (e.g. Vector2f points + euclidean distance) struct EqV2 { bool operator()(Vector2f a, Vector2f b) const {...}; }; struct DistV2 { float operator()(Vector2f a, Vector2f b) const {...}; }; auto g = Graph<Vector2f, EqV2>::fromPairs<DistV2>(pairs); auto mst = g.mst(); // non-mutating auto loop = g.difference(mst); // remaining Delaunay edges → add back N for TinyKeep loops