Java implementations of some algorithms