Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import math
- import numpy as np
- # Wierzchołek 1 jest połączony ze wszystkimi pozostałymi, inne wierzchołki nie są połączone
- w1 = [(3,2), (6,6), (7,2), (5,-2), (1,-2), (-3,2), (1,4)]
- w2 = [(0,0), (2,2), (4,10), (-5,12), (-10,0), (-5,18), (-1,20)]
- distances = []
- xs = np.zeros((len(w1), len(w1)))
- ys = np.zeros((len(w1), len(w1)))
- A = np.zeros((len(w1),len(w1)))
- for i in range(np.shape(xs)[0]):
- for j in range(np.shape(xs)[1]):
- xs[i][j] = abs( (w1[i][0]) - (w1[j][0]) )
- ys[i][j] = abs( (w1[i][1]) - (w1[j][1]) )
- A[i][j] = np.round( np.sqrt(math.pow(xs[i][j], 2) + math.pow(ys[i][j], 2)), 3)
- print(A)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement