human
Longest path in a directed Acyclic graph | Dynamic Programming | Function to traverse the DAG and apply Dynamic Programming to find the longest path.
Mark as visited.
Traverse for all its children.
If not visited.
Store the max of the paths.
Function to add an edge.
Function that returns the longest path.
Dp array.
Visited array to know if the node has been visited previously or not.
Call DFS for every unvisited vertex.
Traverse and find the maximum of all dp [ i ].
Driver Code.
Example - 1"
Solution in Python:

=====
What is a code to longest path in a directed Acyclic graph and the other steps required?
assistant
#Here is code to longest path in a directed Acyclic graph and the other steps required.
 def dfs ( node , adj , dp , vis ) :
	vis [ node ] = True
	for i in range ( 0 , len ( adj [ node ] ) ) :
		if not vis [ adj [ node ] [ i ] ] :
			dfs ( adj [ node ] [ i ] , adj , dp , vis )
		dp [ node ] = max ( dp [ node ] , 1 + dp [ adj [ node ] [ i ] ] )
def addEdge ( adj , u , v ) :
	adj [ u ] . append ( v )
def findLongestPath ( adj , n ) :
	dp = [ 0 ] * ( n + 1 )
	vis = [ False ] * ( n + 1 )
	for i in range ( 1 , n + 1 ) :
		if not vis [ i ] :
			dfs ( i , adj , dp , vis )
	ans = 0
	for i in range ( 1 , n + 1 ) :
		ans = max ( ans , dp [ i ] )
	return ans
if __name__ == " _ _ main _ _ " :
	n = 5
	adj = [ [ ] for i in range ( n + 1 ) ]
	addEdge ( adj , 1 , 2 )
	addEdge ( adj , 1 , 3 )
	addEdge ( adj , 3 , 2 )
	addEdge ( adj , 2 , 4 )
	addEdge ( adj , 3 , 4 )
	print ( findLongestPath ( adj , n ) )