Represents a directed (by nature) Adjacency List Graph Structure.
More...
#include <adjacency_list.h>
|
| using | id_type = I |
| | Alias for the node ID type.
|
| using | edge_type = E |
| | Alias for the edge type.
|
template<valid_id_type I, valid_edge_type< I > E>
class GraphLib::Internal::AdjacencyList< I, E >
Represents a directed (by nature) Adjacency List Graph Structure.
- Parameters
-
Definition at line 39 of file adjacency_list.h.
◆ edge_type
template<valid_id_type I, valid_edge_type< I > E>
◆ id_type
template<valid_id_type I, valid_edge_type< I > E>
◆ add_edge()
template<valid_id_type I, valid_edge_type< I > E>
Adds an edge from from_id to the edge's target node.
- Parameters
-
| from_id | Source node ID. |
| edge | The edge to add. |
- Note
- Requires that both node IDs exist and the edge does not already exist.
Definition at line 176 of file adjacency_list.h.
◆ add_node_id()
template<valid_id_type I, valid_edge_type< I > E>
Adds a node with the specified ID to the graph.
If the node ID already exists, this function does nothing.
- Parameters
-
| node_id | The ID of the node to add. |
Definition at line 93 of file adjacency_list.h.
◆ edge_count()
template<valid_id_type I, valid_edge_type< I > E>
Returns the total number of edges in the graph.
Counts all edges outgoing from every node.
- Returns
- The total edge count.
Definition at line 213 of file adjacency_list.h.
◆ get_edge()
template<valid_id_type I, valid_edge_type< I > E>
Retrieves the edge from from_id to to_id.
- Parameters
-
| from_id | Source node ID. |
| to_id | Target node ID. |
- Returns
- The edge object representing the connection.
- Note
- Asserts that the edge exists.
Definition at line 147 of file adjacency_list.h.
◆ get_edges()
template<valid_id_type I, valid_edge_type< I > E>
Retrieves all edges outgoing from the specified node.
- Parameters
-
| from_id | The node ID whose outgoing edges to retrieve. |
- Returns
- A set containing all outgoing edges from the node.
Definition at line 162 of file adjacency_list.h.
◆ get_neighboring_node_ids()
template<valid_id_type I, valid_edge_type< I > E>
Gets the neighboring node IDs of a given node.
- Parameters
-
| node_id | The ID of the node whose neighbors to retrieve. |
- Returns
- A set of node IDs that are neighbors (targets of edges) of the given node.
- Note
- Asserts that the node exists.
Definition at line 75 of file adjacency_list.h.
◆ get_node_ids()
template<valid_id_type I, valid_edge_type< I > E>
Retrieves all node IDs present in the graph.
- Returns
- An unordered_set containing all node IDs.
Definition at line 60 of file adjacency_list.h.
◆ has_edge()
template<valid_id_type I, valid_edge_type< I > E>
Checks if an edge from from_id to to_id exists.
- Parameters
-
| from_id | Source node ID. |
| to_id | Target node ID. |
- Returns
- true if such an edge exists, false otherwise.
Definition at line 130 of file adjacency_list.h.
◆ has_node_id()
template<valid_id_type I, valid_edge_type< I > E>
Checks if a node with given ID exists in the graph.
- Parameters
-
| node_id | The ID of the node to check. |
- Returns
- true if the node exists, false otherwise.
Definition at line 50 of file adjacency_list.h.
◆ node_id_count()
template<valid_id_type I, valid_edge_type< I > E>
Returns the number of nodes in the graph.
- Returns
- The count of node IDs.
Definition at line 201 of file adjacency_list.h.
◆ operator==()
template<valid_id_type I, valid_edge_type< I > E>
Equality comparison operator.
Compares two adjacency lists for equality of their internal adjacency maps.
- Parameters
-
| other | Another adjacency list to compare with. |
- Returns
- true if both adjacency lists have identical adjacency maps.
Definition at line 229 of file adjacency_list.h.
◆ print_with_data_map()
template<valid_id_type I, valid_edge_type< I > E>
Outputs the adjacency map to the given output stream, but with data instead of IDs.
Iterates over each node and its associated edges, printing the node value followed by a list of its edges in a human-readable format. Format: NODE_VALUE : [EDGE, EDGE] with EDGE being either "NODE_VALUE" or "NODE_VALUE (WEIGHT)" depending on edge type.
- Template Parameters
-
- Parameters
-
| os | The output stream to write to. |
| data_map | the data_map from the graph, which maps NodeIDs to their data. |
Definition at line 250 of file adjacency_list.h.
◆ remove_edge()
template<valid_id_type I, valid_edge_type< I > E>
Removes the edge from from_id to to_id.
- Parameters
-
| from_id | Source node ID. |
| to_id | Target node ID. |
Definition at line 189 of file adjacency_list.h.
◆ remove_node_id()
template<valid_id_type I, valid_edge_type< I > E>
Removes the node with the specified ID and all edges pointing to it.
Also removes all edges from other nodes that target this node.
- Parameters
-
| node_id | The ID of the node to remove. |
Definition at line 107 of file adjacency_list.h.
◆ adj_map_
template<valid_id_type I, valid_edge_type< I > E>
The documentation for this class was generated from the following file: