cycles.py: raise error if argument is directed graph.