Better graph implementation