naive graph implementation in java