Different graph algorithms implemented in Java