{"id":23396558,"url":"https://github.com/mneedham/graphing-brexit","last_synced_at":"2025-04-08T17:32:41.079Z","repository":{"id":66523753,"uuid":"178285950","full_name":"mneedham/graphing-brexit","owner":"mneedham","description":null,"archived":false,"fork":false,"pushed_at":"2019-10-18T15:33:50.000Z","size":342,"stargazers_count":7,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-14T13:50:23.866Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mneedham.png","metadata":{"files":{"readme":"README.adoc","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-03-28T21:38:07.000Z","updated_at":"2023-08-29T12:52:33.000Z","dependencies_parsed_at":null,"dependency_job_id":"70624ab1-0af3-42d2-9ad0-97e853fa3675","html_url":"https://github.com/mneedham/graphing-brexit","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mneedham%2Fgraphing-brexit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mneedham%2Fgraphing-brexit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mneedham%2Fgraphing-brexit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mneedham%2Fgraphing-brexit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mneedham","download_url":"https://codeload.github.com/mneedham/graphing-brexit/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247892655,"owners_count":21013756,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-22T07:36:20.188Z","updated_at":"2025-04-08T17:32:41.073Z","avatar_url":"https://github.com/mneedham.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"= Graphing Brexit\n\n\nAlong with many of my countrymen, I spent the night of 27th March 2019 watching UK MPs vote ‘No’ to a series of potential Brexit options, and then read analysis of how different individuals and parties had votes on various websites.\nWhile being very interesting, all the analysis felt very tabular to me, and I was curious whether we could learn anything new by putting the data into a graph.\n\nYou can read more in https://medium.com/neo4j/graphing-brexit-bbe4314cf70[the blog post^] I wrote on this topic.\n\nThis repository contains the scripts, data, and queries that I reference in the post.\n\nThe blog post is based on data that I scraped from the Guardian website:\n\n== Importing the Guardian data\n\nSource: https://www.theguardian.com/uk-news/ng-interactive/2019/mar/27/how-did-your-mp-vote-in-the-indicative-votes\n\n[source, cypher]\n----\n// Create one node per motion\nLOAD CSV WITH HEADERS FROM \"https://github.com/mneedham/graphing-brexit/raw/master/data/motions.csv\" AS row\nMERGE (m:Motion {id: toInteger(row.id)})\nSET m.name = row.name;\n\n// Create nodes for each MP and each party and connect them\nLOAD CSV WITH HEADERS FROM \"https://github.com/mneedham/graphing-brexit/raw/master/data/mps.csv\" AS row\nMERGE (person:Person {name: row.mp})\nMERGE (party:Party {name: row.party})\nMERGE (person)-[:MEMBER_OF]-\u003e(party);\n\n// Create a relationship between each MP and each motion\nLOAD CSV WITH HEADERS FROM \"https://github.com/mneedham/graphing-brexit/raw/master/data/votes.csv\" AS row\nMATCH (person:Person {name: row.person})\nMATCH (motion:Motion {id: toInteger(row.motionId)})\nCALL apoc.create.relationship(person, row.vote, {}, motion)\nYIELD rel\nRETURN rel;\n----\n\nBut then https://twitter.com/rbramley/status/1111535839811653632[Robin Bramley^] pointed out CommonsVotes, which has the data in CSV format.\nIt also has the data for the votes on Theresa May's various motions.\n\n== Importing the CommonsVotes data\n\nSource: https://commonsvotes.digiminster.com/\n\n[source, cypher]\n----\nUNWIND [655,656,657,658,659,660,661,662] AS division\nLOAD CSV FROM \"https://github.com/mneedham/graphing-brexit/raw/master/data/commonsvotes/Division\" + division + \".csv\" AS row\nWITH division, collect(row) AS rows\nMERGE (motion:Motion {division: trim(split(rows[0][0], \":\")[1]) })\nSET motion.name = rows[2][0]\nWITH motion, rows\nUNWIND rows[7..] AS row\nMERGE (person:Person {name: row[0]})\nMERGE (party:Party {name: row[1]})\nMERGE (constituency:Constituency {name: row[2]})\nMERGE (person)-[:MEMBER_OF]-\u003e(party)\nMERGE (person)-[:REPRESENTS]-\u003e(constituency)\nWITH person, motion,  CASE WHEN row[3] = \"Aye\" THEN \"FOR\" WHEN row[3] = \"No\" THEN \"AGAINST\" ELSE \"DID_NOT_VOTE\" END AS vote\nCALL apoc.merge.relationship(person, vote, {}, {}, motion)\nYIELD rel\nRETURN count(*)\n----\n\n== Importing the House of Commons Library data\n\nSource: https://commonslibrary.parliament.uk/parliament-and-elections/elections-elections/brexit-votes-by-constituency/\n\n[source, cypher]\n----\nLOAD CSV WITH HEADERS FROM \"https://github.com/mneedham/graphing-brexit/raw/master/data/euref.csv\" AS row\nMATCH (c:Constituency) WHERE toLower(c.name) = toLower(row.Constituency)\nSET c.leave = toFloat(apoc.text.replace(row[\"TO USE\"], \"%\",\"\"))\n----\n\n== Mapping of ids to short names\n\n. Mr Clarke's motion J (Customs union)\n. Margaret Beckett's motion M (Confirmatory public vote)\n. Jeremy Corbyn's motion K (Labour's alternative plan)\n. Nick Boles's motion D (Common market 2.0)\n. Joanna Cherry's motion L (Revocation to avoid no deal)\n. Mr Baron's motion B (No deal)\n. Mr Fysh's motion O (Contingent preferential arrangements)\n. George Eustice's motion H (EFTA and EEA)\n\n== Other ideas\n\n* [ ] https://twitter.com/chriseyre2000/status/1111908414521638912[Infer new political groupings^]\n* [ ] Add Theresa May's motions\n* [ ] Changes in how people vote in the Theresa May motions\n* [ ] https://twitter.com/EastlondonDev/status/1111651874413969409[Cosine distance between motions and use that to try a ranking^]\n* [ ] https://twitter.com/davidbarton_/status/1111523034459000832[Similarity of motions^]\n* [ ] https://twitter.com/fluffymaccoy/status/1111542849751998464[Individual stance vs party affiliation^]\n* [ ] https://twitter.com/fluffymaccoy/status/1111542518280261632[Constituencies banded into leave/remain and strong/weak^]\n* [ ] https://twitter.com/mesirii/status/1111513552081293312[Clusters of MPs^]\n* [ ] Full graph with bloom to show clusters\n* [ ] Top k similarity graph\n* [ ] Geocode MPs and put them on a brexit map","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmneedham%2Fgraphing-brexit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmneedham%2Fgraphing-brexit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmneedham%2Fgraphing-brexit/lists"}