human
Give me a code to check whether given degrees of vertices represent a Graph or Tree and the other steps required given the following:
Check whether given degrees of vertices represent a Graph or Tree | Function returns true for tree false for graph.
Find sum of all degrees.
It is tree if sum is equal to 2 ( n - 1 ).
main"
Solution in Python:
assistant
#Here is code to check whether given degrees of vertices represent a Graph or Tree and the other steps required.
 def check ( degree , n ) :
	deg_sum = sum ( degree )
	if ( 2 * ( n - 1 ) == deg_sum ) :
		return True
	else :
		return False
n = 5
degree = [ 2 , 3 , 1 , 1 , 1 ] ;
if ( check ( degree , n ) ) :
	print " Tree "
else :
	print " Graph "