Skip to content

Instantly share code, notes, and snippets.

@manku-timma
Created July 22, 2014 08:10
Show Gist options
  • Save manku-timma/cbaabb8476d273b4a1d6 to your computer and use it in GitHub Desktop.
Save manku-timma/cbaabb8476d273b4a1d6 to your computer and use it in GitHub Desktop.
Graph main file - Toy programs to play with graph algorithms
#include <stdio.h>
#include "graph.h"
int edges[] = {
0, 1,
0, 2,
1, 3,
2, 4,
2, 5,
4, 5,
4, 6,
5, 6,
5, 7,
6, 7,
};
int main() {
struct graph g;
graph_init(&g);
for (int i = 0; i < sizeof(edges) / sizeof(int); i += 2) {
graph_add_edge(&g, edges[i], edges[i + 1], 1);
}
graph_print(&g);
graph_print_dot(&g);
graph_dfs_recursive(&g, 0);
graph_bfs(&g, 0);
graph_bfs_print_path(0, 4); // based on previous bfs
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment