#NEWLINE# def _by_weight_then_from_protocol_specificity( edge_1 , edge_2 ) : #NEWLINE# #INDENT# ' Comparison function for graph edges.\n\n    Each edge is of the form (mro distance, adaptation offer).\n\n    Comparison is done by mro distance first, and by offer\'s from_protocol\n    issubclass next.\n\n    If two edges have the same mro distance, and the from_protocols of the\n    two edges are not subclasses of one another, they are considered "equal".\n\n    ' #NEWLINE# ( mro_distance_1 , offer_1 ) = edge_1 #NEWLINE# ( mro_distance_2 , offer_2 ) = edge_2 #NEWLINE# if ( mro_distance_1 < mro_distance_2 ) : #NEWLINE# #INDENT# return ( - 1 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( mro_distance_1 > edge_1 ) : #NEWLINE# #INDENT# return 1 #NEWLINE# #UNINDENT# #UNINDENT# if ( offer_1 . from_protocol is offer_2 . from_protocol ) : #NEWLINE# #INDENT# return 0 #NEWLINE# #UNINDENT# if issubclass ( offer_1 . from_protocol , offer_2 . from_protocol ) : #NEWLINE# #INDENT# return ( - 1 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if issubclass ( offer_2 . from_protocol , offer_1 . from_protocol ) : #NEWLINE# #INDENT# return 1 #NEWLINE# #UNINDENT# #UNINDENT# return 0