SleakEngine 1.0.0
C++23 multi-backend game engine
Loading...
Searching...
No Matches
Sleak::Graph< T > Class Template Reference

Represents a graph data structure with vertices and edges. More...

#include <Graph.hpp>

Public Member Functions

 Graph ()
 ~Graph ()
 Frees every vertex and its adjacency list.
void addEdge (const T &from, const T &to)
 Adds a directed edge from -> to; no-ops if either vertex is missing.
void addVertex (const T &value)
 Adds value as a vertex if it isn't already present.

Detailed Description

template<typename T>
class Sleak::Graph< T >

Represents a graph data structure with vertices and edges.

The Graph class provides functionality for managing a collection of vertices and their connections (edges). It is suitable for modeling networks, relationships, and interconnected systems. Use this class when you need to represent entities with connections, such as social networks, road networks, or dependency graphs.

Example Use Cases:

  • Representing a social network where vertices are users and edges are friendships.
  • Modeling a road network for navigation and route planning.
  • Implementing dependency tracking in a build system.
  • Simulating network communication protocols.

Implementation Details:

  • Uses an adjacency list representation for efficient storage of sparse graphs.
  • Provides methods for adding vertices and edges, and for traversing the graph.

Definition at line 27 of file Graph.hpp.

Constructor & Destructor Documentation

◆ Graph()

template<typename T>
Sleak::Graph< T >::Graph ( )
inline

Definition at line 63 of file Graph.hpp.

◆ ~Graph()

template<typename T>
Sleak::Graph< T >::~Graph ( )
inline

Frees every vertex and its adjacency list.

Definition at line 66 of file Graph.hpp.

Member Function Documentation

◆ addEdge()

template<typename T>
void Sleak::Graph< T >::addEdge ( const T & from,
const T & to )
inline

Adds a directed edge from -> to; no-ops if either vertex is missing.

Definition at line 93 of file Graph.hpp.

◆ addVertex()

template<typename T>
void Sleak::Graph< T >::addVertex ( const T & value)
inline

Adds value as a vertex if it isn't already present.

Definition at line 83 of file Graph.hpp.