finish Graph class and related classes.