I
I
Ilya Reznik2019-12-11 15:18:57
Python
Ilya Reznik, 2019-12-11 15:18:57

Is it possible to visit all vertices of a connected undirected graph once and return to the initial vertex?

What algorithm can be used to traverse all the vertices of the graph once, returning to the starting vertex.
The graph is connected, undirected.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
antonksa, 2019-12-11
@antonksa

Is it possible to bypass all the vertices of the graph and return to the initial one?

Can.

W
Wataru, 2019-12-12
@wataru

From the description, you want a Hamiltonian path .
This problem is NP-complete - therefore, no simple and fast algorithm is known to mankind. You can do a full search with cutoffs and heuristics. Some methods of simulating annealing or genetic algorithms can work faster, but this is not accurate and you need to poke around for a long and painful time to make it work.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question