|
cgrapht 1.0.0
A modern C++20 header-only graph library
|
Directed graph with hashed vertex and edge ids. More...
#include <graph.hpp>
Public Member Functions | |
| Result< std::size_t, ErrorType > | add_vertex (const V &v) |
| Add a vertex to the graph. | |
| Result< std::size_t, ErrorType > | delete_vertex (std::size_t vertex_id) |
| Delete a vertex if it has no incident edges. | |
| Result< std::size_t, ErrorType > | add_edge (std::size_t from_id, std::size_t to_id, const E &e) |
| Add a directed edge between two vertices. | |
| Result< std::size_t, ErrorType > | delete_edge (std::size_t edge_id) |
| Delete an edge by id. | |
| Result< V, ErrorType > | get_vertex (std::size_t id) const |
| Fetch a vertex payload by id. | |
| Result< Edge< E >, ErrorType > | get_edge (std::size_t id) const |
| Fetch an edge record by id. | |
| Result< std::unordered_set< std::size_t >, ErrorType > | get_children (std::size_t vertex_id) const |
| Get adjacent children (outgoing neighbors). | |
| Result< std::unordered_set< std::size_t >, ErrorType > | get_parents (std::size_t vertex_id) const |
| Get adjacent parents (incoming neighbors). | |
| Result< std::unordered_set< std::size_t >, ErrorType > | get_neighbours (std::size_t vertex_id) const |
| Get all adjacent neighbors (incoming or outgoing). | |
| Result< std::unordered_set< std::size_t >, ErrorType > | get_outgoing_edges (std::size_t vertex_id) const |
| Get outgoing edge ids for a vertex. | |
| Result< std::unordered_set< std::size_t >, ErrorType > | get_incoming_edges (std::size_t vertex_id) const |
| Get incoming edge ids for a vertex. | |
| std::ranges::forward_range auto | get_vertices () const & |
| View of all vertex payloads. | |
| std::ranges::forward_range auto | get_edges () const & |
| View of all edge records. | |
Directed graph with hashed vertex and edge ids.
| V | Vertex payload type. |
| E | Edge payload type. |
V and E must be hashable types. | Result< std::size_t, ErrorType > cgrapht::DirectedGraph< V, E >::add_edge | ( | std::size_t | from_id, |
| std::size_t | to_id, | ||
| const E & | e | ||
| ) |
Add a directed edge between two vertices.
| from_id | Source vertex id. |
| to_id | Destination vertex id. |
| e | Edge payload. |
Definition at line 177 of file graph.hpp.
References cgrapht::ABSENT_VERTEX, cgrapht::EDGE_ALREADY_EXISTS, cgrapht::Result< SUCCESS, ERROR >::error(), cgrapht::Edge< E >::from_id, and cgrapht::Result< SUCCESS, ERROR >::success().
| Result< std::size_t, ErrorType > cgrapht::DirectedGraph< V, E >::add_vertex | ( | const V & | v | ) |
Add a vertex to the graph.
| v | Vertex payload. |
Definition at line 156 of file graph.hpp.
References cgrapht::Result< SUCCESS, ERROR >::success().
| Result< std::size_t, ErrorType > cgrapht::DirectedGraph< V, E >::delete_edge | ( | std::size_t | edge_id | ) |
Delete an edge by id.
| edge_id | Edge id. |
Definition at line 195 of file graph.hpp.
References cgrapht::ABSENT_EDGE, cgrapht::Result< SUCCESS, ERROR >::error(), and cgrapht::Result< SUCCESS, ERROR >::success().
| Result< std::size_t, ErrorType > cgrapht::DirectedGraph< V, E >::delete_vertex | ( | std::size_t | vertex_id | ) |
Delete a vertex if it has no incident edges.
| vertex_id | Vertex id. |
Definition at line 165 of file graph.hpp.
References cgrapht::ABSENT_VERTEX, cgrapht::Result< SUCCESS, ERROR >::error(), cgrapht::Result< SUCCESS, ERROR >::success(), and cgrapht::VERTEX_NOT_FREE.
| Result< std::unordered_set< std::size_t >, ErrorType > cgrapht::DirectedGraph< V, E >::get_children | ( | std::size_t | vertex_id | ) | const |
Get adjacent children (outgoing neighbors).
| vertex_id | Vertex id. |
Definition at line 220 of file graph.hpp.
References cgrapht::ABSENT_VERTEX.
| Result< Edge< E >, ErrorType > cgrapht::DirectedGraph< V, E >::get_edge | ( | std::size_t | id | ) | const |
Fetch an edge record by id.
| id | Edge id. |
Definition at line 213 of file graph.hpp.
References cgrapht::ABSENT_EDGE.
|
inline |
| Result< std::unordered_set< std::size_t >, ErrorType > cgrapht::DirectedGraph< V, E >::get_incoming_edges | ( | std::size_t | vertex_id | ) | const |
Get incoming edge ids for a vertex.
| vertex_id | Vertex id. |
Definition at line 273 of file graph.hpp.
References cgrapht::ABSENT_VERTEX.
| Result< std::unordered_set< std::size_t >, ErrorType > cgrapht::DirectedGraph< V, E >::get_neighbours | ( | std::size_t | vertex_id | ) | const |
Get all adjacent neighbors (incoming or outgoing).
| vertex_id | Vertex id. |
Definition at line 244 of file graph.hpp.
References cgrapht::ABSENT_VERTEX.
| Result< std::unordered_set< std::size_t >, ErrorType > cgrapht::DirectedGraph< V, E >::get_outgoing_edges | ( | std::size_t | vertex_id | ) | const |
Get outgoing edge ids for a vertex.
| vertex_id | Vertex id. |
Definition at line 265 of file graph.hpp.
References cgrapht::ABSENT_VERTEX.
| Result< std::unordered_set< std::size_t >, ErrorType > cgrapht::DirectedGraph< V, E >::get_parents | ( | std::size_t | vertex_id | ) | const |
Get adjacent parents (incoming neighbors).
| vertex_id | Vertex id. |
Definition at line 232 of file graph.hpp.
References cgrapht::ABSENT_VERTEX.
| Result< V, ErrorType > cgrapht::DirectedGraph< V, E >::get_vertex | ( | std::size_t | id | ) | const |
Fetch a vertex payload by id.
| id | Vertex id. |
Definition at line 206 of file graph.hpp.
References cgrapht::ABSENT_VERTEX, cgrapht::Result< SUCCESS, ERROR >::error(), and cgrapht::Result< SUCCESS, ERROR >::success().
|
inline |