Python graph classes