· neo4j cypher brexit

Graphing Brexit: Did the threat work?

Following on from the blog post where we compared how MPs and parties voted on Brexit indicative measures, in this post we’re going to explore how Conservative MPs have voted with respect to a no deal exit from the European Union. In particular we’d like to know whether the threat to have the party whip removed had an impact on how they voted in the recent motion to request an extension to work out a deal.

We know that there were 21 people who voted against the government and had the Conservative party whip removed. Presumably the other Conservative MPs voted against the motion, but let’s check by executing the following query:

MATCH (m:Motion {division: "439"})<-[vote]-(person:Person),
      (person)-[memberOf:MEMBER_OF]->(:Party {name: "Conservative"})
WHERE memberOf.start <= m.date
AND (not(exists(memberOf.end)) OR m.date <= memberOf.end)
RETURN type(vote), count(*)
ORDER BY count(*) DESC
Table 1. Results
type(vote) count(*)







As expected, most MPs voted against this motion, although there are also 3 MPs who didn’t vote.

Those 3 who didn’t vote might be interesting to explore further, but for now let’s go back to our 21 rebel MPs and see how they voted on Mr Baron’s motion B (No deal) back in March. We’d assume that they mostly voted against this motion, but let’s check by executing the following query:

MATCH (person:Person)-[vote]->(:Motion {division: "386"})
WHERE (person)-[:MEMBER_OF {end: date({year: 2019, month: 9, day: 3})}]
       ->(:Party {name: "Conservative"})
WITH person, type(vote) AS vote
ORDER BY person.pageviews DESC
RETURN person.name AS person, vote
Table 2. Results
person vote

"Philip Hammond"


"Kenneth Clarke"


"Justine Greening"


"Rory Stewart"


"Nicholas Soames"


"Dominic Grieve"


"Oliver Letwin"


"Sam Gyimah"


"David Gauke"


"Greg Clark"


"Caroline Nokes"


"Margot James"


"Richard Benyon"


"Anne Milton"


"Guto Bebb"


"Alistair Burt"


"Antoinette Sandbach"


"Stephen Hammond"


"Steve Brine"


"Richard Harrington"


"Edward Vaizey"


Unsurprisingly most of these people voted against the motion, 17 in total, although the 4 cabinet members didn’t vote. Were there any other Conservative MPs who also voted against Mr Baron’s motion B (No deal)?

We can find out by executing the following query:

MATCH (person:Person)-[vote]->(m:Motion {division: "386"}),
      (person)-[memberOf:MEMBER_OF]->(:Party {name: "Conservative"})
WHERE memberOf.start <= m.date
AND (not(exists(memberOf.end)) OR m.date <= memberOf.end)
RETURN type(vote), count(*)
ORDER BY count(*) DESC
Table 3. Results
type(vote) count(*)







There were 94 people who voted against this motion. We know who 17 of them are, but that still leaves us with 77 others.

MATCH (person:Person)-[:AGAINST]->(noDealMotion:Motion {division: "386"}),
      (person)-[memberOf:MEMBER_OF]->(:Party {name: "Conservative"})
WHERE memberOf.start <= noDealMotion.date
AND (not(exists(memberOf.end)) OR noDealMotion.date <= memberOf.end)
MATCH (person)-[vote]->(:Motion {division: "439"})
RETURN  type(vote) AS vote, collect(person.name) AS people, count(*) AS count
Table 4. Results
vote people count


["James Cartlidge", "John Glen", "David Morris", "John Howell", "Luke Hall", "Mark Pawsey", "Chris Skidmore", "Alister Jack", "Gary Streeter", "Luke Graham", "Mel Stride", "Kevin Hollinrake", "Jeremy Lefroy", "Jeremy Quin", "Bim Afolami", "Victoria Atkins", "Michael Fallon", "Robin Walker", "Damien Moore", "Oliver Heald", "Nick Herbert", "Nicky Morgan", "Alok Sharma", "Keith Simpson", "Stephen Kerr", "Paul Masterton", "Alberto Costa", "Nick Hurd", "Colin Clark", "Lucy Frazer", "Stephen Crabb", "Bill Grant", "Andrew Bowie", "Robert Buckland", "Richard Graham", "Damian Collins", "Roger Gale", "David Duguid", "Jesse Norman", "Guy Opperman", "Charles Walker", "Paul Beresford", "Greg Hands", "Hugo Swire", "Patrick McLoughlin", "Mark Prisk", "Vicky Ford", "Damian Green", "Joseph Johnson", "Victoria Prentis", "Mike Freer", "Oliver Dowden", "David Tredinnick", "Andrew Jones", "Helen Grant", "George Hollingbery", "Robert Halfon", "Cheryl Gillan", "Rebecca Pow", "Simon Hoare", "Gillian Keegan", "Alex Chalk", "Graham Brady", "Caroline Spelman", "Peter Bottomley", "Alan Duncan", "Sarah Newton", "Robert Neill", "Philip Dunne", "Peter Aldous", "Jo Churchill", "Mark Field", "Seema Kennedy", "Jonathan Djanogly", "Mary Robinson"]



["Stephen Hammond", "Justine Greening", "Steve Brine", "Rory Stewart", "Margot James", "Oliver Letwin", "Dominic Grieve", "Sam Gyimah", "Nick Boles", "Richard Benyon", "Alistair Burt", "Guto Bebb", "Kenneth Clarke", "Edward Vaizey", "Anne Milton", "Richard Harrington", "Nicholas Soames", "Antoinette Sandbach", "Phillip Lee"]


We can see that there are 19 people who voted against both motions. If we add our 4 ex-Cabinet members, that gives us a total of 23 former Conservative MPs who voted against the motion to ask for an extension. 21 of those had the party whip removed on the 3rd September 2019, but that still gives us two that are not accounted for. We can write the following query to find out what happened with them:

MATCH (person:Person)-[:AGAINST]->(noDealMotion:Motion {division: "386"}),
      (person)-[memberOf:MEMBER_OF]->(:Party {name: "Conservative"})
WHERE memberOf.start <= noDealMotion.date
AND (not(exists(memberOf.end)) OR noDealMotion.date <= memberOf.end)
MATCH (person)-[vote]->(:Motion {division: "439"})
WITH person, type(vote) AS vote, memberOf
WHERE memberOf.end <> date({year: 2019, month: 9, day: 3})
RETURN person.name AS person, vote, memberOf.end AS endDate
Table 5. Results
person vote endDate

"Nick Boles"



"Phillip Lee"



Phillip Lee famously walked across the floor of the Houses of Common to join the Liberal Democrats, and I’d forgotten that Nick Boles had resigned the party whip back in April.

That still leave us with 75 people who changed their position from not supporting no deal in March 2019, but wanting to leave it as an option in September 2019. We’ll give them the benefit of the doubt, and make the assumption that if they represent a constituency that had a majority vote to leave the EU their constituents may be happy with them taking this position. But if their constituency had a majority vote to remain in the EU we can’t really make that argument.

The following query find MPs who voted against no deal in the indicative votes, voted against asking for an extension (under threat of having the party whip removed), and represent constituencies that want to remain in the EU:

MATCH (person:Person)-[:AGAINST]->(noDealMotion:Motion {division: "386"}),
      (person)-[memberOf:MEMBER_OF]->(:Party {name: "Conservative"})
WHERE memberOf.start <= noDealMotion.date
AND (not(exists(memberOf.end)) OR noDealMotion.date <= memberOf.end)
MATCH (person)-[:AGAINST]->(:Motion {division: "439"}),
WHERE constituency.leave < 50
RETURN person.name AS person,
       constituency.name AS constituency,
       constituency.leave AS leavePercentage
ORDER BY constituency.leave
Table 6. Results
person constituency leavePercentage

"Paul Masterton"

"East Renfrewshire"


"Mark Field"

"Cities of London and Westminster"


"Greg Hands"

"Chelsea and Fulham"


"Mike Freer"

"Finchley and Golders Green"


"Stephen Kerr"



"Graham Brady"

"Altrincham and Sale West"


"Andrew Bowie"

"West Aberdeenshire and Kincardine"


"Luke Graham"

"Ochil and South Perthshire"


"Bim Afolami"

"Hitchin and Harpenden"


"Mary Robinson"



"Alex Chalk"



"John Howell"



"Bill Grant"

"Ayr, Carrick and Cumnock"


"Colin Clark"



"Cheryl Gillan"

"Chesham and Amersham"


"Alister Jack"

"Dumfries and Galloway"


"Guy Opperman"



"Lucy Frazer"

"South East Cambridgeshire"


"Sarah Newton"

"Truro and Falmouth"


"Damien Moore"



"Andrew Jones"

"Harrogate and Knaresborough"


"Paul Beresford"

"Mole Valley"


"Mark Prisk"

"Hertford and Stortford"


"Jeremy Quin"



"Nick Hurd"

"Ruislip, Northwood and Pinner"


"Nick Herbert"

"Arundel and South Downs"


"Robert Neill"

"Bromley and Chislehurst"


"John Glen"



Several of these constituencies are in London or Scotland. They would therefore seem like seats that remain favouring parties, such as the Liberal Democrats or SNP would try to win in the next election. And indeed the Liberal Democrats have already moved MPs into Cities of London and Westminster and Finchley and Golders Green.

It’ll be fascinating to see what will happen with these seats if and when there is actually an election. If you have any other ideas for how we can explore the data, let me know in the comments.

  • LinkedIn
  • Tumblr
  • Reddit
  • Google+
  • Pinterest
  • Pocket