How do I find if an array contains pre-specified pairs?

I am storing a set of paths in a graph/network in the form of 2D array. Each row represents a separate path and each element in the row represents nodes that have to be visited in order.

I want to find out if certain pairs of nodes lie on that path.


path1 = 4 5 6 1
path2 = 4 6 8 5 1

I want to search if the pair (6,5) lies in a path. path1 does not satisfy the criteria since it has 5 before 6 but path2 qualifies because it has 5 after 6.

Source: c#

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.