24 for(
size_t i = 0; i < n; ++i) {
33 for(
size_t i = 0; i < g->
nvs; ++i)
54typedef LIST(
size_t) int_stack_t;
56static int DFS_visit(
rawgraph *g,
size_t v,
int time, int_stack_t *sp) {
64 for (
size_t i = 0; i <
LIST_SIZE(&adj); ++i) {
67 time = DFS_visit(g,
id, time, sp);
80 if (g->
nvs == 0)
return;
88 for(
size_t i = 0; i < g->
nvs; ++i) {
90 time = DFS_visit(g, i, time, &sp);
Memory allocation wrappers that exit on failure.
static void * gv_calloc(size_t nmemb, size_t size)
static void * gv_alloc(size_t size)
type-generic dynamically expanding list
#define LIST_APPEND(list, item)
#define LIST_RESERVE(list, capacity)
#define LIST_POP_BACK(list)
#define LIST_CONTAINS(list, needle)
#define LIST_IS_EMPTY(list)
#define LIST_PUSH_BACK(list, item)
#define LIST_REMOVE(list, item)
#define LIST_GET(list, index)
rawgraph * make_graph(size_t n)
makes a graph with n vertices, 0 edges
void insert_edge(rawgraph *g, size_t v1, size_t v2)
inserts edge FROM v1 to v2
void remove_redge(rawgraph *g, size_t v1, size_t v2)
removes any edge between v1 to v2 – irrespective of direction
void top_sort(rawgraph *g)
bool edge_exists(rawgraph *g, size_t v1, size_t v2)
tests if there is an edge FROM v1 TO v2
void free_graph(rawgraph *g)
adj_list_t adj_list
adjacency list