algorithmgraphdynamic-programmingbreadth-first-searchviterbi

Can we apply Viterbi algorithm if there are cycles in a graph?


I am trying to solve a question which can be solved both by BFS and viterbi algorithm. But BFS might fail if there are cycles in the graph. So my question is viterbi algorithm cycle safe?


Solution

  • As long as you make sure your graph follows rules of Hidden Markov Model (for example, sum of all outgoing edges from every node sums to 1), then yes - Viterbi Algorithm can handle cyclic graphs.

    It is hard to say if it's indeed the right choice or if you can use modified BFS without more context on the question.