I need to solve the longest common sequence problem between two sequences when they are slightly out of order and the nodes that are out of order are close to each other. In other words, let's say one of the sequences are s1 s2 s3 ... s_n. It may come in with s1 and s2 swapped, or s1 and s3 swapped, or s_{n-1} and s_n swapped, but it is unlikely that s1 and s_n will swap order.
This arises when an observed sequence is a mixture of many sequences generated concurrently. For example, if I have two concurrent sources that generate (a1, a2, ..., a100) and (b1, b2, ..., b100). Many of the nodes are generated at almost exactly the same time, and so the combined sequence that we use for matching can end up becoming (a1, a2, b1, b2, ... ),or (a1, b1, a2, b2); because the nodes a1, a2, a3, b1, b2, b3 might be generated in the same nanosecond and any order is possible. But it is not possible that a1 and b100 swap orders because they are generated seconds apart.
Let's say there are two such sequences, where they are globally in order, but locally there can be small rearrangements. How do I apply the longest common sequence algorithm in this case?