added a class to consider the graph as a whole
modified the graph structure and tested