human
Construct a graph which does not contain any pair of adjacent nodes with same value | Function that prints the edges of the generated graph.
First print connections stored in store [ ].
Check if there is more than one occurrence of 1 st unique element.
Print all other occurrence of 1 st unique element with second unique element.
Function to construct the graph such that the every adjacent nodes have different value.
Stores pair of edges formed.
Stores first unique occurrence.
Check for the second unique occurrence.
Store indices of 2 nd unique occurrence.
To check if arr has only 1 unique element or not.
Store the connections of all unique elements with Node 1.
If value at node ( i + 1 ) is same as value at Node 1 then store its indices.
If count is zero then it 's not  possible to construct the graph.
If more than 1 unique element is present.
Print the edges.
Driver Code.
Given array having node values.
Function Call"
How can the above be solved in Python?
assistant
#Here is code to construct a graph which does not contain any pair of adjacent nodes with same value and the other steps required.
 def printConnections ( store , ind , ind1 ) :
	for pr in store :
		print ( pr [ 0 ] , pr [ 1 ] )
	if ( len ( ind ) != 0 ) :
		for x in ind :
			print ( ind1 , x + 1 )
def constructGraph ( arr , N ) :
	ind = [ ]
	store = [ ]
	x = arr [ 0 ]
	count , ind1 = 0 , 0
	for i in range ( 1 , N ) :
		if ( arr [ i ] != x ) :
			ind1 = i + 1
			count += 1
			store . append ( [ 1 , i + 1 ] )
		else :
			ind . append ( i )
	if count == 0 :
		print ( " Not ▁ Possible " )
	else :
		print ( " Possible " )
		printConnections ( store , ind , ind1 )
if __name__ == ' _ _ main _ _ ' :
	N = 5
	arr = [ ' a ' , ' b ' , ' a ' , ' b ' , ' c ' ]
	constructGraph ( arr , N )