In a graph, a chain is a sequence of vertices in which every pair of neighbouring vertices is joined by an edge. The same vertex may appear more than once, and a single vertex is already a chain.
You are given a directed graph with no cycles. Find the smallest number of chains needed to cover every vertex.
Two different chains may not share a vertex. A sequence v1,v2,…,vk is a chain only if there is an edge from vi to vi+1 for every i, so edges cannot be traversed against their direction.