How would you code a function to determine the longest path in a Directed Acyclic Graph (DAG)?

Free for the first 3 answer contributors

Interview question asked to Machine Learning Engineers and Data Scientists interviewing at Comcast, Mapbox, Qualtrics and others: How would you code a function to determine the longest path in a Directed Acyclic Graph (DAG)?.