1 Introduction

It is well-known that the Morse functions exist on any manifolds and, hence, there exist gradient flows as well. Generically, they are structurally stable and a dynamics of such systems is a base for the class of gradient-like flows, i.e. flows, whose non-wandering set consists of a finite number of hyperbolic fixed points, whose invariant manifolds cross transversally.

Such flows are used everywhere, when modelling regular processes in different natural sciences is used (see, for example, Pesin and Yurchenko 2004). Hence, it is very important to be able to compare dynamics of such models without depending on a nature of their appearing. Meanwhile, depending on research goals, it is important both a qualitative behaviour of a system, i.e. partition into trajectories, and time of moving along trajectories. In dynamical systems theory, the relation, preserving partition into trajectories up to homeomorphism, is called the topological equivalence and the relation, preserving in addition time of moving along trajectories, is called the topological conjugacy. A finding of invariants uniquely determining an equivalence class for a system is called the topological classification.

The finiteness of the set of non-wandering orbits of a gradient-like flow leads to invariants that goes back to the classical works of Andronov and Pontryagin (1937), Leontovich and Mayer (1937, 1955). In the present paper we survey existing graph invariants for gradient-like flows on surfaces up to the topological equivalence and develop effective algorithmsFootnote 1 (i.e. polynomial-time algorithms) for their distinction. Additionally, we construct a parametrized algorithm for the Fleitas’s invariant, which will be of linear time, when the number of sources is fixed. Finally, we prove that the classes of topological equivalence and topological conjugacy are coincide for gradient-like flows. So, all the proposed invariants and distinguishing algorithms work also for the topological conjugacy.

2 Supporting Concepts and Facts

In this part we recall some definitions and facts to effective distinguish graphs appearing below as invariants for gradient-like flows.

2.1 On Gradient-Like Flows on Surfaces

A \(C^1\)-smooth flow on a closed surfaceS is a family of diffeomorphisms \(f^t:S\rightarrow S\), smoothly depended on \(t\in {\mathbb {R}}\), such that \(f^0(x)=x\) and \(f^t(f^s(x))=f^{t+s}(x)\), for any \(x\in S\), \(t,s\in {\mathbb {R}}\). Everywhere below \(f^t\) is a smooth flow on a closed surface S.

For every point \(x\in S\) the set \({\mathcal {O}}_x=\{f^t(x),t\in \mathbb R\}\) is called an orbit of x. The flow orbit is homeomorphic to either a point, or a circle, or a line; and is called either a fixed point, or a periodic orbit, or a non-singular trajectory, respectively. Each orbit, other than a fixed point, is oriented in the direction of increasing time t.

Two flows \(f^t:S\rightarrow S,{f'}^t:S'\rightarrow S'\) are called topologically equivalent if there is a homeomorphism \(h:S\rightarrow S'\) sending the trajectories of \(f^t\) to trajectories of \({f'}^t\) and preserving the orientation of them. If, in addition, the homeomorphism h has a property \(hf^t=h{f'}^t\) for every \(t\in {\mathbb {R}}\), then the flows are said to be topologically conjugate. An invariant of some class of flows is a properties which is preserved up to the topological equivalence or conjugacy.

If the eigenvalues in a fixed point p have a non-zero real part, then p is called a hyperbolic fixed point. The hyperbolicity of the fixed point is expressed by the fact that the point have a stable manifold\(W^s_p\) and an unstable manifold\(W^u_p\) as following

$$\begin{aligned} W^s_p=\{x\in S\mid f^t(x)\rightarrow p,\,t\rightarrow \infty \},\,\,W^u_p=\{x\in S\mid f^t(x)\rightarrow p,\,t\rightarrow -\infty \}, \end{aligned}$$

respectively. Besides, \(dim\, W^u_p\) is equal to the number of eigenvalues with positive real parts. If \(dim\, W^u_p=0\), then p is called a sink, if \(dim\, W^s_p=1\), then p is called a saddle point, if \(dim\, W^u_p=2\), then p is called a source. A connected component \(l^u_p\), \(l^s_p\) of \(W^u_p\backslash \{p\}\), \(W^s_p\backslash \{p\}\) is called unstable, stable separatrix of p respectively.

Proposition 2.1

(Palis and De Melo 1982, Ch. 2, Theorem 4.10; Kruglov 2018, Lemma 1; Robinson 1995, Ch. 4, Theorem 7.1) A flow \(f^t:S\rightarrow S\) in some neighbourhood of a hyperbolic fixed point p is topologically conjugate to one of the following linear flows

$$\begin{aligned} a^t(x,y)=&\left( 2^{-t}x,2^{-t}y\right) ,\\ b^t(x,y)=&\left( 2^{t}x,2^{-t}y\right) ,\\ c^t(x,y)=&\left( 2^tx,2^ty\right) , \end{aligned}$$

if p is a sink, saddle or source, respectively (see Fig. 1).

Fig. 1
figure 1

A local conjugacy between hyperbolic fixed points and fixed points of the linear flows on \({\mathbb {R}}^2\); \(f^t\) is a flow on S, \(a^t,\,b^t\,c^t\) are flows from Proposition 2.1, u is a neighbourhood of the Origin O

A point \(p\in S\) is called a wandering point of a flow \(f^t\), if there is an open neighbourhood \(U_p\) of p, such that \(f^t(U_p)\cap U_p=\emptyset \), for all \(|t|>1\). Otherwise p is called a non-wandering point. The set of all the non-wandering points of \(f^t\) is called the non-wandering set, and it is denoted by \(\Omega _{f^t}\).

A flow \(f^t:S\rightarrow S\) is a gradient-like if its non-wandering set consists of a finite set of hyperbolic fixed points, and there are no trajectories connecting saddle pointsFootnote 2. Everywhere below \(f^t\) is a gradient-like flow on S with at least one saddle pointFootnote 3, \(\Omega ^0_{f^t}\), \(\Omega ^1_{f^t}\)\(\Omega ^2_{f^t}\) are the sets of all sinks, saddles, and sources of \(f^t\), respectively.

Proposition 2.2

(Grines et al. 2016, Theorem 2.1.1 and Corollary 2.2) For every gradient-like flow \(f^t\), we have the following properties:

  1. 1.

    \(S=\bigcup \nolimits _{p\in \Omega _{f^t}}W_p^u=\bigcup \nolimits _{p\in \Omega _{f^t}}W_p^s\);

  2. 2.

    \(W^u_p\,(W^s_p)\) is a smooth submanifold of S diffeomorphic to \({\mathbb {R}}^{i}\,({\mathbb {R}}^{2-i})\), for each fixed point \(p\in \Omega ^i_{f^t}\);

  3. 3.

    for every saddle point \(\sigma \), there is a unique sink (source) point \(\omega \)\((\alpha )\), such that

    $$\begin{aligned} cl(l^u_\sigma )\backslash l^u_\sigma =\{\sigma , \omega \}\,\,\,\,(cl(l^s_\sigma )\backslash l^s_\sigma =\{\sigma , \alpha \}); \end{aligned}$$
  4. 4.

    for each sink \(\omega \) (source \(\alpha )\), there exists at least one saddle point \(\sigma \) with an unstable (stable) separatrix \(l^u_\sigma \)\((l^s_\sigma )\), such that \(cl(l^u_\sigma )\backslash (l^u_\sigma )=\{\sigma , \omega \}\)\((cl(l^s_\sigma )\backslash (l^s_\sigma )=\{\sigma , \alpha \})\).

2.2 Some Basic Definitions and Facts from Graph Theory

A graph is a pair (VE), where V is a set of vertices and E is a set of pairs of vertices, which are called edges. If E contains ordered pairs, then the graph is called a directed one. If some of edges is consisted in E more than one time, then it is called a multiple edge, a graph with multiple edges is called a multigraph.

Two vertices are called adjacent if they are connected by an edge (i.e. they constitute the edge), and the edge is incident to each of the vertices. A loop is an edge, whose end-vertices coincide. A simple graph is an undirected graph without loops and multiple edges.

The number of edges incident to a vertex is called degree of the vertex. A non-directed graph of the maximum vertex degree 3 is called a subcubic.

A set \(\{b_1, (b_1,b_2), b_2, \dots , b_{k-1}, (b_{k-1}, b_k), b_k\}\) is called a path of the length k. If \(b_1=b_k\), then the path is called a cycle. A graph is called connected if every two its vertices are joined by a path.

A graph \((V',E')\), where \(V'\subset V\) and \(E'\subset E\), is called a subgraph of a graph (VE).

A graph is called embeddable into a surface if there are sets of points and Jordan curves with pairwise disjoint interiors on the surface, corresponding to the graph’s vertices and edges, respectively. The genus of a graph is the minimum among genuses of surfaces into which the graph can be embedded. A graph is called planar if it is embeddable into a 2-sphere.

One says that an isomorphism of n vertices graphs can be recognized (tested) in a time t(n) if a distinguishing algorithm contains t(n) operations. The algorithm is called effective if t(n) is restricted by some polynomial function of n.

Proposition 2.3

(Hopcroft and Wong 1974) Isomorphism of two n-vertex planar simple graphs can be recognized in O(n) time.

Proposition 2.4

(Miller 1980) Isomorphism of two n-vertex simple graphs of genus g can be tested in \(O(n^{O(g)})\) time.

Proposition 2.5

(Kawarabayashi 2015, Theorem 1.3) For every integer g, isomorphism of graphs of genus at most g can be done in linear timeFootnote 4.

Proposition 2.6

(Galil et al. 1987) Isomorphism of n-vertex simple subcubic graphs can be recognized in \(O(n^3\log (n))\) time.

Proposition 2.7

(Luks 1982) For each fixed \(\rho \), isomorphism of n-vertex simple graphs of the maximum vertex degree at most \(\rho \) can be recognized in polynomial time.

To this end, we will also need the following graph transformations.

A k-subdivision of an edge\(e=(a,b)\) is the following modification of an initial graph: to delete e from the graph and add new vertices \(c_1,c_2,\ldots ,c_k\) with edges \(ac_1,c_1c_2,\ldots ,c_{k-1}c_k,c_kb\).

A \(k^*\)-subdivision of an edge\(e=(a,b)\) is the following modification of an initial graph: to delete e from the graph and add new vertices \(c_1,c_2,\ldots ,c_k,d\) with edges \(ac_1,c_1c_2,\ldots ,c_{k-1}c_k,c_kb,c_1d\).

3 An Algorithm for Peixoto’s Graph

3.1 Peixoto’s Graph

According to Peixoto (1973), the Peixoto’s invariant for a gradient-like flow \(f^t\) is a connected directed graph \(\Gamma _{f^t}\) with distinguishing sets. Vertices of \(\Gamma _{f^t}\) correspond to fixed points of the flow \(f^t\) and edges correspond to saddle separatrices. The set of vertices is divided into the three parts: vertices for sources, vertices for saddles, and vertices for sinks. Each saddle vertex is incident to four edges, corresponding to four separatrices. There is no an edge, connecting a source vertex with a sink vertex, and all the edges are directed from a source vertex to a saddle vertex or from a saddle vertex to a sink vertex (see Fig. 2).

Fig. 2
figure 2

An example of a gradient-like flow \(f^t\) and its directed graph \(\Gamma _{f^t}\); \(\alpha _i\) is a source, \(a_i\) is a vertex on \(\Gamma _{f^t}\) corresponding to \(\alpha _i\), \(i=\overline{1,4}\); \(\sigma _i\) is a saddle, \(s_i\) is a vertex on \(\Gamma _{f^t}\) corresponding to \(\sigma _i\), \(i=\overline{1,3}\); \(\omega \) is a sink, w is a vertex on \(\Gamma _{f^t}\) corresponding to \(\omega \)

Figure 3 shows that there are non-equivalent gradient-like flows with isomorphic directed graphs. It is the reason that \(\Gamma _{f^t}\) is equipped with some distinguishing sets to receive an equipped graph \(\Gamma ^P_{f^t}\), which will be a complete topological invariant.

Fig. 3
figure 3

Two flows \(f^t\) and \(f'^t\) with the same directed graphs \(\Gamma _{f^t}\) and \(\Gamma _{f'^t}\); \(\alpha _i\) is a source, \(a_i\) is a vertex on \(\Gamma _{f^t}\) corresponding to \(\alpha _i\), \(i=\overline{1,6}\); \(\sigma _i\) is a saddle, \(s_i\) is a vertex on \(\Gamma _{f^t}\) corresponding to \(\sigma _i\), \(i=\overline{1,5}\); \(\omega \) is a sink, w is a vertex on \(\Gamma _{f^t}\) corresponding to \(\omega \); similar for the primed ones

To define a distinguishing set, let us consider the set

$$\begin{aligned} \tilde{S}=S{{\setminus }}\bigcup \limits _{\sigma \in \Omega ^1_{f^t}}\left( {cl}(W^u_\sigma )\cup {cl}(W^s_\sigma )\right) . \end{aligned}$$

The closure of any its connected component is called a cell. Due to Peixoto (1973), all the cells can be of the three types, described in Fig. 4.

Fig. 4
figure 4

The types of cells for a gradient-like flow; \(\alpha \) is a source, \(\sigma ,\,\sigma _1,\,\sigma _2\) are saddles, \(\omega \) is a sink

A distinguishing set is a subgraph corresponding to the boundary of a cell. Hence, distinguishing sets can be of the three types, corresponding to the cell types (see Fig. 5). We call by a tail an edge with one degree in one of its ends.

Fig. 5
figure 5

A flow \(f^t\) from G and its Peixoto’s graph \(\Gamma _{f^t}^P\) with subgraphs; \(\alpha _i\) is a source, \(a_i\) is a vertex on \(\Gamma _{f^t}\) corresponding to \(\alpha _i\), \(i=\overline{1,4}\); \(\sigma _i\) is a saddle, \(s_i\) is a vertex on \(\Gamma _{f^t}\) corresponding to \(\sigma _i\), \(i=\overline{1,3}\); \(\omega \) is a sink, w is a vertex on \(\Gamma _{f^t}\) corresponding to \(\omega \)

Two Peixoto’s graphs \(\Gamma ^P_{f^t},\Gamma ^P_{f'^t}\) of gradient-like flows \(f^t\) and \(f'^t\), respectively, are called isomorphic if there is an isomorphism between \(\Gamma _{f^t}\) and \(\Gamma _{f'^t}\), which preserves distinguishing sets.

Proposition 3.1

(Peixoto 1973, Proposition 4.4) Two gradient-like flows \(f^t,f'^t\) are topologically equivalent iff their Peixoto graphs \(\Gamma ^P_{f^t},\Gamma ^P_{f'^t}\) are isomorphic.

3.2 An Algorithm Distinguishing the Peixoto’s Graphs

We assume that gradient-like flows are given on the same surface S and denote by g(S) the genus of S. The idea to construct an algorithm consists of a transformation of the equipped Peixoto’s graph \(\Gamma ^P_{f^t}\) to a simple graph \({\tilde{\Gamma }}_{f^t}\) such that \(\Gamma ^P_{f^t}\) and \(\Gamma ^P_{f'^t}\) are isomorphic iff \({\tilde{\Gamma }}_{f^t}\) and \({\tilde{\Gamma }}_{f'^t}\) are isomorphic. Moreover we will do it preserving the embeddability for \({\tilde{\Gamma }}_{f^t}\). In more details.

First, we add two degree one neighbours to every saddle vertex of \(\Gamma ^P_{f^t}\). Next, for any type 1 subgraph of \(\Gamma ^P_{f^t}\), we add a new vertex and four edges, connecting the new vertex with all the vertices of the subgraph. Finally, we apply the \(2^*\)-subdivision operation to every oriented edge of \(\Gamma ^P_{f^t}\) the way if they would be oriented otherwise. The resulting graph is \({\tilde{\Gamma }}_{f^t}\) (see Fig. 6).

Fig. 6
figure 6

The Peixoto’s graph \(\Gamma _{f^t}^P\) of with subgraphs and its simple graph \({\tilde{\Gamma }}_{f^t}\); \(a_i\) is a vertex corresponding to a sink, \(i=\overline{1,4}\); \(s_i\) is a vertex corresponding to a saddle, \(i=\overline{1,3}\); w is a vertex corresponding to a sink

Lemma 3.1

The graphs \(\Gamma ^P_{f^t}\) and \(\Gamma ^P_{f'^t}\) are isomorphic iff \({\tilde{\Gamma }}_{f^t}\) and \({\tilde{\Gamma }}_{f'^t}\) are isomorphic.

Proof

Obviously, \({\tilde{\Gamma }}_{f^t}\) can be uniquely constructed by \(\Gamma ^P_{f^t}\). We will show that \(\Gamma ^P_{f^t}\) can also be uniquely restored by \({\tilde{\Gamma }}_{f^t}\). This fact implies the correctness of this lemma.

A vertex of \({\tilde{\Gamma }}_{f^t}\) is a saddle in \(\Gamma ^P_{f^t}\) iff it has two neighbour degree one vertices. Hence, all the saddle vertices can be uniquely determined. Let x be a saddle vertex of \(\Gamma ^P_{f^t}\). In \({\tilde{\Gamma }}_{f^t}\), it is adjacent to a degree two vertex y and to a degree three vertex z. The vertex y has a degree three neighbour \(y'\), which has two neighbours and one of them, denoted by \(y''\), has degree one or more than one. The vertex \(y''\) is a sink vertex and \(xy''\) is an edge in \(\Gamma ^P_{f^t}\). The vertex z has a degree two neighbour \(z'\), which has a neighbour \(z''\ne z\). The vertex \(z''\) is a source vertex and \(z''x\) is an edge in \(\Gamma ^P_{f^t}\).

Knowing sink, source, and saddle vertices of \(\Gamma ^P_{f^t}\), it is possible to restore all its tails. Any subgraph of type 2 or 3 is completely defined by its tail. Hence, all subgraphs of these types can be uniquely found. Vertices of type 1 subgraphs are defined as the neighbours of those degree four vertices of \({\tilde{\Gamma }}_{f^t}\) that belong to four 5-cycles. \(\square \)

Theorem 1

Let \(f^t\) and \(f'^t\) be gradient-like flows on S, \(\Gamma ^P_{f^t}\) and \(\Gamma ^P_{f'^t}\) be their equipped n-vertex Peixoto’s graphs with m edges. Then isomorphism of \(\Gamma ^P_{f^t}\) and \(\Gamma ^P_{f'^t}\) can be tested in \(O(n^{O(g(S))})\) time. This problem can be solved in O(m) time if \(g(S)=0\).

Proof

First, construct \({\tilde{\Gamma }}_{f^t}\) and \({\tilde{\Gamma }}_{f'^t}\) by \(\Gamma ^P_{f^t}\) and \(\Gamma ^P_{f'^t}\). It can be done in O(m) time. Additionally, \({\tilde{\Gamma }}_{f^t}\) and \({\tilde{\Gamma }}_{f'^t}\) both have O(m) vertices. Both graphs \({\tilde{\Gamma }}_{f^t}\) and \({\tilde{\Gamma }}_{f'^t}\) can be emdedded into S. Indeed, it is true for \(\Gamma _{f^t}\) and \(\Gamma _{f'^t}\). Putting new vertices, corresponding to type 1 subgraphs, inside type 1 cells does not create an intersection of edges in an interior point. The same is true for adding degree one vertices. Hence, \({\tilde{\Gamma }}_{f^t}\) and \({\tilde{\Gamma }}_{f'^t}\) are both emdeddable into S. By Propositions 2.3 and 2.4, isomorphism \({\tilde{\Gamma }}_{f^t}\) and \({\tilde{\Gamma }}_{f'^t}\) can be checked in \(O(n^{O(g(S))})\) time (in O(m) time if \(g(S)=0\)). Thus, the same is true for \(\Gamma ^P_{f^t}\) and \(\Gamma ^P_{f'^t}\). \(\square \)

4 An Algorithm for a Modification of Peixoto’s Graph

4.1 A Modification of Peixoto’s Graph

In 2011, Grines et al. (2016) suggestedFootnote 5 another version of the Peixoto’s invariant. Namely, they avoid the distinguishing sets and equipped the directed Peixoto’s graph \(\Gamma _{f^t}\) by orders of some edges to obtain an equipped graph \(\Gamma ^{GP}_{f^t}\).

Let \(\omega \) be a sink of \(f^t\), and let \(L_\omega \) be the set of separatrices containing \(\omega \) in their closures. It follows, for example, from Proposition 2.1 that there is a 2-disk \(B_\omega \ni \omega \), such that each separatrix \(l\subset L_\omega \) intersects \(\partial B_\omega \) at a unique point. For the vertex w, corresponding to \(\omega \), let \(E_w\) be the set of edges of the graph \(\Gamma _{f^t}\) incident to w. Let \(N_w\) be the cardinality of the set \(E_w\). Let us enumerate elements of \(E_w\) in the next way. We pick a 2-disk \(B_\omega \) in the basin of \(\omega \) and set \(c_\omega =\partial B_\omega \). We define the counterclockwise orientation on \(c_\omega \) with respect to \(B_\omega \). We enumerate all the edges \(e_1,\dots , e_{N_w}\) from \(E_w\) according to the order of the corresponding separatrices as we move along \(c_\omega \), starting from some point on \(c_\omega \). This enumeration of all the elements of \(E_w\) is said to be compatible with the embedding of the separatrices.

Two equipped graphs \(\Gamma ^{GP}_{f^t}\) and \(\Gamma ^{GP}_{f^{\prime t}}\) of flows \(f^t\) and \(f^{\prime t}\) (possibly, on different ambient surfaces) are said to be isomorphic if there is an isomorphism \(\xi \) between \(\Gamma _{f^t}\) and \(\Gamma _{f'^t}\), such that the permutation \(\Theta _{w,w'}\), where \(w'=\xi (w)\), induced by \(\xi \) is a power of a cyclic permutationFootnote 6, for each vertex w, corresponding to a sink.

Consider Fig. 3 once again and suppose that the vertex \(w~(w')\) of the graph corresponds to the sink point \(\omega ~(\omega ')\) and the vertex \(a~(a')\) of the graph corresponds to the source point \(\alpha ~(\alpha ')\). We renumber the separatrices \(l^u_1,l^u_2,l^u_3,l^u_4\) (\(l^{\prime u}_1,l^{\prime u}_2,l^{\prime u}_3, l^{\prime u}_4\)) of the saddle points belonging to the stable manifold of the point \(\omega ~(\omega ')\) in accordance with the positive orientation on a closed curve around \(\omega \) (\(\omega '\)). We denote by \(\sigma _1,\sigma _2,\sigma _3,\sigma _4\) (\(\sigma ^\prime _1,\sigma ^\prime _2,\sigma ^\prime _3,\sigma ^\prime _4\)) the saddle points that satisfy the condition that \(\sigma _i\) (\(\sigma ^\prime _i\)) belongs to the closure of \(l^u_i\) (\(l^{\prime u}_i\)). Introduce a numeration on the set \(E_\omega \) (\(E_\omega ^\prime \)) compatible with the embedding of the separatrices. As we have already noted, the graphs \(\Gamma _{f^t}\) and \(\Gamma _{f'^t}\) are isomorphic. There are exactly two isomorphisms of these graphs: the isomorphism \(\xi _1\) of the natural identification of the graph \(\Gamma _{f^t}\) with the graph \(\Gamma _{f'^t}\) and the isomorphism \(\xi _2\) that is the composition of the natural identification and the reflection with respect to the axis \(a'w'\). One can directly check that the isomorphism \(\xi _1\) induces the permutation \(\Theta _{w,w'}=\begin{pmatrix} 1&{}2&{}3&{}4\\ 1&{}2&{}4&{}3&{}\end{pmatrix}\) and the isomorphism \(\xi _2\) induces the permutation \(\Theta _{w,w'}=\begin{pmatrix} 1&{}2&{}3&{}4\\ 4&{}3&{}2&{}1&{}\end{pmatrix}\). None of the permutations is a power of a cyclic permutation and the equipped graphs \(\Gamma ^{GP}_{f^t}\) and \(\Gamma ^{GP}_{f^{\prime t}}\) are not isomorphic.

Proposition 4.1

(Grines et al. 2016, Theorem 3.2.1) Gradient-like flows \(f^t\) and \(f^{\prime t}\) are topologically conjugate iff their equipped graphs \(\Gamma ^{GP}_{f^t}\) and \(\Gamma ^{GP}_{f^{\prime t}}\) are isomorphic.

4.2 An Algorithm Distinguishing the Modifying Peixoto’s Graphs

We will use an idea which is similar to one for Peixoto’s graphs and modify the graph \(\Gamma ^{GP}_{f^t}\) up to a graph \({\bar{\Gamma }}_{f^t}\) by the following way.

For any sink vertex w of \(\Gamma ^{GP}_{f^t}\), we consider the cyclically ordered set \(E_w\) of all the edges, incident to w. We delete w from \(\Gamma ^{GP}_{f^t}\) (and all the edges, incident to w), add a cycle with \(N_w\) vertices to the resulting graph, whose vertices are numbered with \(1,\ldots ,N_w\). For any \(1\le i \le N_w\), we add a non-oriented edge between i-th vertex of the cycle and the second end of i-th element of \(E_w\) distinct to w. Next, we add two degree one neighbours to every saddle vertex of \(\Gamma ^{GP}_{f^t}\) and apply the \(2^*\)-subdivision operation to every its oriented edge.

Lemma 4.1

The graphs \(\Gamma ^{GP}_{f^t}\) and \(\Gamma ^{GP}_{f'^t}\) are isomorphic iff \({\bar{\Gamma }}_{f^t}\) and \({\bar{\Gamma }}_{f'^t}\) are isomorphic.

Proof

Similar to the reasonings from the proof of Lemma 3.1, knowing \({\bar{\Gamma }}_{f^t}\), it is possible to restore all the saddles of \(\Gamma ^{GP}_{f^t}\) and all the edges of \(\Gamma ^{GP}_{f^t}\). Hence, all the cycles of \({\bar{\Gamma }}_{f^t}\), corresponding to all the sinks of \(\Gamma ^{GP}_{f^t}\), can be determined. A cyclical order of \(E_w\) is determined under rounding of the cycles. Hence, knowing \({\bar{\Gamma }}_{f^t}\), it is possible to uniquely restore \(\Gamma ^{GP}_{f^t}\) The opposite possibility is obvious. \(\square \)

Theorem 2

Let \(f^t\) and \(f'^t\) be gradient-like flows on S, \(\Gamma ^{GP}_{f^t}\) and \(\Gamma ^{GP}_{f'^t}\) be their equipped n-vertex graphs with m edges. Then isomorphism of \(\Gamma ^{GP}_{f^t}\) and \(\Gamma ^{GP}_{f'^t}\) can be tested in \(O(n^{O(g(S))})\) time. This problem can be solved in O(m) time if \(g(S)=0\).

Proof

We start from constructing the graphs \({\bar{\Gamma }}_{f^t}\) and \({\bar{\Gamma }}_{f'^t}\) by \(\Gamma ^{GP}_{f^t}\) and \(\Gamma ^{GP}_{f'^t}\). It can be done in O(m) time. Additionally, \({\bar{\Gamma }}_{f^t}\) and \({\bar{\Gamma }}_{f'^t}\) both have O(m) vertices. Since \({\tilde{\Gamma }}_{f^t}\) and \({\tilde{\Gamma }}_{f'^t}\) can be embedded into S, \(<<\text {inscribing}>>\) cycles into sinks of \(\Gamma ^{GP}_{f^t}\) and \(\Gamma ^{GP}_{f'^t}\) keeps embeddability into S, then \({\bar{\Gamma }}_{f^t}\) and \({\bar{\Gamma }}_{f'^t}\) can also be embedded into S. By Propositions 2.3 and 2.4, isomorphism \({\bar{\Gamma }}_{f^t}\) and \({\bar{\Gamma }}_{f'^t}\) can be checked in \(O(n^{O(g(S))})\) time (in O(m) time if \(g(S)=0\)). Thus, the same is true for \(\Gamma ^{GP}_{f^t}\) and \(\Gamma ^{GP}_{f'^t}\). \(\square \)

5 An Algorithm for Wang’s Graph

5.1 Wang’s Graph

The Wang’s invariant (Wang 1990) is an invariant for gradient-like flows on oriented surfaces S. The invariant is a graph dual to the unequipped Peixoto’s graph: for the Wang’s graph \(\Gamma ^W_{f^t}\) for \(f^t\) correspond to the cells of \(f^t\) its edges of the colour s correspond to the stable separatrices and edges of the colour u correspond to the unstable separatrices (see Fig. 7). This graph consists of 4-cycles around each saddle point, its edges are coloured in two colours u and s, the opposite edges in all the 4-cycles have the same colour. Hence, each its vertex has degree two or four. In addition, all the edges are directed so that the direction of any edge is consistent with the clockwise orientation of its 4-cycle.

Fig. 7
figure 7

A flow \(f^t\) from G on a surface S and its Wang’s invariant \(\Gamma ^W_{f^t}\); \(s,\,u\) are the colours for edges

Two Wang’s graphs \(\Gamma ^W_{f^t},\Gamma ^W_{f'^t}\) for gradient-like flows \(f^t,f'^t\), respectively, are called isomorphic if there is an isomorphism between \(\Gamma ^W_{f^t}\) and \(\Gamma ^W_{f'^t}\) preserving the colours.

Proposition 5.1

(Wang 1990) The gradient-like flows \(f^t,f'^t\) are topologically equivalent iff their Wang’s graphs \(\Gamma ^W_{f'^t},\Gamma ^W_{f'^t}\) are isomorphic.

5.2 An Algorithm Distinguishing the Wang’s Graphs

By the graph \(\Gamma ^W_{f^t}\), we construct a graph \(\breve{\Gamma }_{f^t}\) as follows. We apply \(2^*\)-subdivision to every oriented edge of the colour s and \(3^*\)-subdivision to every oriented edge of the colour u. The same operation is done for the graph \(\Gamma ^W_{f'^t}\) to obtain a graph \(\breve{\Gamma }_{f'^t}\). These operations take linear time on the numbers of vertices.

Lemma 5.1

The graphs \(\Gamma ^W_{f^t}\) and \(\Gamma ^W_{f'^t}\) are isomorphic iff \(\breve{\Gamma }_{f^t}\) and \(\breve{\Gamma }_{f'^t}\) are isomorphic.

Proof

To prove the lemma, we only need to show that \(\Gamma ^W_{f^t}\) can be uniquely reconstructed by \(\breve{\Gamma }_{f^t}\). Indeed, in \(\breve{\Gamma }_{f^t}\), we find all degree 4 vertices, which will be degree 4 vertices in \(\Gamma ^W_{f'^t}\), remove them to obtain the disjunctive sum of path-like remaining subgraphs. By degree 3 vertices in these subgraphs, it is possible restore all edges in 4-cycles and their colours in \(\Gamma ^W_{f^t}\). \(\square \)

Theorem 3

Let \(f^t,f'^t\) be gradient-like flows and \(\Gamma ^W_{f^t},\Gamma ^W_{f'^t}\) be their n-vertex Wang’s graphs. Then isomorphism of \(\Gamma ^W_{f^t}\) and \(\Gamma ^W_{f'^t}\) can be tested in a polynomial time on n. If, additionally, \(f^t\) and \(f'^t\) are given on the same surface S, then isomorphism of \(\Gamma ^W_{f^t}\) and \(\Gamma ^W_{f'^t}\) can be tested in \(O(n^{O(g(S))})\) time (in O(n) time, if \(g(S)=0)\).

Proof

Firstly, construct \(\breve{\Gamma }_{f^t}\) and \(\breve{\Gamma }_{f'^t}\) by \(\Gamma ^W_{f^t}\) and \(\Gamma ^W_{f'^t}\). It can be done in linear time. The sizes of \(\breve{\Gamma }_{f^t}\) and \(\breve{\Gamma }_{f'^t}\) linearly depend on the sizes of \(\Gamma ^W_{f^t}\) and \(\Gamma ^W_{f'^t}\), respectively. Notice that the maximum vertex degrees of \(\breve{\Gamma }_{f^t}\) and \(\breve{\Gamma }_{f'^t}\) are 4. From this fact, Lemma 5.1, and Propositions 2.3, 2.4, 2.7 the statement of this lemma follows. \(\square \)

6 Algorithms for Oshemkov–Sharko’s Graph

6.1 Oshemkov–Sharko’s Graph

The Oshemkov-Sharko’s invariant (Oshemkov and Sharko 1998) for a gradient-like flow \(f^t\) is a three-colour graph \(\Gamma ^{OS}_{f^t}\) defined as follows. We were already speaking about cells and their three types in Sect. 3 (see Fig. 4). We remove a trajectory from each cell that connects its source and sink. These curves are said to be t-curves. A connected component of the cell that we have got is called a triangular domain. Its boundary is the union of closures of an unstable saddle separatrix, i.e. u-curve, a stable saddle separatrix, i.e. s-curve, and a t-curve. We call these coloured curves as sides of the triangular domain. Also the boundary of any triangular domain contains exactly one source, one sink, and one saddle (see Fig. 8).

Fig. 8
figure 8

A triangular domain; \(\alpha \) is a source, \(\omega \) is a sink, \(\sigma \) is a saddle, \(l^s_\sigma \) is a stable sepratrix, \(l^u_\sigma \) is an unstable separatrix

Vertices of the graph \(\Gamma ^{OS}_{f^t}\) correspond to triangular domains of \(f^t\), edges correspond to their sides and have the same colour – u, s or t (see Fig. 9).

Fig. 9
figure 9

A gradient-like flow \(f^t\) on a surface S and its Oshemkov-Sharko’s invariant – three-colour graph \(\Gamma ^{OS}_{f^t}\); \(u,\,s,\,t\) are the colours for edges and colour curves

Two graphs \(\Gamma ^{OS}_{f^t}\) and \(\Gamma ^{OS}_{f'^t}\) of gradient-like flows \(f^t,f'^t\), respectively, are called isomorphic if there is an isomorphism between \(\Gamma ^{OS}_{f^t}\) and \(\Gamma ^{OS}_{f'^t}\) preserving colours.

Proposition 6.1

(Oshemkov and Sharko 1998, Theorem 1.10) Two gradient-like flows \(f^t, f'^t\) are topologically equivalent iff their graphs \(\Gamma ^{OS}_{f^t}\) and \(\Gamma ^{OS}_{f'^t}\) are isomorphic.

6.2 An Effective Algorithm to Distinguish the Oshemkov–Sharko’s Graphs

In the paper (Oshemkov and Sharko 1998), the authors proposed an algorithm for distinguishing their graphs. Unfortunately, it is not polynomial-time and below we suggest an effective algorithm.

Again, we use the idea of reduction of the isomorphism problem for three-colour graphs to the same problem for simple graphs of bounded degree or embedded into the ambient surface. We construct a graph \({\check{\Gamma }}_{f^t}\) by 1-subdividing each s-edge, 2-subdividing each t-edge, and 3-subdividing each u-edge of \(\Gamma ^{OS}_{f^t}\) (see Fig. 10).

Fig. 10
figure 10

The three-colour graph \(\Gamma ^{OS}_{f^t}\) and its simple graph \({\check{\Gamma }}_{f^t}\); \(u,\,s,\,t\) are the colours for edges and colour curves

Lemma 6.1

The graphs \({\check{\Gamma }}_{f^t}\) and \({\check{\Gamma }}_{f'^t}\) are isomorphic iff \(\Gamma ^{OS}_{f^t}\) and \(\Gamma ^{OS}_{f'^t}\) are isomorphic.

Proof

The graphs \({\check{\Gamma }}_{f^t}\) and \({\check{\Gamma }}_{f'^t}\) can be uniquely constructed by the graphs \(\Gamma ^{OS}_{f^t}\) and \(\Gamma ^{OS}_{f'^t}\). Let us show that the opposite fact is true. To this end, we may consider the graphs \({\check{\Gamma }}_{f^t}\) and \(\Gamma ^{OS}_{f^t}\) only. Degree 3 vertices of \({\check{\Gamma }}_{f^t}\) are exactly degree 3 vertices of \(\Gamma ^{OS}_{f^t}\). A colour of any edge of \(\Gamma ^{OS}_{f^t}\) is determined by length of a path between the edge’s end vertices in \({\check{\Gamma }}_{f^t}\). This finishes the proof of this lemma. \(\square \)

Theorem 4

Let \(f^t\) and \(f'^t\) be gradient-like flows, \(\Gamma ^{OS}_{f^t}\) and \(\Gamma ^{OS}_{f'^t}\) be their n-vertex Oshemkov-Sharko’s graphs. Then isomorphism of \(\Gamma ^{OS}_{f^t}\) and \(\Gamma ^{OS}_{f'^t}\) can be tested in \(O(n^3\log (n))\) time. If \(f^t\) and \(f'^t\) are given on the same surface S, then isomorphism of \(\Gamma ^{OS}_{f^t}\) and \(\Gamma ^{OS}_{f'^t}\) can be checked in \(O(n^{O(g(S))})\) time (in O(n) time, if \(g(S)=0)\).

Proof

The graphs \({\check{\Gamma }}_{f^t}\) and \({\check{\Gamma }}_{f'^t}\) can be obtained in O(n) time and both have at most 5n vertices. The graphs \({\check{\Gamma }}_{f^t}\) and \({\check{\Gamma }}_{f'^t}\) are subcubic and both embeddable into S whenever \(f^t\) and \(f'^t\) are on S. Hence, by Propositions 2.3, 2.4, 2.6, and Lemma 6.1 this lemma holds. \(\square \)

7 Algorithms for the Fleitas’ Graph

7.1 Fleitas’ Graph

The Fleitas’ invariant \(\Gamma ^F_{f^t}\) (Fleitas 1975) for a gradient-like flow \(f^t\) is constructed in the next way. Choose around each source a circle inside the cell’s closure, transversal to \(f^t\)’s trajectories. Then label all the intersections of each circle and saddle separatrices with marks so that intersections with separatrices of the same saddle have the same mark. After that let us equip each chosen intersection point by a spin, i.e. an arrow directed along the circle so that if we move intersection points with the same mark in direction of their arrows, then their trajectories would converge to the same separatrix (see Fig. 11).

Fig. 11
figure 11

A gradient-like flow \(f^t\) and its Fleitas’ invariant \(\Gamma ^F_{f^t}\); \(\alpha _i\) is a source, \(i=\overline{1,4}\); \(\sigma _i\) is a saddle, \(i=\overline{1,3}\), \(\omega \) is a sink; 1, 2 and 3 are the labels

Two Fleitas’ invariants \(\Gamma ^F_{f^t}\) and \(\Gamma ^F_{f'^t}\) of gradient-like flows \(f^t,f'^t\), respectively, are called isomorphic if there is an isomorphism mapping circles of \(\Gamma ^F_{f^t}\) into circles of \(\Gamma ^F_{f'^t}\) preserving marks and spins.

The Fleitas’ invariant was created to classify not all gradient-like flows on surfaces but only polar flows (only one sink and one source).

Proposition 7.1

(Fleitas 1975) Two polar flows \(f^t,f^t\) (possibly, on distinct surfaces) are topologically equivalent iff their Fleitas’ invariants \(\Gamma ^F_{f^t}\) and \(\Gamma ^F_{f'^t}\) are isomorphic.

7.2 An Algorithm Distinguishing the Fleitas’ Graphs

7.2.1 Efficient Algorithms Based on Boundedness of Vertex Degrees and Embeddability into the Ambient Surface

For the graph \(\Gamma ^F_{f^t}\), we define a graph \({\hat{\Gamma }}_{f^t}\) as follows. We apply \(2^*\)-subdivision to every oriented edge (including loops) and put an edge between any pair of vertices with the same marks. The same operation is done with \(\Gamma ^F_{f'^t}\) to obtain a graph \({\hat{\Gamma }}_{f'^t}\).

Lemma 7.1

The graphs \({\hat{\Gamma }}_{f^t}\) and \({\hat{\Gamma }}_{f'^t}\) are isomorphic iff \(\Gamma ^{F}_{f^t}\) and \(\Gamma ^{F}_{f'^t}\) are isomorphic.

Proof

The graphs \({\hat{\Gamma }}_{f^t}\) and \({\hat{\Gamma }}_{f'^t}\) can be uniquely constructed by the graphs \(\Gamma ^{F}_{f^t}\) and \(\Gamma ^{F}_{f'^t}\). We will show that the opposite fact is also true. One may consider the graphs \({\hat{\Gamma }}_{f^t}\) and \(\Gamma ^{F}_{f^t}\) only. Two vertices x and y of \({\hat{\Gamma }}_{f^t}\) constitute the oriented edge xy in \(\Gamma ^{F}_{f^t}\) iff there is a path \((x,x',y',y)\) in \({\hat{\Gamma }}_{f^t}\), such that \(y'\) has a degree one neighbour in \({\hat{\Gamma }}_{f^t}\). Therefore, all the cycles around source vertices can be restored. By these cycles and edges between them it is possible to uniquely restore the marks.\(\square \)

Theorem 5

Let \(f^t\) and \(f'^t\) be gradient-like flows, \(\Gamma ^{F}_{f^t}\) and \(\Gamma ^{F}_{f'^t}\) be their n-vertex Fleitas’ graphs. Then isomorphism of \(\Gamma ^{F}_{f^t}\) and \(\Gamma ^{F}_{f'^t}\) can be tested in \(O(n^3\log (n))\) time. If \(f^t\) and \(f'^t\) lye on the same surface S, then isomorphism of \(\Gamma ^{F}_{f^t}\) and \(\Gamma ^{F}_{f'^t}\) can be checked in \(O(n^{O(g(S))})\) time (in O(n) time, if \(g(S)=0\)).

Proof

The graphs \({\hat{\Gamma }}_{f^t}\) and \({\hat{\Gamma }}_{f'^t}\) can be obtained in O(n) time and both have at most 5n vertices. The graphs \({\hat{\Gamma }}_{f^t}\) and \({\hat{\Gamma }}_{f'^t}\) are subcubic and both embeddable into S whenever \(f^t\) and \(f'^t\) are on S. Hence, by Propositions 2.3, 2.4, 2.6, and Lemma 7.1 this lemma holds. \(\square \)

7.2.2 A Parameterized Algorithm for the Fleitas’ Invariant

We consider n-vertex subcubic graphs (possibly, with loops and multiple edges), whose vertex sets were partitioned into k clockwise oriented cycles and suppose that the partition into the cycles is explicitly given. We assume that a loop gives one to degree of its ends. For short, we will refer these graphs to as (nk)-graphs. In this subsection, we present an algorithm to solve the isomorphism problem for (nk)-graphs with the computational complexity \(O((k+1)!\cdot n)\). Therefore, if the number of sources is fixed, then the Fleitas’ criterion can be applied in linear time.

The main idea will be a reduction of the graph isomorphism problem to the following stringology task. Given two strings \(X=X_1X_2\ldots X_l\) and \(Y=Y_1Y_2\ldots Y_l\), the task is to verify that Y is a cyclic permutation of X. It can be solved in O(l) time by considering the word \(Z=X_1X_2\ldots X_lX_1X_2\ldots X_l\), containing all cyclic permutations of X, and by subsequent applying any linear-time string matching algorithm (like algorithms in Aho and Corasick (1975) Apostolico and Giancarlo (1986) Donald et al. (1977)) to find an entering of Y to Z. Further, it will be explained how to construct, by two given (nk)-graphs, two sets of at most k! strings, each with at most \(3\cdot n\) characters in the alphabet \(\{-n,-n+1,\ldots ,-1,0,1,\dots ,n-1,n\}\). The time-complexity of this process will be \(O((k+1)!\cdot n)\). The graphs will be isomorphic iff there are two strings from distinct sets, one of which is a cyclic permutation of another.

Theorem 6

The isomorphism problem for (nk)-graphs can be solved in \(O((k+1)!\cdot n)\) time.

Proof

Let \(\Gamma \) be a connected (nk)-graph. We number all the cycles by numbers from 1 to k, such that, for any \(2 \le i\le k\), there is an edge between \(\bigcup \nolimits _{j=1}^{i-1} V(C_j)\) and \(C_i\). There are at most k! such numerations, and all the appropriate numerations can be computed in \(O(k!\cdot n)\) time. Denote by \(C_1,\ldots ,C_k\) all the numbered, oriented cycles. For any \(i\ge 2\), some vertices of \(C_i\) will be added to a \(<<\text {sum}>>\)\({\tilde{C}}_{i-1}\) of \(C_1,\ldots ,C_{i-1}\). The \(<<\text {sum}>>\) \({\tilde{C}}_{i-1}\) will be a clockwise oriented cycle and every vertex of \({\tilde{C}}_{i-1}\) will have one, two or three ordered labels. Every degree two vertex of \(\Gamma \), belonging to \(\bigcup \nolimits _{j=1}^{i}V(C_i)\), will obligatory be on \({\tilde{C}}_{i}\) and will have exactly one label. Any adjacent degree three vertices of \(\Gamma \), both belonging to one of the cycles \(C_1,\ldots ,C_i\), will obligatory be on \({\tilde{C}}_{i-1}\) and will have exactly two labels. Vertices of \({\tilde{C}}_{i}\), having exactly three labels, correspond to edges between distinct elements of the set \(\{C_1,\ldots ,C_i\}\). Initially, \({{{\tilde{C}}}}_1=C_1\) and all its vertices are labelled with the label 1.

The transformation from \({{{\tilde{C}}}}_{i-1}\) to \({{{\tilde{C}}}}_{i}\) is as follows. Let \(x_1y_1,x_2y_2,\ldots ,x_{j_i}y_{j_i}\) be all the edges between \({{{\tilde{C}}}}_{i-1}\) and \(C_{i}\), i.e., for any \(1\le j\le j_i\), we have \(x_j\in V({{{\tilde{C}}}}_{i-1})\) and \(y_j\in V(C_i)\). Suppose that \(y_1,\ldots ,y_{j_i}\) are clockwise located on \(C_i\). Let \(z_j\) be the right neighbour of \(x_j\) on \({{{\tilde{C}}}}_{i-1}\). For any \(1\le j\le j_i\), if \(y_{j_i+1}\) is not a neighbour of \(y_{j_i}\) in \(C_i\), we delete the edge \(x_jz_j\) from \({\tilde{C}}_{i-1}\), add a path, strictly clockwise located between \(y_j\) and \(y_{j+1}\) on \(C_i\), where \(y_{j_i+1}=y_1\). We also add two edges, one of which connects \(x_j\) and the right neighbour of \(y_j\) on \(C_i\), the another one connects \(z_j\) and the left neighbour of \(y_{j+1}\) on \(C_i\).

We arrange i as the second label to all the vertices \(x_1,\ldots ,x_{j_i}\) and as the first label to all vertices of all the added paths. Second labels are also given to any two adjacent vertices a and b of \(C_i\). If \(a=b\), then zero is the second label of a. If \(a\ne b\), then let \(n_a\) and \(n_b\) be the numbers of vertices on clockwise oriented arcs between ab and between ba, correspondingly. The vertex a has the second label \(n_a+1\), and the vertex b has the second label \(n_b+1\). Clearly, \({\tilde{C}}_i\) can be uniquely constructed by \({\tilde{C}}_{i-1}\) and \(C_i\). Moreover, by \({\tilde{C}}_i\), it is possible to uniquely reconstruct \({\tilde{C}}_{i-1}\), \(V(C_i)\), all the edges between \({\tilde{C}}_{i-1}\), and internal paths between \(y_j\) and \(y_{j+1}\), for any \(1\le j\le j_i-1\). But, we do not know an order for assembling paths between \(y_j\) and \(y_{j+1}\), where \(1\le j\le j_i-1\), to obtain the cycle \(C_i\). It is easy to see that the procedure, described in this paragraph, can be done in \(O(|V({\tilde{C}}_{i-1})|+|V(C_i)|)\) time.

The current information, stored in \({\tilde{C}}_i\), and the \(j_i\)-link oriented broken line, composed of the vectors \(\overrightarrow{x_1x_2},\overrightarrow{x_2x_3},\ldots , \overrightarrow{x_{j_i}x_1}\), completely define \({\tilde{C}}_{i-1}, C_i\) and all the edges between them, as \({\tilde{C}}_i\) and the \(j_i\)-link define an order for assembling the paths between \(y_j\) and \(y_{j+1}\), where \(1\le j\le j_i-1\). To encode the line, let us consider a clockwise oriented cycle C on the vertices \(x_1,\ldots , x_{j_i}\), lied on C in the same order as on \({\tilde{C}}_{i-1}\). We clockwise number all the vertices of C. By this numeration, for any \(1\le j\le j_i\), it is possible to compute in O(1) time the number \(n_j\) of vertices on the clockwise oriented arc between \(x_j\) and \(x_{j+1}\). Note that the vector \((n_1,n_2,\ldots ,n_{j_i})\) does not depend on the numeration of vertices and completely defines the line together with some its point. If arc’s orientation coincides with the orientation of \(\overrightarrow{x_{j}x_{j+1}}\), then the third label of \(x_j\) is \(n_j+1\); otherwise it is \(-n_j-1\). Clearly that the total computation time for finding all these third labels is \(O(|V({\tilde{C}}_{i-1})|+|V(C_i)|)\).

Therefore, for any i, \({\tilde{C}}_{i-1},C_i\), and all the edges between them uniquely define \({\tilde{C}}_i\) and vice versa. Hence, \(\Gamma \) uniquely defines a cycle \({\tilde{C}}_k\) and vice versa. The complexity for obtaining \({{{\tilde{C}}}}_k\) by the graph G is

$$\begin{aligned} O(\sum \limits _{i=1}^{k}(k-i)\cdot |V(C_i)|)=O(k\cdot \sum \limits _{i=1}^{k}|V(C_i)|)=O(k\cdot n). \end{aligned}$$

By \({\tilde{C}}_k\), a string is obtained as follows. Started from any vertex of \({\tilde{C}}_k\), we clockwise read all its vertices, adding one, two or three characters to the current word, depending on a vertex’s type. So, the total complexity for obtaining the whole set of words is \(O(k!\cdot k\cdot n)=O((k+1)!\cdot n)\). Two given (nk)-graphs are isomorphic iff there are two words from distinct sets, such that one of them is a cyclic permutation of another. Thus, the isomorphism problem for (nk)-graphs can be solved in \(O((k+1)!\cdot n)\) time. \(\square \)

8 Topological Conjugacy of Gradient-Like Flows

The next theorem gives an opportunity to use all instruments for recognizing an equivalence class of a gradient-like flow also to recognize its conjugacy class. This theorem has been schematically proved as the main theorem in Kruglov (2018), but we give here a modified and most detailed version of its proof.

Theorem 7

If two gradient-like flows on a closed surface are topologically equivalent, then they are topologically conjugate.

Proof

Let S be a closed surface and \(f^t:S\times {\mathbb {R}}\rightarrow S\) be a \(C^1\) gradient-like flow. Then, for every wandering trajectory \(\ell \) of \(f^t\), there are exactly two different fixed points pq of \(f^t\), such that the boundary of the trajectory has the form

$$\begin{aligned} \text {cl}(\ell )\backslash \ell =\{p, q\}, \end{aligned}$$

and the trajectory is directed from p to q. In this case we will denote the trajectory by \(\ell _{p,q}\) assuming that the trajectory is directed from p to q.

Let \(f'^t\) be a \(C^1\) gradient-like flow topologically equivalent to \(f^t\), i.e. there is a homeomorphism \(h:S\rightarrow S\), sending trajectories of \(f^t\) into trajectories of \(f'^t\) and preserving orientations of trajectories. It implies that h sends the fixed points of \(f^t\) to the fixed points of \(f'^t\), we will denote \(p'=h(p)\) for \(p\in \Omega _{f^t}\). Then

$$\begin{aligned} h(\ell _{pq})=\ell '_{p'q'}, \end{aligned}$$

for every wandering trajectory \(\ell _{pq}\) of \(f^t\).

Let \(U_0=\{(x,y)\in {\mathbb {R}}^2\mid x^2+y^2<1\}\). By Proposition 2.1, there exist neighbourhoods \(u_p\), \(u_{p'}\) of p, \(p'\) respectively and homeomorphisms \(\psi _p:u_p\rightarrow U_0\), \(\psi _{p'}:u_{p'}\rightarrow U_0\) such that restrictions \(f^t|_{u_p}\) and \(f'^t|_{p'}\) are conjugate by means of a homeomorphism \(h_p=\psi ^{-1}_{p'}\psi _p:u_p\rightarrow u_{p'}\), i.e. \(h_p\circ f^t|_{u_p}=f'^t|_{u_{p'}}\circ h_p\) for any t not moving points outward \(u_p\), \(u_{p'}\) respectively.

Let \(\sigma \) be a saddle point of \(f^t\). Consider \(u_\sigma \) and \(U_0\). Let \({{\tilde{U}}}_0\subset U_0\) and its boundary be constructed the next way. Let \(l_{++}\), \(l_{-+}\), \(l_{--}\), \(l_{+-}\) be the four trajectories of the flow \(b^t(x,y)=\left( 2^{-t}x,2^ty\right) :{\mathbb {R}}^2\rightarrow {\mathbb {R}}^2\) lying in different quadrants. Let \({{\tilde{U}}}_0\) be the part of \(U_0\) restricted by these trajectories (see Fig. 12). Denote \({{\tilde{u}}}_\sigma =\psi _\sigma ^{-1}({{\tilde{U}}}_0)\) and \(\tilde{u}_{\sigma '}=\psi _{\sigma '}^{-1}({{\tilde{U}}}_0)\). Note that obviously \(u_{\sigma '}=h_\sigma (u_\sigma )\), and a map \(h^{-1}h_\sigma \) preserves separatrix of \(\sigma \). Also note that \(h_\sigma \) sends boundary of \({{\tilde{u}}}_\sigma \) to boundary of \({{\tilde{u}}}_{\sigma '}\), which means that points of \(\partial {{\tilde{u}}}_\sigma \) and points of \(\partial {{\tilde{u}}}_{\sigma '}\) are conjugate.

For a point \(x\in S\), we denote by \({\mathcal {O}}_x~({\mathcal {O}}'_x)\) the orbit of the flow \(f^t~(f'^t)\) passing through the point x. Let

$$\begin{aligned} V_\sigma =\bigcup \limits _{x\in \text {cl}({{\tilde{u}}}_\sigma )}\mathcal O_x,~~~ V_{\sigma '}=\bigcup \limits _{x\in \text {cl}(\tilde{u}_{\sigma '})}{\mathcal {O}}'_x. \end{aligned}$$

Let us extend \(h_\sigma \) up to a homeomorphism \(h_{V_\sigma }:V_\sigma \rightarrow V_{\sigma '}\) by the following rule (see Fig. 13). First let

$$\begin{aligned} h_{V_\sigma }|_{{{\tilde{u}}}_{\sigma }}=h_\sigma . \end{aligned}$$

Second, let for a point \(z\in (\text {int}V_\sigma {\backslash }\text {cl}({{\tilde{u}}}_\sigma ))\) be \(\{z_0\}={\mathcal {O}}_z\cap \partial {{\tilde{u}}}_\sigma \) and \(f^{t_z}(z_0)=z\), for \(t_z\in {\mathbb {R}}\); for a point \(z\in \partial {V_\sigma \backslash \partial {{\tilde{u}}}_\sigma }\) let \(t_z\) be such that \(|t_z|=\min \nolimits _{|t|}\{t\in {\mathbb {R}}\mid f^{-t}(z)\in \partial {{\tilde{u}}}_\sigma \}\) and \(z_0=f^{-t_z}(z)\); then

$$\begin{aligned} h_{V_\sigma }(z)=f'^{t_z}(h_\sigma (z_0)). \end{aligned}$$

Let us show that \(h_{V_\sigma }\) is a conjugating homeomorphism. Note that for each point of \(\partial {{\tilde{u}}}_\sigma \) the homeomorphism \(h_\sigma \) is well defined. Let \({{\hat{z}}}\in \text {cl}\tilde{u}_\sigma \). Note that \({{\hat{z}}}'=h_\sigma ({{\hat{z}}})\in \text {cl}\tilde{u}_{\sigma '}\). Let \({{\bar{z}}}\in {\mathcal {O}}_{{{\hat{z}}}}\cap \text {cl}\tilde{u}_\sigma \). Then there is a point \({{\bar{z}}}'=h_\sigma ({{\bar{z}}})\) such that \({{\bar{z}}}'\in \text {cl}{{\tilde{u}}}_{\sigma '}\) and a value \({{\bar{t}}}\) such that \(h_\sigma (f^{{{\bar{t}}}}({{\hat{z}}}))=f'^{{{\bar{t}}}}(h_\sigma ({{\hat{z}}}))\), because \(h_\sigma \) is the conjugating one.

Fig. 12
figure 12

Neighbourhood \({{\tilde{u}}}_\sigma \) of a saddle \(\sigma \); \(l_{++}\), \(l_{-+}\), \(l_{--}\), \(l_{+-}\) are trajectories of \(b^t\)

Let \({{\hat{z}}}, {{\bar{z}}}\in {\mathcal {O}}_{z_0}={\mathcal {O}}_{z}\), where z and \(z_0\) are defined as before. Let \({{\hat{t}}}\) be such that \(f^{{{\hat{t}}}}({{\hat{z}}})=z\) and let \({{\tilde{t}}}\) be such that \(f^{{{\tilde{t}}}}({{\hat{z}}})=z_0\); note that \({{\hat{t}}}={{\tilde{t}}}+t_z\), where \(t_z\) is defined as before. Then \(h_{V_\sigma }(f^{{{\hat{t}}}}({{\hat{z}}}))=h_{V_\sigma }(f^{t_z}(f^{{{\tilde{t}}}}({{\hat{z}}})))=[def]=f'^{t_z}(h_\sigma (f^{{{\tilde{t}}}}({{\hat{z}}})))=f'^{t_z}(f'^{{{\tilde{t}}}}(h_\sigma ({{\hat{z}}})))=f'^{\tilde{t}+t_z}(h_\sigma ({{\hat{z}}}))=f'^{{{\hat{t}}}}(h_\sigma ({{\hat{z}}}))=f'^{{{\hat{t}}}}(h_{V_\sigma }({{\hat{z}}}))\), because \(h_{V_\sigma }|_{\tilde{u}_{\sigma }}=h_\sigma \).

Fig. 13
figure 13

Main constructions for \(f^t\) (on the left sphere) and for \(f'^t\) (on the right sphere); \(\alpha _1,\,\alpha _2,\,\alpha '_1,\,\alpha '_2\) are sources, \(\sigma \), \(\sigma '\) are saddles, \({{\tilde{u}}}_\sigma \) is the neighbourhood of \(\sigma \), \(V_\sigma ,\,V_{\sigma '},\,T,\,T'\,\) are the domains, \(\omega \), \(\omega '\) are sinks, \({{\tilde{u}}}_\omega \) is the \(\omega \)’s neighbourhood, \(J_T,\,J_{T'},\,\tilde{J_T}\) are the cross-sections, \(a_0,\,a_1\) are the endpoints of \(J_T\), \(\tilde{a_0},\,\tilde{a_1}\) are the endpoints of \(\tilde{J_T}\)

Let \(V~(V')\) be the union of all \(V_\sigma ~(V_{\sigma '})\) and let \(h_V:V\rightarrow V'\) be a homeomorphism such that \(h_V(z)=h_{V_\sigma }(z)\) if \(z\in V_z\).

Next we want to extend the homeomorphism \(h_{V}\) up to ambient conjugating homeomorphism. Note that there exists a sink \(\omega \) such that the closure T of any connected component of the set \(S{\setminus } (V\cup \Omega _{f^t})\) belongs to the basin of \(\omega \). As \(h^{-1}h_\sigma \) preserves a separatrix of \(\sigma \) then there is the closure \(T'\subset W^s_{\omega '}\) of an unique connected component of the set \(S{\setminus }(V'\cup \Omega _{f'^t})\), such that \(h(T)\cap T'\ne \emptyset \), also \(\omega '=h(\omega )\). Let us extend \(h_V\) to T by means of conjugating homeomorphism \(h_T\).

By Proposition 2.1, flows \(f^t|_{u_\omega }\) and \(f'^t|_{u_{h(\omega )}}\) are conjugate by means of \(\psi _\omega \) and \(\psi _{\omega '}\), respectively, to the restriction of the flow \(a^t|_{U_0}\). Let \(\gamma _0=\{(x,y)\in {\mathbb {R}}^2\mid x^2+y^2=\frac{1}{2}\}\) be some closed curve without a contact, transversally crossing all trajectories of the linear flows, and let \(\gamma =\psi _\omega ^{-1}(\gamma _0)\), \(\gamma '=\psi _{\omega '}^{-1}(\gamma _0)\). So, we correctly constructed a closed curve without a contact around \(\omega \) and \(\omega '\).

Let \(J_{T}=\gamma \cap T\) and let \(a_0,a_1\) be the endpoints of the arc \(J_T\). Then there are saddle points \(\sigma _0,\sigma _1\) (possible \(\sigma _0=\sigma _1\)), such that \(a_i\in (J_T\cap V_{\sigma _i}),i=0,1\). Similarly, the arc \({{\tilde{J}}}_{T'}=\gamma '\cap T'\) is bounded by the points \({{\tilde{a}}}_0,{{\tilde{a}}}_1\) belonging to \(V_{\sigma '_0},V_{\sigma '_1}\), accordingly. Let \(t_0,t_1\in \mathbb R\), so that \(f'^{t_i}({{\tilde{a}}}_i)=h_V(a_i),i=0,1\) and \(\rho :{{\tilde{J}}}_{T'}\rightarrow [0,1]\) be a homeomorphism, such that \(\rho ({{\tilde{a}}}_i)=i,i=0,1\). Let

$$\begin{aligned} J_{T'}=\{f'^{t_z}({{\tilde{z}}})\mid {{\tilde{z}}}\in {{\tilde{J}}}_{T'}, t_z=t_0+(t_1-t_0)\rho ({{\tilde{z}}})\}. \end{aligned}$$

Define an arbitrary homeomorphism \(h_J:J_T\rightarrow J_{T'}\), so that \(h_J(a_i)=h_V(a_i), i=0,1\). Then every point z in T is uniquely defined by the point \(z_0={\mathcal {O}}_z\cap J_T\) and the value \(t_z\in {\mathbb {R}}\), such that \(f^{t_z}(z_0)=z\). Let us define a homeomorphism \(h_T:T\rightarrow T'\) by the formula

$$\begin{aligned} h_T(f^{t_z}(z_0))=f'^{t_z}(h_J(z_0)). \end{aligned}$$

Let us define the conjugating homeomorphism \(h_c:S\rightarrow S\), so that \(h_c|_V=h_V\), \(h_c|_T=h_T\), and \(h_c|_{\Omega _{f^t}}=h|_{\Omega _{f^t}}\). Thus, the conjugating homeomorphism is constructed and Theorem is proved. \(\square \)