Algorithm below takes edges of graph and couple of paths (named vertices in code below) and prints YES if the path can visit all nodes once and returns back to
YES