Extracted common base class of AdjacencyListImpl and DictOfDictsImpl.