added graph algorithms and other utility function