Implementation of graphs in java, and cool algorithms using them