Commit 451d0201 authored by Jonathan Mattingly's avatar Jonathan Mattingly
Browse files

Merge branch 'main' of git.math.duke.edu:jonm/atlas-examples

parents 2229669e 72502661
Loading
Loading
Loading
Loading

read_graph.py

0 → 100644
+22 −0
Original line number Diff line number Diff line
import Atlas
import helper_functions as hf
import json
import matplotlib.pyplot as plt
import pandas as pd

pctDataF = open("pct21_20cen_wMCD.json")
pctData = json.load(pctDataF)

import networkx as nx
g = nx.Graph()
# g.add_edge(1, 2)
for (ii, adj_data) in enumerate(pctData["adjacency"]):
    for adj in adj_data:
        jj = adj["id"]
        g.add_edge(ii, jj)
inc_node_data = ['pop2020cen', 'G08_PR_D', 'G08_PR_R']
for (ii, _)  in enumerate(pctData['nodes']):
    for d in inc_node_data:
        g.nodes[ii][d] = pctData["nodes"][ii][d]

 print(g.nodes[0])
 No newline at end of file