#!/usr/bin/env python # coding: utf-8 # In[1]: import os, sys from glob import glob import networkx as nx import numpy as np import pickle import matplotlib.pyplot as plt sys.path.append('../'); import Holes as ho # In[2]: import geojson as gj # In[3]: get_ipython().run_line_magic('matplotlib', 'inline') # In[4]: max_dimensions=1; # In[5]: import scipy.io ld = os.listdir('../stores/phom/country_high_act_low_entropy_matrices/'); countries_to_cells={} for country in ld: if country == '.gitignore': continue countries_to_cells[country[:-4]]=pickle.load(open('../stores/phom/country_high_act_low_entropy_matrices/'+country)) # In[6]: grid=gj.load(open('../data/poi/milano-grid.geojson')) # In[7]: import pandas as pd cell_position = {} for i,cell in enumerate(grid['features']): cell_position[cell["properties"]["cellId"]] = cell["geometry"]["coordinates"][0][0] # In[8]: import networkx as nx country_graphs={} for country in countries_to_cells: coords = np.nonzero(countries_to_cells[country]); country_graphs[country]=nx.Graph(); coords = zip(coords[0],coords[1]); for i, cell in enumerate(coords): for j, other_cell in enumerate(coords): if i