Warning

This documents an unmaintained version of NetworkX. Please upgrade to a maintained version and see the current NetworkX documentation.

networkx.algorithms.euler.has_eulerian_path

has_eulerian_path(G)[source]

Return True iff G has an Eulerian path.

An Eulerian path is a path in a graph which uses each edge of a graph exactly once.

A directed graph has an Eulerian path iff:
  • at most one vertex has out_degree - in_degree = 1,

  • at most one vertex has in_degree - out_degree = 1,

  • every other vertex has equal in_degree and out_degree,

  • and all of its vertices with nonzero degree belong to a

  • single connected component of the underlying undirected graph.

An undirected graph has an Eulerian path iff:
  • exactly zero or two vertices have odd degree,

  • and all of its vertices with nonzero degree belong to a

  • single connected component.

Parameters

G (NetworkX Graph) – The graph to find an euler path in.

Returns

Bool

Return type

True if G has an eulerian path.