Answer the question
In order to leave comments, you need to log in
What is the best way to traverse all the vertices of a graph?
It is necessary to go around all the vertices of an undirected connected graph, moving pointwise along the edges. The graph is arbitrary (not Euler and not Hamilton, except for connectivity, nothing is given). The transition along the edge is one step. How to do it in the minimum number of steps? Returning to the original vertex, as in the traveling salesman problem, is not necessarily the main thing to visit each vertex at least once.
Answer the question
In order to leave comments, you need to log in
Obviously, by traversing the graph .
Which of the algorithms is better to use and what modifications can be made depends on the specific features of the graph, that is, for an arbitrary one, it is not known in advance which variation will be the most optimal.
If possible, then you need to collect statistics and look at the possible features of the processed graphs. So, for example, for "stars" it will be optimal to bypass the center with BFS, after which the processing of rays using DFS.
If we talk about coins: this is finding the shortest path on which all the coins lie. I would use Dijkstra's algorithm .
For the number of vertices of the order of 15: (more than 15 vertices will work already relatively longer)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question