algorithms, tests and adding in Graph class