Split common to build_graph, pyn_exceptions, refactor Graph, Rule