23#include <unordered_map>
24#include <unordered_set>
27#include <shared_mutex>
29#include "absl/container/flat_hash_map.h"
34 template <
class T1,
class T2>
35 size_t operator()(
const std::pair<T1, T2>& p)
const noexcept {
36 return absl::HashOf(p.first, p.second);
77void save_graph(
const std::string& filename)
const;
80 absl::flat_hash_map<int, std::shared_ptr<const std::vector<int>>> adj_list;
81 static const std::vector<int> static_empty_vector;
82 mutable std::shared_mutex adj_list_mutex;
90 bool validate_filepath(
const std::string& path)
const;
void save_graph(const std::string &filename) const
Save the graph to a file in edge list format.
Definition Graph.cpp:171
void delete_node(int node)
Deletes a node and its edges from the graph.
Definition Graph.cpp:148
void load_graph(const std::string &filepath)
Loads an edge list from a file into an adjacency list.
Definition Graph.cpp:66
const std::vector< int > & get_neighbors(int node) const
Gets the neighbors of a given node.
Definition Graph.cpp:133
void add_node(int node)
Adds a node to the graph.
Definition Graph.cpp:143