function walk = eulerWalk(G)
% Euler's result that every edge in an all-even-degree graph is in
% a cycle.
% http://www.unc.edu/~rowlett/Math148/notes/graphintro.html
% Euler's result that you can construct an Eulerian walk in your
% all-even-degree graph.
% http://www.unc.edu/~rowlett/Math148/notes/eulerian.html

% start with an edge, any edge in the graph.
edge = findEdge(G, []);

% build it into a cycle T.
T = makeCycle(G, edge);
G
T'

G2 = G;
while 1,
	% G2 = subtract the cycle from the graph
	G2 = subtractCycle(G2, T);

	% if G2 = empty, we're done.
	if (emptyGraph(G2)),
		break;
	end

	% find edge in G2 incident on some node A1 in T.
	edge = findEdge(G2, T);

	% build it into a cycle U.
	U = makeCycle(G2, edge);

	% T = merge T and U.
	T = mergeCycles(T, U);
end

walk = T;
