Essential Graph Algorithms for Programming Contests
Dikjstra's Algorithm (Adjacency Matrix)
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
const int MAX_NODES = 510;
int node_count, edge_count;
int graph[MAX_NODES][MAX_NODES];
int min_distance[MAX_NODES];
bool visited[MAX_NODES];
int dijkstra_shortest_path() {
memset(min_distance, 0x3f, s ...
Posted on Fri, 18 Sep 2026 16:11:15 +0000 by sledgeweb
Graph Algorithms and Critical Path Analysis in C
Depth-First Search on Adjacency-Matrix Graphs
void DFS(MGraph G, Vertex v, void (*visit)(Vertex)) {
visit(v);
Visited[v] = true;
for (Vertex w = 0; w < G->Nv; ++w)
if (G->G[v][w] && !Visited[w])
DFS(G, w, visit);
}
Breadth-First Search on Adjacency-List Graphs
void BFS(LGraph G, Vertex s, void ...
Posted on Wed, 22 Jul 2026 16:36:11 +0000 by han2754