-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgraph_tools.py
More file actions
38 lines (31 loc) · 836 Bytes
/
graph_tools.py
File metadata and controls
38 lines (31 loc) · 836 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
from gerrychain import (GeographicPartition, Partition, Graph, MarkovChain,
proposals, updaters, constraints, accept, Election)
from functools import partial
import pandas
import json
import random
from networkx.readwrite import json_graph
import json
import numpy as np
import requests
import geopandas
import maup
import os
import random
import json
import geopandas as gpd
import functools
import datetime
import matplotlib
import matplotlib.pyplot as plt
#link = input("Put graph link: ")
def graph_from_url(link):
r = requests.get(url=link)
data = json.loads(r.content)
g = json_graph.adjacency_graph(data)
graph = Graph(g)
graph.issue_warnings()
pos = {}
for node in graph.nodes():
pos[node] = [graph.node[node]['C_X'], graph.node[node]['C_Y'] ]
return graph