Price your future right. 60% off with code BLACKSCHOLES at USD checkout. Offer ends in 1d 16h 01m 44s1 days 16 hours 1 minutes 44 seconds.
Price your future right. 60% off with code BLACKSCHOLES at USD checkout. Offer ends in 1d 16h 01m 44s1 days 16 hours 1 minutes 44 seconds.

Sign in to watch this lesson
Advanced - Graphs · 4:16
An Euler path uses every edge of a graph exactly once, and an Euler circuit also ends where it started. In an undirected graph a circuit exists when all degrees are even and a path when exactly zero or two are odd, with all edges connected (directed: in-degree equals out-degree, with one extra out at the start and one extra in at the end). Hierholzer's algorithm finds one in O(m) with a stack: follow unused edges, pop a vertex into the answer only when it is stuck, and read the answer backwards.