34 #ifndef __GRAPHS_HPP__
35 #define __GRAPHS_HPP__
52 std::vector<std::vector<std::pair<int, int>>>
adj_list;
67 void add_edge(
int v,
int w,
int weight);
81 void dfs_rec(
int v, std::vector<bool> &visited);
109 std::vector<std::pair<int, std::pair<int, int>>>
kruskal();
196 std::vector<std::pair<int, int>>
match_wt();
235 bool is_k33(
const std::set<int> &k_vertices);
243 double euclid_dist(
const std::pair<double, double> &point1,
244 const std::pair<double, double> &point2);
256 void decompress(
const std::vector<uint64_t> &compressed);
267 std::vector<bool> &visited,
268 std::stack<int> &topo_stack);
277 int find(std::vector<int> &parent,
int i);
285 void union_sets(std::vector<int> &parent,
int x,
int y);
299 std::vector<bool> &visited,
300 std::vector<int> &component);
318 std::vector<bool> &visited,
319 std::vector<int> &path,
bool has_hamiltonian_circuit()
Checks if the graph contains a Hamiltonian circuit.
int radius()
Calculates the radius of the graph.
bool has_k5()
Checks if the graph contains a subgraph that is a subdivision of K5.
std::vector< std::pair< int, std::pair< int, int > > > kruskal()
Applies Kruskal's algorithm to find the minimum spanning tree of the graph.
void dfs(int start)
Performs Depth-First Search (DFS) traversal starting from a given vertex.
void bellman_ford(int start)
Applies Bellman-Ford algorithm to find the single-source shortest paths in the graph,...
bool is_bipartite()
Determines if a given graph is bipartite using BFS (Breadth First Search)
std::vector< bool > is_matched
std::vector< std::vector< std::pair< int, int > > > adj_list
void add_edge(int v, int w, int weight)
Adds an edge between two vertices with a specified weight.
std::vector< std::pair< int, int > > match_wt()
Finds a maximum weight matching in the graph using a greedy algorithm.
int chromatic_number()
Calculates the chromatic number of the graph.
int eccentricity(int vertex)
Calculates the eccentricity of a specified vertex in the graph.
void bfs(int start)
Performs Breadth-First Search (BFS) traversal starting from a given vertex.
int find(std::vector< int > &parent, int i)
Finds the representative element of the set that contains the given element.
std::vector< double > betweenness_centrality()
Calculates betweenness centrality for each vertex in the graph.
std::vector< int > greedy_coloring()
Performs graph coloring using the greedy algorithm.
bool hamiltonian_circuit_util(int v, std::vector< bool > &visited, std::vector< int > &path, int count)
Utility function for finding a Hamiltonian circuit.
double euclid_dist(const std::pair< double, double > &point1, const std::pair< double, double > &point2)
Calculates the Euclidean distance between two 2D points.
std::vector< uint64_t > compress()
Compresses the graph using Elias Gamma encoding.
std::vector< std::vector< int > > connected_components()
Finds connected components in an undirected graph using Depth-First Search (DFS)
void decompress(const std::vector< uint64_t > &compressed)
Decompresses a compressed graph using Elias Gamma encoding.
void dfs_rec(int v, std::vector< bool > &visited)
Helper function for recursive Depth-First Search (DFS) traversal.
void topo_sort_util(int v, std::vector< bool > &visited, std::stack< int > &topo_stack)
Helper function for topological sorting.
void planar_gen(int num_vertices, double radius)
Generates a random planar graph using the random geometric graph model.
Graph(int v)
Constructor for the Graph class.
std::vector< std::pair< int, int > > match_cardinality()
Finds a maximum cardinality matching in the graph using a greedy algorithm.
bool has_eulerian_path()
Checks if the graph contains an Eulerian path.
int choose_random_neighbor(int vertex)
Chooses a random neighbor of a given vertex.
void floyd_warshall()
Applies Floyd-Warshall algorithm to find all-pairs shortest paths in the graph.
void dfs_connected_components(int v, std::vector< bool > &visited, std::vector< int > &component)
Performs Depth-First Search (DFS) traversal to find connected components in an undirected graph.
void dijkstra(int start)
Applies Dijkstra's algorithm to find the single-source shortest paths in the graph.
bool is_k33(const std::set< int > &k_vertices)
Checks if a set of vertices forms a subgraph that is a subdivision of K3,3.
void union_sets(std::vector< int > &parent, int x, int y)
Unions two sets by rank in the disjoint set data structure.
bool is_planar()
Checks if the graph is planar using Kuratowski's theorem.
bool has_k33()
Checks if the graph contains a subgraph that is a subdivision of K3,3.
void topo_sort()
Performs topological sorting on a Directed Acyclic Graph (DAG)
The source C++ openGPMP namespace.