Replace hash sets with array lists to compact the graph