pydot allows to easily create both directed and non directed graphs from Python.