25 for(
size_t i = 0; i < n; ++i) {
34 for(
size_t i = 0; i < g->
nvs; ++i)
51static bool zeq(
size_t a,
size_t b) {
69 for (
size_t i = 0; i < adj_list_size(&adj); ++i) {
70 const size_t id = adj_list_get(&adj, i);
75 int_stack_push_back(sp, v);
85 if (g->
nvs == 0)
return;
92 int_stack_reserve(&sp, g->
nvs);
93 for(
size_t i = 0; i < g->
nvs; ++i) {
97 while (!int_stack_is_empty(&sp)) {
98 const size_t v = int_stack_pop_back(&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)
#define DEFINE_LIST(name, type)
rawgraph * make_graph(size_t n)
makes a graph with n vertices, 0 edges
static int DFS_visit(rawgraph *g, size_t v, int time, int_stack_t *sp)
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
static bool zeq(size_t a, size_t b)
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