TITLE: Do level sets always correspond to even graphs?
QUESTION [8 upvotes]: Suppose I have a level set of some function $f\colon\mathbb{R}^n\rightarrow\mathbb{R}^m$, say $L:=\{x:f(x)=c\}$. Let $S$ denote the points in $L$ at which $L$ is locally diffeomorphic to an open interval on the real line. Now define a set of vertices by $V:=(\overline{S}\setminus S)\cup\{\infty\}$, where bar denotes closure. Let's say two vertices $u,v\in V$ are adjacent if there is a continuous path $\gamma\colon[0,1]\rightarrow\mathbb{R}^n\cup\{\infty\}$ such that $\gamma(0)=u$, $\gamma(1)=v$, and $\gamma(t)\in S$ whenever $t\in(0,1)$.
Question: Is this graph necessarily even if $f$ is polynomial? analytic?
As an example, the following depicts the $(x,y)$'s such that $(x^2+y^2-2)(x^3-y^2)(xy-1)=0$, along with the corresponding graph:

In the graph, I put the point at infinity on the bottom right. The other vertices are $(0,0)$, $(1,1)$, $(1,-1)$ and $(-1,-1)$, and all of these have even degree.
Note that the graph is not necessarily even if $f$ is $C^\infty$, since the non-analytic smooth function in this article, namely
$$
f(x):=\left\{\begin{array}{ll}e^{-1/x}&\mbox{if }x>0\\0&\mbox{otherwise}\end{array}\right.
$$
has a level set $\{x:f(x)=0\}=(-\infty,0]$ whose graph is a path of two vertices (each of degree $1$).

REPLY [11 votes]: This is true for real analytic functions $f:R^2\to R$. Let such a function be $f(x,y)$ and
we consider the level set $f(x,y)=0$, that is an analytic curve. If at some point $f_x$ or $f_y$ is different from $0$, this point is non-singular and belongs to your set $S$.
Now we show that a singular point is a common endpoint of an even number of branches of
the curve. Let this singular point be $O=(0,0)$.
According to Newton and Puiseux, the curve near $O$ is given by finitely many series
of the form $y=(c+o(1))x^{p/q}$, where $p$ and $q$ are positive integers, $c\neq 0$.
Each such series
defines an even number of branches. If one of $p$, $q$ is even, the principal term
is invariant either under $x\mapsto-x$ or $y\mapsto -y$. If both are odd,
use $(x,y)\mapsto (-x,-y)$ So we have an even number of branches converging at each
singular point. (For a reference, you can look at "Puiseux series" entry in Wikipedia,
or any book which has "algebraic curves" in the title. There is no difference between
algebraic and analytic curves in this respect).
EDIT. I asked the specialists in singularities, and they told me that this is true in any dimension, as a corollary of a much more general fact proved by Sullivan in:
MR0278333 
Sullivan, D.
Combinatorial invariants of analytic spaces. 1971 Proceedings of Liverpool Singularities—Symposium, I (1969/70) pp. 165–168 Springer, Berlin.
EDIT2.
Another reference: Real algebraic geometry" by Bochnak,  Coste,
Roy, Corollary 11.2.4. It is stated for algebraic case but actually there is no difference, according to Thm 8.6.12 of the same book.