Algorithm includes: depth first search in graph, creating M-numeration and N-numeration, defining edges by type (tree, straight, reverse, cross)