Fix memory leak in graph.c