Reformated parts a bit, changed them so they take a graph as a param"