Not sure if reading from a file makes sense. Actually DirectedGraph provides an iterator on Nodes. So, perhaps just taking the next node provided by this iterator will be fine (be careful to check hasNext) for this example instead of a random choice.