A set of 7 bridges connected two islands and two banks, forming a graph. Euler was asked if a person could traverse each bridge exactly once and return to his starting point. The answer was no, and Euler proved it. More than that, he developed necessary and sufficient conditions for the existence of these "Eulerean trails".
An Eulerean trail is a trail that contains every edge of a graph or digraph. A graph contains an Eulerean cyclic trail iff its vertices all have even degree.
Since the trail consumes two edges each time it travels through a vertex, any vertex with an odd degree prohibits the Eulerean cyclic trail. Eventually the trail reaches the offending vertex, consuming the last odd edge, and finds itself trapped, with no unused edges leaving that vertex.
When all vertices have even degree, a deterministic procedure constructs the Eulerean cyclic trail. Begin at any vertex and proceed randomly, never repeating an edge. Since degrees are even, there will always be another unused edge to take, until you finally reach the initial vertex. If all edges have been consumed, you are done. Otherwise find a vertex in the constructed trail with unused incident edges and construct a new trail starting at that vertex. This second trail is then incorporated into the first, making one longer trail. This process continues until all edges have been used.
If the Eulerean trail need not start and end at the same vertex the two endpoints must have odd degree.
When dealing with digraphs, the constraint "even degree" is replaced with "indegree = outdegree". The reasoning is essentially the same. If start and end points differ, the start point has one extra outgoing edge, and the end point has one extra incoming edge.