Added basic support for arbitrary graphs