# fn() longestIncreasingSubsequence
Computes the longest increasing subsequence.

Defined in | <seqan/graph_algorithms.h>
Signature | `void longestIncreasingSubsequence(str, pos);`

## Parameters

`str` | An arbitrary ContainerConcept object.
`pos` | A String with the positions that belong to the longest increasing subsequence.

## Detailed Description

### Remarks

The last position in `pos` indicates the first element in the longets increasing subsequence.

### Example

    #include <iostream>
    #include <seqan/graph_algorithms.h>

    using namespace seqan;

    int main()
    {
        // Create a sequence of integers.
        String<unsigned> seq;
        appendValue(seq, 5);
        appendValue(seq, 3);
        appendValue(seq, 4);
        appendValue(seq, 9);
        appendValue(seq, 6);
        appendValue(seq, 2);
        appendValue(seq, 1);
        appendValue(seq, 8);
        appendValue(seq, 7);
        appendValue(seq, 10);

        // Compute the longest increasing subsequence.
        typedef Position<String<unsigned> >::Type TPosition;
        String<TPosition> pos;
        longestIncreasingSubsequence(seq, pos);

        // Print the result to stdout.
        for (unsigned i = 0; i < length(seq); ++i)
            std::cout << seq[i] << ',';

        std::cout << "\n"
                  << "Lis: \n";
        for (int i = length(pos) - 1; i >= 0; --i)
            std::cout << seq[pos[i]] <<  ',';
        std::cout << "\n";

        return 0;
    }

Demo: demos/dox/graph_algorithms/longest_increasing_subsequence.cpp

    5,3,4,9,6,2,1,8,7,10,
    Lis:
    3,4,6,7,10,

## Data Races

Thread safety unknown!

## See Also

- heaviestIncreasingSubsequence
- longestCommonSubsequence

#### Dox Sources

    /*!
     * @fn longestIncreasingSubsequence
     *
     * @headerfile <seqan/graph_algorithms.h>
     *
     * @brief Computes the longest increasing subsequence.
     *
     * @signature void longestIncreasingSubsequence(str, pos);
     *
     * @param[in] str An arbitrary @link ContainerConcept @endlink object.
     * @param[out] pos A String with the positions that belong to the longest
     *                 increasing subsequence.
     *
     * @section Remarks
     *
     * The last position in <tt>pos</tt> indicates the first element in the longets
     * increasing subsequence.
     *
     * @section Example
     *
     * @include demos/dox/graph_algorithms/longest_increasing_subsequence.cpp
     *
     * @code{.console}
     * 5,3,4,9,6,2,1,8,7,10,
     * Lis:
     * 3,4,6,7,10,
     * @endcode
     *
     *
     * @see heaviestIncreasingSubsequence
     * @see longestCommonSubsequence
     */