Skip to content

Instantly share code, notes, and snippets.

@ConorAspell
Last active November 27, 2017 23:11
Show Gist options
  • Save ConorAspell/a41f0551b93e25e24622675124f9444d to your computer and use it in GitHub Desktop.
Save ConorAspell/a41f0551b93e25e24622675124f9444d to your computer and use it in GitHub Desktop.
"What Happened" by Hillary Clinton
license: mit
{
"info": {
"nodes": [
{"id": "Al Gore", "group": 1, "question": "Male", "Centrality": { "Betweeness": 0.0, "Degree": 0.09090909090909091, "Eigenvector": 0.01037270895592081, "Closeness": 0.01037270895592081, "Harmonic": 0.5, "Communicability": 11.666666666666666 } },
{"id": "Barack", "group": 1, "question": "Male", "Centrality": { "Betweeness": 0.09502164502164503, "Degree": 0.4090909090909091, "Eigenvector": 0.2753182178094942, "Closeness": 0.2753182178094942, "Harmonic": 0.6285714285714286, "Communicability": 15.5 } },
{"id": "Bernie", "group": 0, "question": "Male", "Centrality": { "Betweeness": 0.04112554112554113, "Degree": 0.18181818181818182, "Eigenvector": 0.21557611166667498, "Closeness": 0.21557611166667498, "Harmonic": 0.5365853658536586, "Communicability": 12.833333333333334 } },
{"id": "Bill", "group": 0, "question": "Male", "Centrality": { "Betweeness": 0.005411255411255411, "Degree": 0.18181818181818182, "Eigenvector": 0.4621905252304448, "Closeness": 0.4621905252304448, "Harmonic": 0.5, "Communicability": 12.333333333333334 } },
{"id": "Chelsea", "group": 0, "question": "Female", "Centrality": { "Betweeness": 0.0, "Degree": 0.09090909090909091, "Eigenvector": 0.20415915003451957, "Closeness": 0.20415915003451957, "Harmonic": 0.46808510638297873, "Communicability": 11.166666666666666 } },
{"id": "Donald", "group": 2, "question": "Male", "Centrality": { "Betweeness": 0.18116883116883112, "Degree": 0.4090909090909091, "Eigenvector": 0.34194111761795426, "Closeness": 0.34194111761795426, "Harmonic": 0.6285714285714286, "Communicability": 15.5 } },
{"id": "Donna", "group": 0, "question": "Female", "Centrality": { "Betweeness": 0.0, "Degree": 0.045454545454545456, "Eigenvector": 0.009392126668994716, "Closeness": 0.009392126668994716, "Harmonic": 0.4583333333333333, "Communicability": 10.666666666666666 } },
{"id": "Elizabeth", "group": 0, "question": "Female", "Centrality": { "Betweeness": 0.0, "Degree": 0.045454545454545456, "Eigenvector": 0.018784253337989432, "Closeness": 0.018784253337989432, "Harmonic": 0.4583333333333333, "Communicability": 10.666666666666666 } },
{"id": "Gary", "group": 0, "question": "Male", "Centrality": { "Betweeness": 0.0, "Degree": 0.045454545454545456, "Eigenvector": 0.018784253337989432, "Closeness": 0.018784253337989432, "Harmonic": 0.4583333333333333, "Communicability": 10.666666666666666 } },
{"id": "George", "group": 1, "question": "Male", "Centrality": { "Betweeness": 0.004617604617604618, "Degree": 0.18181818181818182, "Eigenvector": 0.07093741079402684, "Closeness": 0.07093741079402684, "Harmonic": 0.5365853658536586, "Communicability": 12.833333333333332 } },
{"id": "Hillary", "group": 0, "question": "Female", "Centrality": { "Betweeness": 0.6274891774891774, "Degree": 0.7727272727272727, "Eigenvector": 0.6829410873820295, "Closeness": 0.6829410873820295, "Harmonic": 0.8148148148148148, "Communicability": 19.5 } },
{"id": "Huma", "group": 0, "question": "Female", "Centrality": { "Betweeness": 0.0, "Degree": 0.045454545454545456, "Eigenvector": 0.037568506675978865, "Closeness": 0.037568506675978865, "Harmonic": 0.4583333333333333, "Communicability": 10.666666666666666 } },
{"id": "James Comey", "group": 2, "question": "Male", "Centrality": { "Betweeness": 0.0, "Degree": 0.09090909090909091, "Eigenvector": 0.05168863705635353, "Closeness": 0.05168863705635353, "Harmonic": 0.5, "Communicability": 11.666666666666666 } },
{"id": "Jill", "group": 2, "question": "Female", "Centrality": { "Betweeness": 0.0, "Degree": 0.13636363636363635, "Eigenvector": 0.015215937504256255, "Closeness": 0.015215937504256255, "Harmonic": 0.44, "Communicability": 11.0 } },
{"id": "Joe", "group": 1, "question": "Male", "Centrality": { "Betweeness": 0.0025252525252525255, "Degree": 0.09090909090909091, "Eigenvector": 0.010855114812667852, "Closeness": 0.010855114812667852, "Harmonic": 0.4, "Communicability": 9.833333333333334 } },
{"id": "John Podesta", "group": 1, "question": "Male", "Centrality": { "Betweeness": 0.14617604617604618, "Degree": 0.3181818181818182, "Eigenvector": 0.07130343363390072, "Closeness": 0.07130343363390072, "Harmonic": 0.5789473684210527, "Communicability": 14.333333333333332 } },
{"id": "Julian", "group": 2, "question": "Male", "Centrality": { "Betweeness": 0.0, "Degree": 0.13636363636363635, "Eigenvector": 0.025511496060178503, "Closeness": 0.025511496060178503, "Harmonic": 0.5116279069767442, "Communicability": 12.166666666666666 } },
{"id": "Michelle", "group": 1, "question": "Female", "Centrality": { "Betweeness": 0.0, "Degree": 0.09090909090909091, "Eigenvector": 0.03014298345456936, "Closeness": 0.03014298345456936, "Harmonic": 0.4782608695652174, "Communicability": 11.333333333333334 } },
{"id": "Mitch", "group": 2, "question": "Male", "Centrality": { "Betweeness": 0.0, "Degree": 0.045454545454545456, "Eigenvector": 0.009404902819747754, "Closeness": 0.009404902819747754, "Harmonic": 0.39285714285714285, "Communicability": 9.333333333333334 } },
{"id": "Nancy", "group": 0, "question": "Female", "Centrality": { "Betweeness": 0.0, "Degree": 0.045454545454545456, "Eigenvector": 0.009392126668994716, "Closeness": 0.009392126668994716, "Harmonic": 0.4583333333333333, "Communicability": 10.666666666666666 } },
{"id": "Paul Ryan", "group": 2, "question": "Male", "Centrality": { "Betweeness": 0.020562770562770564, "Degree": 0.13636363636363635, "Eigenvector": 0.015104278547241253, "Closeness": 0.015104278547241253, "Harmonic": 0.4489795918367347, "Communicability": 11.166666666666666 } },
{"id": "Ruth Bader", "group": 1, "question": "Male", "Centrality": { "Betweeness": 0.0, "Degree": 0.09090909090909091, "Eigenvector": 0.0011883034217490384, "Closeness": 0.0011883034217490384, "Harmonic": 0.39285714285714285, "Communicability": 9.666666666666666 } },
{"id": "Vladimir", "group": 2, "question": "Male", "Centrality": { "Betweeness": 0.014430014430014427, "Degree": 0.2272727272727273, "Eigenvector": 0.147233172717295, "Closeness": 0.147233172717295, "Harmonic": 0.5365853658536586, "Communicability": 13.166666666666666 } }
],
"links":[
{"source": "Barack", "target": "Bill", "value": "2", "group": 1},
{"source": "Barack", "target": "Donald", "value": "4", "group": 1},
{"source": "Barack", "target": "George", "value": "3", "group": 1},
{"source": "Barack", "target": "Jill", "value": "1", "group": 1},
{"source": "Barack", "target": "Michelle", "value": "3", "group": 1},
{"source": "Barack", "target": "Vladimir", "value": "4", "group": 1},
{"source": "Bernie", "target": "Barack", "value": "1", "group": 0},
{"source": "Bernie", "target": "Donald", "value": "3", "group": 0},
{"source": "Bernie", "target": "Joe", "value": "3", "group": 0},
{"source": "Bill", "target": "Chelsea", "value": "7", "group": 0},
{"source": "Donald", "target": "James Comey", "value": "5", "group": 2},
{"source": "Donald", "target": "Jill", "value": "2", "group": 2},
{"source": "Donald", "target": "Julian", "value": "1", "group": 2},
{"source": "Donald", "target": "Mitch", "value": "2", "group": 2},
{"source": "Donald", "target": "Paul Ryan", "value": "3", "group": 2},
{"source": "Donald", "target": "Vladimir", "value": "6", "group": 2},
{"source": "George", "target": "Bill", "value": "3", "group": 1},
{"source": "Hillary", "target": "Al Gore", "value": "1", "group": 0},
{"source": "Hillary", "target": "Barack", "value": "24", "group": 0},
{"source": "Hillary", "target": "Bernie", "value": "21", "group": 0},
{"source": "Hillary", "target": "Bill", "value": "46", "group": 0},
{"source": "Hillary", "target": "Chelsea", "value": "17", "group": 0},
{"source": "Hillary", "target": "Donald", "value": "32", "group": 0},
{"source": "Hillary", "target": "Donna", "value": "1", "group": 0},
{"source": "Hillary", "target": "Elizabeth", "value": "2", "group": 0},
{"source": "Hillary", "target": "Gary", "value": "2", "group": 0},
{"source": "Hillary", "target": "George", "value": "4", "group": 0},
{"source": "Hillary", "target": "Huma", "value": "4", "group": 0},
{"source": "Hillary", "target": "James Comey", "value": "3", "group": 0},
{"source": "Hillary", "target": "John Podesta", "value": "6", "group": 0},
{"source": "Hillary", "target": "Julian", "value": "2", "group": 0},
{"source": "Hillary", "target": "Michelle", "value": "2", "group": 0},
{"source": "Hillary", "target": "Nancy", "value": "1", "group": 0},
{"source": "Hillary", "target": "Vladimir", "value": "11", "group": 0},
{"source": "Jill", "target": "Vladimir", "value": "1", "group": 2},
{"source": "John Podesta", "target": "Al Gore", "value": "1", "group": 1},
{"source": "John Podesta", "target": "Barack", "value": "3", "group": 1},
{"source": "John Podesta", "target": "George", "value": "3", "group": 1},
{"source": "John Podesta", "target": "Joe", "value": "2", "group": 1},
{"source": "John Podesta", "target": "Paul Ryan", "value": "1", "group": 1},
{"source": "John Podesta", "target": "Ruth Bader", "value": "1", "group": 1},
{"source": "Ruth Bader", "target": "Paul Ryan", "value": "1", "group": 1},
{"source": "Vladimir", "target": "Julian", "value": "1", "group": 2}
],
"Unadjusted_centrality":[
{"id": "Chelsea","Centrality": { "Betweeness": 0.0, "Degree": 0.09090909090909091, "Eigenvector": 0.20415915003451957, "Closeness": 0.20415915003451957, "Harmonic": 0.46808510638297873, "Communicability": 11.166666666666666 } },
{"id": "Joe","Centrality": { "Betweeness": 0.0025252525252525255, "Degree": 0.09090909090909091, "Eigenvector": 0.010855114812667852, "Closeness": 0.010855114812667852, "Harmonic": 0.4, "Communicability": 9.833333333333334 } },
{"id": "John Podesta","Centrality": { "Betweeness": 0.14617604617604618, "Degree": 0.3181818181818182, "Eigenvector": 0.07130343363390072, "Closeness": 0.07130343363390072, "Harmonic": 0.5789473684210527, "Communicability": 14.333333333333332 } },
{"id": "Julian","Centrality": { "Betweeness": 0.0, "Degree": 0.13636363636363635, "Eigenvector": 0.025511496060178503, "Closeness": 0.025511496060178503, "Harmonic": 0.5116279069767442, "Communicability": 12.166666666666666 } },
{"id": "Hillary","Centrality": { "Betweeness": 0.6274891774891774, "Degree": 0.7727272727272727, "Eigenvector": 0.6829410873820295, "Closeness": 0.6829410873820295, "Harmonic": 0.8148148148148148, "Communicability": 19.5 } },
{"id": "Bernie","Centrality": { "Betweeness": 0.04112554112554113, "Degree": 0.18181818181818182, "Eigenvector": 0.21557611166667498, "Closeness": 0.21557611166667498, "Harmonic": 0.5365853658536586, "Communicability": 12.833333333333334 } },
{"id": "Nancy","Centrality": { "Betweeness": 0.0, "Degree": 0.045454545454545456, "Eigenvector": 0.009392126668994716, "Closeness": 0.009392126668994716, "Harmonic": 0.4583333333333333, "Communicability": 10.666666666666666 } },
{"id": "Bill","Centrality": { "Betweeness": 0.005411255411255411, "Degree": 0.18181818181818182, "Eigenvector": 0.4621905252304448, "Closeness": 0.4621905252304448, "Harmonic": 0.5, "Communicability": 12.333333333333334 } },
{"id": "Elizabeth","Centrality": { "Betweeness": 0.0, "Degree": 0.045454545454545456, "Eigenvector": 0.018784253337989432, "Closeness": 0.018784253337989432, "Harmonic": 0.4583333333333333, "Communicability": 10.666666666666666 } },
{"id": "Gary","Centrality": { "Betweeness": 0.0, "Degree": 0.045454545454545456, "Eigenvector": 0.018784253337989432, "Closeness": 0.018784253337989432, "Harmonic": 0.4583333333333333, "Communicability": 10.666666666666666 } },
{"id": "Al Gore","Centrality": { "Betweeness": 0.0, "Degree": 0.09090909090909091, "Eigenvector": 0.01037270895592081, "Closeness": 0.01037270895592081, "Harmonic": 0.5, "Communicability": 11.666666666666666 } },
{"id": "Jill","Centrality": { "Betweeness": 0.0, "Degree": 0.13636363636363635, "Eigenvector": 0.015215937504256255, "Closeness": 0.015215937504256255, "Harmonic": 0.44, "Communicability": 11.0 } },
{"id": "Vladimir","Centrality": { "Betweeness": 0.014430014430014427, "Degree": 0.2272727272727273, "Eigenvector": 0.147233172717295, "Closeness": 0.147233172717295, "Harmonic": 0.5365853658536586, "Communicability": 13.166666666666666 } },
{"id": "Paul Ryan","Centrality": { "Betweeness": 0.020562770562770564, "Degree": 0.13636363636363635, "Eigenvector": 0.015104278547241253, "Closeness": 0.015104278547241253, "Harmonic": 0.4489795918367347, "Communicability": 11.166666666666666 } },
{"id": "Huma","Centrality": { "Betweeness": 0.0, "Degree": 0.045454545454545456, "Eigenvector": 0.037568506675978865, "Closeness": 0.037568506675978865, "Harmonic": 0.4583333333333333, "Communicability": 10.666666666666666 } },
{"id": "Ruth Bader","Centrality": { "Betweeness": 0.0, "Degree": 0.09090909090909091, "Eigenvector": 0.0011883034217490384, "Closeness": 0.0011883034217490384, "Harmonic": 0.39285714285714285, "Communicability": 9.666666666666666 } },
{"id": "George","Centrality": { "Betweeness": 0.004617604617604618, "Degree": 0.18181818181818182, "Eigenvector": 0.07093741079402684, "Closeness": 0.07093741079402684, "Harmonic": 0.5365853658536586, "Communicability": 12.833333333333332 } },
{"id": "Michelle","Centrality": { "Betweeness": 0.0, "Degree": 0.09090909090909091, "Eigenvector": 0.03014298345456936, "Closeness": 0.03014298345456936, "Harmonic": 0.4782608695652174, "Communicability": 11.333333333333334 } },
{"id": "Donald","Centrality": { "Betweeness": 0.18116883116883112, "Degree": 0.4090909090909091, "Eigenvector": 0.34194111761795426, "Closeness": 0.34194111761795426, "Harmonic": 0.6285714285714286, "Communicability": 15.5 } },
{"id": "James Comey","Centrality": { "Betweeness": 0.0, "Degree": 0.09090909090909091, "Eigenvector": 0.05168863705635353, "Closeness": 0.05168863705635353, "Harmonic": 0.5, "Communicability": 11.666666666666666 } },
{"id": "Barack","Centrality": { "Betweeness": 0.09502164502164503, "Degree": 0.4090909090909091, "Eigenvector": 0.2753182178094942, "Closeness": 0.2753182178094942, "Harmonic": 0.6285714285714286, "Communicability": 15.5 } },
{"id": "Mitch","Centrality": { "Betweeness": 0.0, "Degree": 0.045454545454545456, "Eigenvector": 0.009404902819747754, "Closeness": 0.009404902819747754, "Harmonic": 0.39285714285714285, "Communicability": 9.333333333333334 } },
{"id": "Donna","Centrality": { "Betweeness": 0.0, "Degree": 0.045454545454545456, "Eigenvector": 0.009392126668994716, "Closeness": 0.009392126668994716, "Harmonic": 0.4583333333333333, "Communicability": 10.666666666666666 } }
],
"importance":[
{"id": "Chelsea", "importance": 22.771527508938235, "question": "Female"},
{"id": "Joe", "importance": 18.34236807748427, "question": "Male"},
{"id": "John Podesta", "importance": 53.3882540906612, "question": "Male"},
{"id": "Julian", "importance": 33.99433791294509, "question": "Male"},
{"id": "Hillary", "importance": 145.49757092756178, "question": "Female"},
{"id": "Bernie", "importance": 40.90017615204678, "question": "Male"},
{"id": "Nancy", "importance": 16.8749883918687, "question": "Female"},
{"id": "Bill", "importance": 39.01002839078903, "question": "Male"},
{"id": "Elizabeth", "importance": 16.8749883918687, "question": "Female"},
{"id": "Gary", "importance": 16.874988391868705, "question": "Male"},
{"id": "Al Gore", "importance": 23.88804055000509, "question": "Male"},
{"id": "Jill", "importance": 30.52857896011303, "question": "Female"},
{"id": "Vladimir", "importance": 51.83853445139311, "question": "Male"},
{"id": "Paul Ryan", "importance": 23.703448041740145, "question": "Male"},
{"id": "Huma", "importance": 16.8749883918687, "question": "Female"},
{"id": "Ruth Bader", "importance": 17.733160588654357, "question": "Male"},
{"id": "George", "importance": 42.58433974746827, "question": "Male"},
{"id": "Michelle", "importance": 25.683444448659042, "question": "Female"},
{"id": "Donald", "importance": 77.54498571331655, "question": "Male"},
{"id": "James Comey", "importance": 25.218692772756917, "question": "Male"},
{"id": "Barack", "importance": 89.99036490986391, "question": "Male"},
{"id": "Mitch", "importance": 14.179147027442944, "question": "Male"},
{"id": "Donna", "importance": 16.874988391868705, "question": "Female"}
],
"group_stats":[
{"group": "Female", "total_importance": 291.9810754127469, "average_importance": 36.497634426593365, "total_mentions": 8},
{"group": "Male", "total_importance": 569.1908668184363, "average_importance": 37.946057787895754, "total_mentions": 15}
],
"pagerank":[
{"id": "Chelsea", "pagerank": 61},
{"id": "Elizabeth", "pagerank": 17},
{"id": "Joe", "pagerank": 21},
{"id": "John Podesta", "pagerank": 48},
{"id": "Hillary", "pagerank": 3637},
{"id": "Bernie", "pagerank": 57},
{"id": "Bill", "pagerank": 140},
{"id": "Ruth Bader", "pagerank": 7},
{"id": "Gary", "pagerank": 8},
{"id": "Mitch", "pagerank": 9},
{"id": "Jill", "pagerank": 11},
{"id": "Vladimir", "pagerank": 66},
{"id": "Donald", "pagerank": 366},
{"id": "Huma", "pagerank": 16},
{"id": "John McCain", "pagerank": 0},
{"id": "Julian", "pagerank": 13},
{"id": "George", "pagerank": 51},
{"id": "Michelle", "pagerank": 10},
{"id": "Nancy", "pagerank": 4},
{"id": "Paul Ryan", "pagerank": 11},
{"id": "James Comey", "pagerank": 63},
{"id": "Barack", "pagerank": 122},
{"id": "Al Gore", "pagerank": 5},
{"id": "Donna", "pagerank": 2}
],
"question":[
{"id": "Chelsea", "question": "Female"},
{"id": "Joe", "question": "Male"},
{"id": "Michelle", "question": "Female"},
{"id": "Julian", "question": "Male"},
{"id": "Hillary", "question": "Female"},
{"id": "Bernie", "question": "Male"},
{"id": "Nancy", "question": "Female"},
{"id": "Bill", "question": "Male"},
{"id": "Ruth Bader", "question": "Male"},
{"id": "Gary", "question": "Male"},
{"id": "Mitch", "question": "Male"},
{"id": "Jill", "question": "Female"},
{"id": "Vladimir", "question": "Male"},
{"id": "Donald", "question": "Male"},
{"id": "Huma", "question": "Female"},
{"id": "Elizabeth", "question": "Female"},
{"id": "John McCain", "question": "Male"},
{"id": "George", "question": "Male"},
{"id": "John Podesta", "question": "Male"},
{"id": "Paul Ryan", "question": "Male"},
{"id": "James Comey", "question": "Male"},
{"id": "Barack", "question": "Male"},
{"id": "Al Gore", "question": "Male"},
{"id": "Donna", "question": "Female"}
]
},"stats":{
"graph_stats":
{"size": 43, "connectivity": 1.0, "transitivity": 0.2757352941176471, "density": 0.16996047430830039, "diameter": 3}
,
"Periphery_stats": [
{"node": "Chelsea"},
{"node": "Joe"},
{"node": "John Podesta"},
{"node": "Julian"},
{"node": "Bernie"},
{"node": "Nancy"},
{"node": "Vladimir"},
{"node": "Ruth Bader"},
{"node": "Gary"},
{"node": "Al Gore"},
{"node": "Jill"},
{"node": "Bill"},
{"node": "Huma"},
{"node": "Elizabeth"},
{"node": "George"},
{"node": "Michelle"},
{"node": "Paul Ryan"},
{"node": "James Comey"},
{"node": "Mitch"},
{"node": "Donna"}
],
"Central_stats": [
{"node": "Hillary"},
{"node": "Donald"},
{"node": "Barack"}
],
"Node_stats": [
{"node": "Chelsea", "core": 2, "degree": 2},
{"node": "Joe", "core": 2, "degree": 2},
{"node": "John Podesta", "core": 3, "degree": 7},
{"node": "Julian", "core": 3, "degree": 3},
{"node": "Hillary", "core": 3, "degree": 17},
{"node": "Bernie", "core": 3, "degree": 4},
{"node": "Nancy", "core": 1, "degree": 1},
{"node": "Vladimir", "core": 3, "degree": 5},
{"node": "Ruth Bader", "core": 2, "degree": 2},
{"node": "Gary", "core": 1, "degree": 1},
{"node": "Al Gore", "core": 2, "degree": 2},
{"node": "Jill", "core": 3, "degree": 3},
{"node": "Bill", "core": 3, "degree": 4},
{"node": "Donald", "core": 3, "degree": 9},
{"node": "Huma", "core": 1, "degree": 1},
{"node": "Elizabeth", "core": 1, "degree": 1},
{"node": "George", "core": 3, "degree": 4},
{"node": "Michelle", "core": 2, "degree": 2},
{"node": "Paul Ryan", "core": 2, "degree": 3},
{"node": "James Comey", "core": 2, "degree": 2},
{"node": "Barack", "core": 3, "degree": 9},
{"node": "Mitch", "core": 1, "degree": 1},
{"node": "Donna", "core": 1, "degree": 1}
],
"Clique_stats": [
{"Character 1": "Joe","Character 2": "Bernie"},
{"Character 1": "Joe","Character 2": "John Podesta"},
{"Character 1": "Hillary","Character 2": "Chelsea","Character 3": "Bill"},
{"Character 1": "Hillary","Character 2": "Julian","Character 3": "Donald","Character 4": "Vladimir"},
{"Character 1": "Hillary","Character 2": "Nancy"},
{"Character 1": "Hillary","Character 2": "Elizabeth"},
{"Character 1": "Hillary","Character 2": "James Comey","Character 3": "Donald"},
{"Character 1": "Hillary","Character 2": "Gary"},
{"Character 1": "Hillary","Character 2": "Barack","Character 3": "Vladimir","Character 4": "Donald"},
{"Character 1": "Hillary","Character 2": "Barack","Character 3": "Bernie","Character 4": "Donald"},
{"Character 1": "Hillary","Character 2": "Barack","Character 3": "George","Character 4": "John Podesta"},
{"Character 1": "Hillary","Character 2": "Barack","Character 3": "George","Character 4": "Bill"},
{"Character 1": "Hillary","Character 2": "Barack","Character 3": "Michelle"},
{"Character 1": "Hillary","Character 2": "Al Gore","Character 3": "John Podesta"},
{"Character 1": "Hillary","Character 2": "Donna"},
{"Character 1": "Hillary","Character 2": "Huma"},
{"Character 1": "Ruth Bader","Character 2": "Paul Ryan","Character 3": "John Podesta"},
{"Character 1": "Mitch","Character 2": "Donald"},
{"Character 1": "Jill","Character 2": "Barack","Character 3": "Donald","Character 4": "Vladimir"},
{"Character 1": "Paul Ryan","Character 2": "Donald"}
]
}
}
<!DOCTYPE html>
<meta charset="utf-8">
<form>
<style>
.links line {
stroke: #999;
stroke-opacity: 0.6;
}
.nodes circle {
stroke: #fff;
stroke-width: 1.5px;
}
</style>
<svg width="960" height="1000"></svg>
<script src="Scripts/angular.js"></script>
<script src="Scripts/angular-animate.js"></script>
<script src="Scripts/angular-aria.min.js"></script>
<script src="Scripts/angular-ui-router.js"></script>
<script src="Scripts/angular-css.min.js"></script>
<script src="Scripts/angular-cookies.js"></script>
<script src="Scripts/angular-resource.js"></script>
<script src="Scripts/angular-messages.min.js"></script>
<script src="Scripts/angular-material.min.js"></script>
<script src="https://d3js.org/d3.v4.min.js"></script>
<script>
var graph = this;
graph.centrality = "Degree";
console.log(graph.centrality);
var charge = -5000;
var size = 100;
graph.groups = [];
graph.temp = [];
graph.sel = []
var svg = d3.select("svg"),
width = +svg.attr("width"),
height = +svg.attr("height");
var color = d3.scaleOrdinal(d3.schemeCategory20);
var simulation = d3.forceSimulation()
.force("link", d3.forceLink().id(function(d) { return d.id; }))
.force("charge", d3.forceManyBody().strength(function (d) { return d.Centrality[graph.centrality] * charge; }))
.force("center", d3.forceCenter(width / 2, height / 2));
d3.json("hillaryJSON.json", function(error, graph) {
if (error) throw error;
console.log(graph)
graph.groups = [];
graph.temp = [];
graph.sel = [];
graph.centrality = "Degree";
for (var i = 0; i < graph.info.nodes.length; i++) {
if (!graph.groups.includes(graph.info.nodes[i].question)) {
graph.groups.push(graph.info.nodes[i].question);
graph.sel.push(graph.info.nodes.question);
graph.temp.push(graph.info.nodes.question);
}
}
console.log(graph.groups);
graph.changes = function (item) {
if (graph.sel.includes(item)) {
var index = graph.sel.indexOf(item);
graph.sel.splice(index, 1);
}
else {
graph.sel.push(item);
}
}
graph.type = function (d) {
return graph.sel.includes(d) ? true : false;
}
var link = svg.append("g")
.attr("class", "links")
.selectAll("line")
.data(graph.info.links)
.enter().append("line")
.attr("stroke-width", function(d) { return Math.sqrt(d.value); });
var node = svg.append("g")
.attr("class", "nodes")
.selectAll("circle")
.data(graph.info.nodes)
.enter().append("circle")
.attr("r", function (d) {
return d.Centrality[graph.centrality]*size;
})
.attr("fill", function(d) { return color(d.group); })
.attr("type", function (d) { return d.question })
.call(d3.drag()
.on("start", dragstarted)
.on("drag", dragged)
.on("end", dragended));
var texts = svg.selectAll("text.label")
.data(graph.info.nodes)
.enter()
.append("text")
.attr("class", "label")
.text(function (d) {
return d.id;
});
node.append("title")
.text(function(d) { return d.id; });
node.append("span")
.text(function (d) { return d.id });
node.append("text")
.attr("dx", 12)
.attr("dy", ".35em")
.text(function (d) { return d.id });
simulation
.nodes(graph.info.nodes)
.on("tick", ticked);
simulation.force("link")
.links(graph.info.links);
graph.change = function (value) {
graph.centrality = value;
simulation.force("charge", d3.forceManyBody().strength(function (d) { return d.Centrality[graph.centrality] * charge; }))
node
.attr("cx", function (d) {
return d.x;
})
.attr("cy", function (d) { return d.y; })
.attr("r", function (d) {
return d.Centrality[graph.centrality] * size;
});
restart();
}
function ticked() {
link
.attr("x1", function(d) { return d.source.x; })
.attr("y1", function(d) { return d.source.y; })
.attr("x2", function(d) { return d.target.x; })
.attr("y2", function(d) { return d.target.y; });
node
.attr("cx", function(d) { return d.x; })
.attr("cy", function(d) { return d.y; })
.attr("r", function (d) {
return d.Centrality[graph.centrality] *size;
});
texts.attr("x", function (d) {
return d.x;
})
.attr("y", function (d) {
return d.y;
});
}
});
function dragstarted(d) {
if (!d3.event.active) simulation.alphaTarget(0.3).restart();
d.fx = d.x;
d.fy = d.y;
}
function dragged(d) {
d.fx = d3.event.x;
d.fy = d3.event.y;
}
function dragended(d) {
if (!d3.event.active) simulation.alphaTarget(0);
d.fx = null;
d.fy = null;
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment