13 std::cout <<
"DFS Traversal starting from vertex 0: ";
15 std::cout << std::endl;
17 std::cout <<
"BFS Traversal starting from vertex 0: ";
19 std::cout << std::endl;
25 std::cout <<
"Kruskal's Minimum Spanning Tree:\n";
26 std::vector<std::pair<int, std::pair<int, int>>> kruskalMST = g.
kruskal();
27 for (
const auto &edge : kruskalMST) {
28 std::cout <<
"Edge: " << edge.second.first <<
" - "
29 << edge.second.second <<
" | Weight: " << edge.first <<
"\n";
34 std::cout <<
"Graph for Topological Sorting:\n";
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,...
void add_edge(int v, int w, int weight)
Adds an edge between two vertices with a specified weight.
void bfs(int start)
Performs Breadth-First Search (BFS) traversal starting from a given vertex.
void floyd_warshall()
Applies Floyd-Warshall algorithm to find all-pairs shortest paths in the graph.
void dijkstra(int start)
Applies Dijkstra's algorithm to find the single-source shortest paths in the graph.
void topo_sort()
Performs topological sorting on a Directed Acyclic Graph (DAG)