Advertisement
Skylighty

for-candy

Jan 20th, 2022
1,056
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.65 KB | None | 0 0
  1. import math
  2. import numpy as np
  3.  
  4.  
  5. # Wierzchołek 1 jest połączony ze wszystkimi pozostałymi, inne wierzchołki nie są połączone
  6. w1 = [(3,2), (6,6), (7,2), (5,-2), (1,-2), (-3,2), (1,4)]
  7. w2 = [(0,0), (2,2), (4,10), (-5,12), (-10,0), (-5,18), (-1,20)]
  8.  
  9. distances = []
  10. xs = np.zeros((len(w1), len(w1)))
  11. ys = np.zeros((len(w1), len(w1)))
  12. A = np.zeros((len(w1),len(w1)))
  13.  
  14.  
  15. for i in range(np.shape(xs)[0]):
  16.     for j in range(np.shape(xs)[1]):
  17.         xs[i][j] = abs( (w1[i][0]) - (w1[j][0]) )
  18.         ys[i][j] = abs( (w1[i][1]) - (w1[j][1]) )
  19.         A[i][j] = np.round( np.sqrt(math.pow(xs[i][j], 2) + math.pow(ys[i][j], 2)), 3)
  20.  
  21.  
  22. print(A)
  23.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement