Remove dependency on jgrapht