diff --git a/dfs.c b/dfs.c index 8210d66116f5c33ca8702bd08b4e09e420f8991c..caca347f1717dc5e69dacc11a68b805b0270425c 100644 --- a/dfs.c +++ b/dfs.c @@ -26,7 +26,10 @@ struct node *stack_dequeue(struct list_head *stack) { struct node *n; - return list_first_entry(stack, struct node, list); + n = list_first_entry(stack, struct node, list); + list_del(n->list); + + return n; } void add_visited(struct node *n, struct list_head *visited)