iriad11

Nahid vai er problem

Apr 8th, 2021
384
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import numpy as np
  2. from collections import defaultdict
  3.  
  4. matrix = np.array([[10.0,   0.53,   0.95,   0.15,   0.21,   0.52],
  5.                    [0.53, 10.0, 0.13,   0.18,   0.02,   0.15],
  6.                    [0.95,   0.53,   10.0,   0.3,    0.29,   0.21],
  7.                    [0.15,   0.18,   0.3,    10.0,   0.3,    0.31],
  8.                    [0.21,   0.02,   0.29,   0.3,    10.0,   0.02],
  9.                    [0.52,   0.15,   0.21,   0.31,   0.02,   10.0]])
  10.  
  11. x,y = matrix.shape
  12. adjacency_id_value = defaultdict(list)
  13. adjacency_value_id = {}
  14. taken_index = []
  15. for row_index in range(x):
  16.   if row_index in taken_index:
  17.     print('found',row_index)
  18.     continue
  19.   row = matrix[row_index]
  20.   for column_index in range(y):
  21.     if column_index==row_index:
  22.       continue
  23.     lowest_column_value = np.amin(matrix[:,column_index])
  24.     if row[column_index] == lowest_column_value:
  25.       if column_index in taken_index:
  26.         adjacency_id_value[adjacency_value_id[column_index]].append(row_index)
  27.         taken_index.append(row_index)
  28.         continue
  29.       else:
  30.         adjacency_id_value[row_index].append(column_index)
  31.         adjacency_value_id[column_index] = row_index
  32.         taken_index.append(column_index)
  33.  
  34. print(adjacency_id_value)
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×