#NEWLINE# def _compare_graphlets( am1 , am2 ) : #NEWLINE# #INDENT# '\n    Compare two graphlets.\n    ' #NEWLINE# adj_mat1 = am1 #NEWLINE# adj_mat2 = am2 #NEWLINE# np . fill_diagonal ( adj_mat1 , 1 ) #NEWLINE# np . fill_diagonal ( adj_mat2 , 1 ) #NEWLINE# k = np . array ( adj_mat1 ) . shape [ 0 ] #NEWLINE# if ( k == 3 ) : #NEWLINE# #INDENT# return ( np . array ( adj_mat1 ) . sum ( ) == np . array ( adj_mat2 ) . sum ( ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( not ( np . array ( adj_mat1 ) . sum ( ) == np . array ( adj_mat2 ) . sum ( ) ) ) : #NEWLINE# #INDENT# return False #NEWLINE# #UNINDENT# if ( np . array ( adj_mat1 ) . sum ( ) in ( 4 , 6 , 14 , 16 ) ) : #NEWLINE# #INDENT# return True #NEWLINE# #UNINDENT# if ( np . array ( adj_mat1 ) . sum ( ) == 8 ) : #NEWLINE# #INDENT# return ( 3.0 in [ adj_mat . sum ( ) for adj_mat in adj_mat1 ] == 3.0 in [ adj_mat . sum ( ) for adj_mat in adj_mat2 ] ) #NEWLINE# #UNINDENT# if ( np . array ( adj_mat1 ) . sum ( ) == 10 ) : #NEWLINE# #INDENT# sums1 = [ adj_mat . sum ( ) for adj_mat in adj_mat1 ] #NEWLINE# sums2 = [ adj_mat . sum ( ) for adj_mat in adj_mat2 ] #NEWLINE# if ( ( ( _is_3star ( adj_mat1 ) + _is_3star ( adj_mat2 ) ) % 2 ) == 1 ) : #NEWLINE# #INDENT# return False #NEWLINE# #UNINDENT# if ( _is_3star ( adj_mat1 ) and _is_3star ( adj_mat2 ) ) : #NEWLINE# #INDENT# return True #NEWLINE# #UNINDENT# return ( ( 1 in sums1 ) == ( 1 in sums2 ) ) #NEWLINE# #UNINDENT# if ( np . array ( adj_mat1 ) . sum ( ) == 12 ) : #NEWLINE# #INDENT# return ( _4_graphlet_contains_3star ( adj_mat1 ) == _4_graphlet_contains_3star ( adj_mat2 ) ) #NEWLINE# #UNINDENT# #UNINDENT# return False