I have two directed acyclic graph and I need to compute the longest common subsequence (LCS) of these graphs. For two strings/subsequences I use LCS algorithm using dynamic programming (DP) but how can I modify this algorithm to the graphs?
Any idea?
whole task:
Let G is a directed acyclic graph in which each vertex is labeled with a symbol from a finite alphabet. Different vertices may be marked with the same symbol. Each directed path in G has trace formed by concatenating the symbol of vertices from the path. Sequence of graph G is a subsequence of trace of some directed path in G.
Design an efficient algorithm that computes the longest common sequence of two given directed acyclic graph.
Example: strings DYNAMIC, PROGRAM and DEPTHFIRST are sequences of oriented acyclic graph of the picture. String PROGRAM is its trace.