graph.c code refactor