Created
July 22, 2014 08:10
-
-
Save manku-timma/cbaabb8476d273b4a1d6 to your computer and use it in GitHub Desktop.
Graph main file - Toy programs to play with graph algorithms
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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