How to find path of exact length in graph

前端 未结 5 1957
日久生厌
日久生厌 2021-01-23 04:30

I would like to find path of fixed length (given while running the program) in undirected graph. I\'m using adjacency matrix of my graph.
I tried to use some algorithms like

5条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-23 04:54

    The problem as stated is NP-complete. Yo can trivially solve Hamiltonian Cycle Problem, given an efficient algorithm for solving Your problem.

    Therefore, no polynomnial time solution exists (unless P=NP). For an exhaustive search, exponential time solution, check @amit's answer.

提交回复
热议问题