Apple interview question

Solve a design problem using Graph theory. Rewrite one of the core Java APIs.