Algorithm added for testing for acyclic property.