Created
June 9, 2017 14:26
-
-
Save mhornbacher/7c32b644ef188717896d28d1d302ef7b to your computer and use it in GitHub Desktop.
Takes a list of X, and Y coordinates and calculates the edge cost between all of them. X^2 runtime
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def build_edges(x, y): | |
edges = [] | |
for i in range(len(x)): | |
for k in range(len(x)): | |
dist = math.sqrt(((x[i] - x[k]) ** 2) + ((y[i] - y[k]) **2)) | |
edges.append([i, k, dist]) | |
return edges |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment