How to find path of exact length in graph

前端 未结 5 1961
日久生厌
日久生厌 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:50

    Suppose you can find a path of length d in a graph then you can run this algorithm |V| times and find the longest path which is NP-complete. So you can try the following approach -

    1) approximation algorithm 2) brute force approach (more suitable for programming). Use a GPU to accelerate your code.

    Also it may be of interest to you that -

    there exists a linear time algorithm for DAGs.

提交回复
热议问题