D
D
dalbio2021-02-22 14:08:45
Algorithms
dalbio, 2021-02-22 14:08:45

How to find a recursive Euler way in the graph, from which vertex to start?

I need to find an euler path in a directed graph, on the internet I found an article in the article it says:

After entering the graph, you need to run euler(0) or from any other vertex.
, but it doesn't work for a directed graph, so what should I do?
Thanks in advance for your reply.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
Wataru, 2021-02-22
@dalbio

An Euler cycle exists in a graph only if the input degree of each vertex is equal to its output degree.
An Euler path exists from a vertex with an output degree 1 greater than the input degree to a vertex with an input degree 1 greater than the output. (If the graph is undirected, then the path is from one odd vertex to another). In this case, all other vertices must be balanced.
This is elementary to prove - the path enters each vertex a number of times and exits the same number of times. The only exception is the start and end vertex if they don't match.
Accordingly, you need to calculate the degrees of all vertices, check that everything is fine (maximum one with in==out+1 and one with in==out-1) and run either from any or from the one that has more outgoing edges.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question