def colorNode(node): subarr = []; colors = [] ptr1 = Nodes.index(node) for c in range(Num_Nodes): colors.append(c+1) for n1 in Nbr[ptr1]: ptr2 = Nodes.index(n1) if(colorArray[ptr2] != 0): subarr.append(colorArray[ptr2]) cf.rmvNbr1(colors,subarr) colors.reverse() colorArray[ptr1] = colors.pop()
def TwoHopNbr(arr1,arr2): arr3 = [] for m in arr1: subarr = [] ptr1 = arr1.index(m) for n1 in arr2[ptr1]: ptr2 = arr1.index(n1) for n2 in arr2[ptr2]: if(m != n2): subarr.append(n2) cf.rmv_duplicate(subarr) cf.rmvNbr1(subarr,arr2[ptr1]) arr3.append(subarr) return arr3
Nbr_t.append(Nbr1_t[m]+Nbr2_t[m]) CDS_t = np.zeros(num_Nodes) for n1 in Nodes_t: CDS_t[n1] = 1 #Coloring of the Node... color = []; subarr = [] for c in range(Num_Nodes_t): color.append(c+1) ptr1 = Nodes_t.index(node) for n in Nbr_t[ptr1]: ptr2 = Nodes_t.index(n) if(colorArray[ptr2] != 0): subarr.append(colorArray[ptr2]) cf.rmvNbr1(color,subarr) color.reverse() Color_Array[Num_Nodes] = color.pop() #Calculating the maximum frame size maxColor_t = Color_Array.max() power = math.ceil(math.log(maxColor_t)/math.log(2)) maxFrame_t = int(2**power) #Matrix for slot Tx of each node TxSlot_t = np.zeros([Num_Nodes_t,maxFrame_t]) #Matrix for slot Tx of nodes Tx_t = np.zeros([Num_Nodes_t,maxFrame_t]) #Initializing the TxSlot Matrix