Algorithms to find the number of Hamiltonian paths in a graph

后端 未结 5 1340
轮回少年
轮回少年 2020-12-19 10:05

I\'m trying to solve a slightly modified version of the Hamiltonian Path problem. It is modified in that the start and end points are given to us and instead of determining

5条回答
  •  感情败类
    2020-12-19 10:17

    You could still use a bidirectional search, just add a constraint to the search so that previously seen nodes will not be candidates for searching.

    Another approach you could take which would lend itself to a paralellizable solution is to break the search into smaller searches.

    For example, try to solve your original problem by solving:

    For each node, n, which is not a start or end node, find all paths from the start to n (set1) and from n to the end (set2).

    After you find set1 and set2, you can discard all elements of their cross product which have a common node other than node n.

提交回复
热议问题