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
from collections import defaultdict | |
import random | |
import networkx | |
import pandas | |
def propose_any_node_flip(partition): | |
node = random.choice(tuple(partition.assignment.keys())) | |
part = random.choice(tuple(partition.parts.keys())) | |
return partition.flip({ node: part }) | |
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
import numpy as np | |
import geopandas | |
def quadratic_distance(x, y): | |
return np.sum(np.square(np.array(x) - np.array(y))) | |
def distance_matrix(points): | |
N = len(points) |