changes in class Graph, fix typo in testfile

-extend __repr__ method
-write on optimize method
-change __init__: call set_contributesto when an instance is created.