human
Number of sink nodes in a graph | Return the number of Sink NOdes ..
Array for marking the non - sink node ..
Marking the non - sink node ..
Counting the sink nodes ..
Driver Code"
How can the above be solved in Python?
 ... Give me a code to number of sink nodes in a graph and the other steps required?
assistant
#Here is code to number of sink nodes in a graph and the other steps required.
 def countSink ( n , m , edgeFrom , edgeTo ) :
	mark = [ 0 ] * ( n + 1 )
	for i in range ( m ) :
		mark [ edgeFrom [ i ] ] = 1
	count = 0
	for i in range ( 1 , n + 1 ) :
		if ( not mark [ i ] ) :
			count += 1
	return count
if __name__ == ' _ _ main _ _ ' :
	n = 4
	m = 2
	edgeFrom = [ 2 , 4 ]
	edgeTo = [ 3 , 3 ]
	print ( countSink ( n , m , edgeFrom , edgeTo ) )