Note on performance: By default, the graph structure only stores the outgoing (adjacent) edges of every node. The incoming edge lists are computed lazily when graph_get_incoming_edges/3 is called for the first time (but then they are built for all nodes at once). Therefore the first call to this predicate has O(NlogN) complexity, subsequent calls are only O(1). It may therefore make sense to do a dummy call to this predicate before starting time critical or nondeterministic computation.