Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?

The Star Wars social network

I recently looked at the whole Star Wars universe from a computational perspective, where I extracted and analyzed social networks from all seven films. The social network structure revealed some interesting differences between the individual films, especially between the original trilogy and the prequels. Here I’ll look at how we can represent and explore the same network using a Neo4j database.

You can read more about my original analysis in my two blog posts, which include additional social network analysis and my F# scripts for downloading and extracting the data:

The network

The social network was automatically constructed using the films' screenplays. The nodes in the network represent the individual characters who are connected by a link if they both speak within the same movie scene. The network only includes characters that appear in at least two scenes and that are explicitly named in the screenplay (I excluded characters called "PILOT" or even "STAR DESTROYER TECHNICIAN"). I also separated the characters into two categories: Person and Droid.

The interactions create the basic structure of the network, where characters are connected by the SPEAKS_WITH relation. I also included the information about the individual movies using the APPEARS_IN relation. The following graph illustrates the general network structure:

network relations

Now we can setup the database using the social network from all the 7 movies combined together.

CREATE
  (Episode1:Movie {name: 'Episode I: The Phantom Menace'}),
  (Episode2:Movie {name: 'Episode II: Attack of the Clones'}),
  (Episode3:Movie {name: 'Episode III: Revenge of the Sith'}),
  (Episode4:Movie {name: 'Episode IV: A New Hope'}),
  (Episode5:Movie {name: 'Episode V: The Empire Strikes Back'}),
  (Episode6:Movie {name: 'Episode VI: Return of the Jedi'}),
  (Episode7:Movie {name: 'Episode VII: The Force Awakens'}),
  (r2_d2:Droid {name: 'R2-D2'}),
  (chewbacca:Person {name: 'CHEWBACCA'}),
  (bb_8:Droid {name: 'BB-8'}),
  (qui_gon:Person {name: 'QUI-GON'}),
  (nute_gunray:Person {name: 'NUTE GUNRAY'}),
  (pk_4:Person {name: 'PK-4'}),
  (tc_14:Person {name: 'TC-14'}),
  (obi_wan:Person {name: 'OBI-WAN'}),
  (dofine:Person {name: 'DOFINE'}),
  (rune:Person {name: 'RUNE'}),
  (tey_how:Person {name: 'TEY HOW'}),
  (emperor:Person {name: 'EMPEROR'}),
  (captain_panaka:Person {name: 'CAPTAIN PANAKA'}),
  (sio_bibble:Person {name: 'SIO BIBBLE'}),
  (jar_jar:Person {name: 'JAR JAR'}),
  (tarpals:Person {name: 'TARPALS'}),
  (boss_nass:Person {name: 'BOSS NASS'}),
  (padme:Person {name: 'PADME'}),
  (ric_olie:Person {name: 'RIC OLIE'}),
  (watto:Person {name: 'WATTO'}),
  (anakin:Person {name: 'ANAKIN'}),
  (sebulba:Person {name: 'SEBULBA'}),
  (jira:Person {name: 'JIRA'}),
  (shmi:Person {name: 'SHMI'}),
  (c_3po:Droid {name: 'C-3PO'}),
  (darth_maul:Person {name: 'DARTH MAUL'}),
  (kitster:Person {name: 'KITSTER'}),
  (wald:Person {name: 'WALD'}),
  (fode_beed:Person {name: 'FODE/BEED'}),
  (jabba:Person {name: 'JABBA'}),
  (greedo:Person {name: 'GREEDO'}),
  (valorum:Person {name: 'VALORUM'}),
  (mace_windu:Person {name: 'MACE WINDU'}),
  (ki_adi_mundi:Person {name: 'KI-ADI-MUNDI'}),
  (yoda:Person {name: 'YODA'}),
  (rabe:Person {name: 'RABE'}),
  (bail_organa:Person {name: 'BAIL ORGANA'}),
  (general_ceel:Person {name: 'GENERAL CEEL'}),
  (bravo_two:Person {name: 'BRAVO TWO'}),
  (bravo_three:Person {name: 'BRAVO THREE'}),
  (captain_typho:Person {name: 'CAPTAIN TYPHO'}),
  (senator_ask_aak:Person {name: 'SENATOR ASK AAK'}),
  (orn_free_taa:Person {name: 'ORN FREE TAA'}),
  (sola:Person {name: 'SOLA'}),
  (jobal:Person {name: 'JOBAL'}),
  (ruwee:Person {name: 'RUWEE'}),
  (taun_we:Person {name: 'TAUN WE'}),
  (lama_su:Person {name: 'LAMA SU'}),
  (boba_fett:Person {name: 'BOBA FETT'}),
  (jango_fett:Person {name: 'JANGO FETT'}),
  (owen:Person {name: 'OWEN'}),
  (beru:Person {name: 'BERU'}),
  (cliegg:Person {name: 'CLIEGG'}),
  (count_dooku:Person {name: 'COUNT DOOKU'}),
  (sun_rit:Person {name: 'SUN RIT'}),
  (poggle:Person {name: 'POGGLE'}),
  (plo_koon:Person {name: 'PLO KOON'}),
  (odd_ball:Person {name: 'ODD BALL'}),
  (general_grievous:Person {name: 'GENERAL GRIEVOUS'}),
  (fang_zar:Person {name: 'FANG ZAR'}),
  (mon_mothma:Person {name: 'MON MOTHMA'}),
  (giddean_danu:Person {name: 'GIDDEAN DANU'}),
  (clone_commander_gree:Person {name: 'CLONE COMMANDER GREE'}),
  (clone_commander_cody:Person {name: 'CLONE COMMANDER CODY'}),
  (tion_medon:Person {name: 'TION MEDON'}),
  (captain_antilles:Person {name: 'CAPTAIN ANTILLES'}),
  (darth_vader:Person {name: 'DARTH VADER'}),
  (luke:Person {name: 'LUKE'}),
  (camie:Person {name: 'CAMIE'}),
  (biggs:Person {name: 'BIGGS'}),
  (leia:Person {name: 'LEIA'}),
  (motti:Person {name: 'MOTTI'}),
  (tarkin:Person {name: 'TARKIN'}),
  (han:Person {name: 'HAN'}),
  (dodonna:Person {name: 'DODONNA'}),
  (gold_leader:Person {name: 'GOLD LEADER'}),
  (wedge:Person {name: 'WEDGE'}),
  (red_leader:Person {name: 'RED LEADER'}),
  (red_ten:Person {name: 'RED TEN'}),
  (gold_five:Person {name: 'GOLD FIVE'}),
  (rieekan:Person {name: 'RIEEKAN'}),
  (derlin:Person {name: 'DERLIN'}),
  (zev:Person {name: 'ZEV'}),
  (piett:Person {name: 'PIETT'}),
  (ozzel:Person {name: 'OZZEL'}),
  (dack:Person {name: 'DACK'}),
  (janson:Person {name: 'JANSON'}),
  (needa:Person {name: 'NEEDA'}),
  (lando:Person {name: 'LANDO'}),
  (jerjerrod:Person {name: 'JERJERROD'}),
  (bib_fortuna:Person {name: 'BIB FORTUNA'}),
  (boushh:Person {name: 'BOUSHH'}),
  (admiral_ackbar:Person {name: 'ADMIRAL ACKBAR'}),
  (lor_san_tekka:Person {name: 'LOR SAN TEKKA'}),
  (poe:Person {name: 'POE'}),
  (kylo_ren:Person {name: 'KYLO REN'}),
  (captain_phasma:Person {name: 'CAPTAIN PHASMA'}),
  (finn:Person {name: 'FINN'}),
  (unkar_plutt:Person {name: 'UNKAR PLUTT'}),
  (rey:Person {name: 'REY'}),
  (general_hux:Person {name: 'GENERAL HUX'}),
  (lieutenant_mitaka:Person {name: 'LIEUTENANT MITAKA'}),
  (bala_tik:Person {name: 'BALA-TIK'}),
  (snoke:Person {name: 'SNOKE'}),
  (maz:Person {name: 'MAZ'}),
  (snap:Person {name: 'SNAP'}),
  (admiral_statura:Person {name: 'ADMIRAL STATURA'}),
  (yolo_ziff:Person {name: 'YOLO ZIFF'}),
  (colonel_datoo:Person {name: 'COLONEL DATOO'}),
  (ello_asty:Person {name: 'ELLO ASTY'}),
  (jess:Person {name: 'JESS'}),
  (niv_lek:Person {name: 'NIV LEK'}),
  (chewbacca)-[:SPEAKS_WITH]->(r2_d2),
  (bb_8)-[:SPEAKS_WITH]->(r2_d2),
  (bb_8)-[:SPEAKS_WITH]->(chewbacca),
  (obi_wan)-[:SPEAKS_WITH]->(r2_d2),
  (padme)-[:SPEAKS_WITH]->(r2_d2),
  (qui_gon)-[:SPEAKS_WITH]->(r2_d2),
  (anakin)-[:SPEAKS_WITH]->(r2_d2),
  (r2_d2)-[:SPEAKS_WITH]->(watto),
  (c_3po)-[:SPEAKS_WITH]->(r2_d2),
  (kitster)-[:SPEAKS_WITH]->(r2_d2),
  (jabba)-[:SPEAKS_WITH]->(r2_d2),
  (emperor)-[:SPEAKS_WITH]->(r2_d2),
  (captain_typho)-[:SPEAKS_WITH]->(r2_d2),
  (beru)-[:SPEAKS_WITH]->(r2_d2),
  (owen)-[:SPEAKS_WITH]->(r2_d2),
  (bail_organa)-[:SPEAKS_WITH]->(r2_d2),
  (r2_d2)-[:SPEAKS_WITH]->(yoda),
  (luke)-[:SPEAKS_WITH]->(r2_d2),
  (leia)-[:SPEAKS_WITH]->(r2_d2),
  (captain_antilles)-[:SPEAKS_WITH]->(r2_d2),
  (biggs)-[:SPEAKS_WITH]->(r2_d2),
  (darth_vader)-[:SPEAKS_WITH]->(r2_d2),
  (han)-[:SPEAKS_WITH]->(r2_d2),
  (lando)-[:SPEAKS_WITH]->(r2_d2),
  (chewbacca)-[:SPEAKS_WITH]->(obi_wan),
  (c_3po)-[:SPEAKS_WITH]->(chewbacca),
  (chewbacca)-[:SPEAKS_WITH]->(luke),
  (chewbacca)-[:SPEAKS_WITH]->(han),
  (chewbacca)-[:SPEAKS_WITH]->(jabba),
  (chewbacca)-[:SPEAKS_WITH]->(leia),
  (chewbacca)-[:SPEAKS_WITH]->(darth_vader),
  (chewbacca)-[:SPEAKS_WITH]->(rieekan),
  (chewbacca)-[:SPEAKS_WITH]->(lando),
  (boba_fett)-[:SPEAKS_WITH]->(chewbacca),
  (chewbacca)-[:SPEAKS_WITH]->(finn),
  (chewbacca)-[:SPEAKS_WITH]->(rey),
  (bala_tik)-[:SPEAKS_WITH]->(chewbacca),
  (chewbacca)-[:SPEAKS_WITH]->(maz),
  (chewbacca)-[:SPEAKS_WITH]->(poe),
  (chewbacca)-[:SPEAKS_WITH]->(kylo_ren),
  (captain_phasma)-[:SPEAKS_WITH]->(chewbacca),
  (bb_8)-[:SPEAKS_WITH]->(poe),
  (bb_8)-[:SPEAKS_WITH]->(lor_san_tekka),
  (bb_8)-[:SPEAKS_WITH]->(rey),
  (bb_8)-[:SPEAKS_WITH]->(unkar_plutt),
  (bb_8)-[:SPEAKS_WITH]->(finn),
  (bb_8)-[:SPEAKS_WITH]->(han),
  (bala_tik)-[:SPEAKS_WITH]->(bb_8),
  (bb_8)-[:SPEAKS_WITH]->(maz),
  (bb_8)-[:SPEAKS_WITH]->(leia),
  (bb_8)-[:SPEAKS_WITH]->(c_3po),
  (nute_gunray)-[:SPEAKS_WITH]->(qui_gon),
  (pk_4)-[:SPEAKS_WITH]->(tc_14),
  (obi_wan)-[:SPEAKS_WITH]->(tc_14),
  (qui_gon)-[:SPEAKS_WITH]->(tc_14),
  (obi_wan)-[:SPEAKS_WITH]->(qui_gon),
  (nute_gunray)-[:SPEAKS_WITH]->(tc_14),
  (dofine)-[:SPEAKS_WITH]->(nute_gunray),
  (dofine)-[:SPEAKS_WITH]->(tc_14),
  (nute_gunray)-[:SPEAKS_WITH]->(rune),
  (rune)-[:SPEAKS_WITH]->(tey_how),
  (nute_gunray)-[:SPEAKS_WITH]->(tey_how),
  (captain_panaka)-[:SPEAKS_WITH]->(emperor),
  (emperor)-[:SPEAKS_WITH]->(sio_bibble),
  (captain_panaka)-[:SPEAKS_WITH]->(sio_bibble),
  (jar_jar)-[:SPEAKS_WITH]->(qui_gon),
  (jar_jar)-[:SPEAKS_WITH]->(obi_wan),
  (jar_jar)-[:SPEAKS_WITH]->(tarpals),
  (boss_nass)-[:SPEAKS_WITH]->(qui_gon),
  (boss_nass)-[:SPEAKS_WITH]->(obi_wan),
  (boss_nass)-[:SPEAKS_WITH]->(jar_jar),
  (emperor)-[:SPEAKS_WITH]->(nute_gunray),
  (emperor)-[:SPEAKS_WITH]->(rune),
  (nute_gunray)-[:SPEAKS_WITH]->(sio_bibble),
  (jar_jar)-[:SPEAKS_WITH]->(sio_bibble),
  (captain_panaka)-[:SPEAKS_WITH]->(jar_jar),
  (qui_gon)-[:SPEAKS_WITH]->(sio_bibble),
  (captain_panaka)-[:SPEAKS_WITH]->(qui_gon),
  (captain_panaka)-[:SPEAKS_WITH]->(padme),
  (padme)-[:SPEAKS_WITH]->(qui_gon),
  (padme)-[:SPEAKS_WITH]->(sio_bibble),
  (captain_panaka)-[:SPEAKS_WITH]->(obi_wan),
  (obi_wan)-[:SPEAKS_WITH]->(ric_olie),
  (jar_jar)-[:SPEAKS_WITH]->(ric_olie),
  (qui_gon)-[:SPEAKS_WITH]->(ric_olie),
  (captain_panaka)-[:SPEAKS_WITH]->(ric_olie),
  (jar_jar)-[:SPEAKS_WITH]->(padme),
  (qui_gon)-[:SPEAKS_WITH]->(watto),
  (anakin)-[:SPEAKS_WITH]->(watto),
  (padme)-[:SPEAKS_WITH]->(watto),
  (anakin)-[:SPEAKS_WITH]->(qui_gon),
  (anakin)-[:SPEAKS_WITH]->(padme),
  (jar_jar)-[:SPEAKS_WITH]->(sebulba),
  (anakin)-[:SPEAKS_WITH]->(sebulba),
  (qui_gon)-[:SPEAKS_WITH]->(sebulba),
  (padme)-[:SPEAKS_WITH]->(sebulba),
  (anakin)-[:SPEAKS_WITH]->(jar_jar),
  (anakin)-[:SPEAKS_WITH]->(jira),
  (jira)-[:SPEAKS_WITH]->(qui_gon),
  (jira)-[:SPEAKS_WITH]->(padme),
  (anakin)-[:SPEAKS_WITH]->(shmi),
  (jar_jar)-[:SPEAKS_WITH]->(shmi),
  (qui_gon)-[:SPEAKS_WITH]->(shmi),
  (padme)-[:SPEAKS_WITH]->(shmi),
  (anakin)-[:SPEAKS_WITH]->(c_3po),
  (c_3po)-[:SPEAKS_WITH]->(padme),
  (obi_wan)-[:SPEAKS_WITH]->(sio_bibble),
  (darth_maul)-[:SPEAKS_WITH]->(emperor),
  (anakin)-[:SPEAKS_WITH]->(kitster),
  (anakin)-[:SPEAKS_WITH]->(wald),
  (kitster)-[:SPEAKS_WITH]->(wald),
  (jar_jar)-[:SPEAKS_WITH]->(kitster),
  (kitster)-[:SPEAKS_WITH]->(qui_gon),
  (jar_jar)-[:SPEAKS_WITH]->(wald),
  (qui_gon)-[:SPEAKS_WITH]->(wald),
  (anakin)-[:SPEAKS_WITH]->(obi_wan),
  (obi_wan)-[:SPEAKS_WITH]->(shmi),
  (c_3po)-[:SPEAKS_WITH]->(watto),
  (kitster)-[:SPEAKS_WITH]->(watto),
  (c_3po)-[:SPEAKS_WITH]->(qui_gon),
  (c_3po)-[:SPEAKS_WITH]->(kitster),
  (kitster)-[:SPEAKS_WITH]->(padme),
  (fode_beed)-[:SPEAKS_WITH]->(jabba),
  (jabba)-[:SPEAKS_WITH]->(shmi),
  (sebulba)-[:SPEAKS_WITH]->(shmi),
  (anakin)-[:SPEAKS_WITH]->(jabba),
  (jabba)-[:SPEAKS_WITH]->(jar_jar),
  (jabba)-[:SPEAKS_WITH]->(padme),
  (jabba)-[:SPEAKS_WITH]->(sebulba),
  (jabba)-[:SPEAKS_WITH]->(qui_gon),
  (fode_beed)-[:SPEAKS_WITH]->(jar_jar),
  (fode_beed)-[:SPEAKS_WITH]->(padme),
  (greedo)-[:SPEAKS_WITH]->(qui_gon),
  (anakin)-[:SPEAKS_WITH]->(greedo),
  (greedo)-[:SPEAKS_WITH]->(wald),
  (kitster)-[:SPEAKS_WITH]->(shmi),
  (anakin)-[:SPEAKS_WITH]->(captain_panaka),
  (anakin)-[:SPEAKS_WITH]->(ric_olie),
  (emperor)-[:SPEAKS_WITH]->(valorum),
  (emperor)-[:SPEAKS_WITH]->(jar_jar),
  (emperor)-[:SPEAKS_WITH]->(qui_gon),
  (jar_jar)-[:SPEAKS_WITH]->(valorum),
  (qui_gon)-[:SPEAKS_WITH]->(valorum),
  (mace_windu)-[:SPEAKS_WITH]->(qui_gon),
  (ki_adi_mundi)-[:SPEAKS_WITH]->(qui_gon),
  (qui_gon)-[:SPEAKS_WITH]->(yoda),
  (qui_gon)-[:SPEAKS_WITH]->(rabe),
  (ki_adi_mundi)-[:SPEAKS_WITH]->(mace_windu),
  (mace_windu)-[:SPEAKS_WITH]->(yoda),
  (anakin)-[:SPEAKS_WITH]->(mace_windu),
  (mace_windu)-[:SPEAKS_WITH]->(rabe),
  (ki_adi_mundi)-[:SPEAKS_WITH]->(yoda),
  (anakin)-[:SPEAKS_WITH]->(ki_adi_mundi),
  (ki_adi_mundi)-[:SPEAKS_WITH]->(rabe),
  (anakin)-[:SPEAKS_WITH]->(yoda),
  (rabe)-[:SPEAKS_WITH]->(yoda),
  (anakin)-[:SPEAKS_WITH]->(rabe),
  (bail_organa)-[:SPEAKS_WITH]->(emperor),
  (bail_organa)-[:SPEAKS_WITH]->(valorum),
  (obi_wan)-[:SPEAKS_WITH]->(yoda),
  (mace_windu)-[:SPEAKS_WITH]->(obi_wan),
  (ki_adi_mundi)-[:SPEAKS_WITH]->(obi_wan),
  (boss_nass)-[:SPEAKS_WITH]->(padme),
  (darth_maul)-[:SPEAKS_WITH]->(nute_gunray),
  (anakin)-[:SPEAKS_WITH]->(boss_nass),
  (boss_nass)-[:SPEAKS_WITH]->(captain_panaka),
  (obi_wan)-[:SPEAKS_WITH]->(padme),
  (emperor)-[:SPEAKS_WITH]->(general_ceel),
  (general_ceel)-[:SPEAKS_WITH]->(nute_gunray),
  (darth_maul)-[:SPEAKS_WITH]->(general_ceel),
  (darth_maul)-[:SPEAKS_WITH]->(rune),
  (bravo_two)-[:SPEAKS_WITH]->(ric_olie),
  (anakin)-[:SPEAKS_WITH]->(bravo_two),
  (general_ceel)-[:SPEAKS_WITH]->(jar_jar),
  (nute_gunray)-[:SPEAKS_WITH]->(padme),
  (dofine)-[:SPEAKS_WITH]->(tey_how),
  (bravo_three)-[:SPEAKS_WITH]->(bravo_two),
  (bravo_three)-[:SPEAKS_WITH]->(ric_olie),
  (anakin)-[:SPEAKS_WITH]->(bravo_three),
  (emperor)-[:SPEAKS_WITH]->(padme),
  (emperor)-[:SPEAKS_WITH]->(senator_ask_aak),
  (emperor)-[:SPEAKS_WITH]->(orn_free_taa),
  (orn_free_taa)-[:SPEAKS_WITH]->(senator_ask_aak),
  (emperor)-[:SPEAKS_WITH]->(mace_windu),
  (emperor)-[:SPEAKS_WITH]->(yoda),
  (emperor)-[:SPEAKS_WITH]->(ki_adi_mundi),
  (bail_organa)-[:SPEAKS_WITH]->(mace_windu),
  (bail_organa)-[:SPEAKS_WITH]->(yoda),
  (bail_organa)-[:SPEAKS_WITH]->(ki_adi_mundi),
  (captain_typho)-[:SPEAKS_WITH]->(jar_jar),
  (captain_typho)-[:SPEAKS_WITH]->(obi_wan),
  (anakin)-[:SPEAKS_WITH]->(captain_typho),
  (obi_wan)-[:SPEAKS_WITH]->(pk_4),
  (anakin)-[:SPEAKS_WITH]->(sio_bibble),
  (padme)-[:SPEAKS_WITH]->(sola),
  (anakin)-[:SPEAKS_WITH]->(sola),
  (jobal)-[:SPEAKS_WITH]->(sola),
  (ruwee)-[:SPEAKS_WITH]->(sola),
  (jobal)-[:SPEAKS_WITH]->(padme),
  (padme)-[:SPEAKS_WITH]->(ruwee),
  (anakin)-[:SPEAKS_WITH]->(jobal),
  (anakin)-[:SPEAKS_WITH]->(ruwee),
  (jobal)-[:SPEAKS_WITH]->(ruwee),
  (obi_wan)-[:SPEAKS_WITH]->(taun_we),
  (lama_su)-[:SPEAKS_WITH]->(taun_we),
  (lama_su)-[:SPEAKS_WITH]->(obi_wan),
  (boba_fett)-[:SPEAKS_WITH]->(taun_we),
  (boba_fett)-[:SPEAKS_WITH]->(jango_fett),
  (boba_fett)-[:SPEAKS_WITH]->(obi_wan),
  (jango_fett)-[:SPEAKS_WITH]->(taun_we),
  (jango_fett)-[:SPEAKS_WITH]->(obi_wan),
  (c_3po)-[:SPEAKS_WITH]->(owen),
  (beru)-[:SPEAKS_WITH]->(c_3po),
  (c_3po)-[:SPEAKS_WITH]->(cliegg),
  (anakin)-[:SPEAKS_WITH]->(owen),
  (anakin)-[:SPEAKS_WITH]->(beru),
  (anakin)-[:SPEAKS_WITH]->(cliegg),
  (beru)-[:SPEAKS_WITH]->(owen),
  (owen)-[:SPEAKS_WITH]->(padme),
  (cliegg)-[:SPEAKS_WITH]->(owen),
  (beru)-[:SPEAKS_WITH]->(padme),
  (beru)-[:SPEAKS_WITH]->(cliegg),
  (cliegg)-[:SPEAKS_WITH]->(padme),
  (bail_organa)-[:SPEAKS_WITH]->(obi_wan),
  (emperor)-[:SPEAKS_WITH]->(obi_wan),
  (obi_wan)-[:SPEAKS_WITH]->(senator_ask_aak),
  (bail_organa)-[:SPEAKS_WITH]->(senator_ask_aak),
  (bail_organa)-[:SPEAKS_WITH]->(jar_jar),
  (senator_ask_aak)-[:SPEAKS_WITH]->(yoda),
  (jar_jar)-[:SPEAKS_WITH]->(yoda),
  (mace_windu)-[:SPEAKS_WITH]->(senator_ask_aak),
  (jar_jar)-[:SPEAKS_WITH]->(mace_windu),
  (jar_jar)-[:SPEAKS_WITH]->(senator_ask_aak),
  (mace_windu)-[:SPEAKS_WITH]->(padme),
  (jar_jar)-[:SPEAKS_WITH]->(orn_free_taa),
  (count_dooku)-[:SPEAKS_WITH]->(padme),
  (count_dooku)-[:SPEAKS_WITH]->(jango_fett),
  (poggle)-[:SPEAKS_WITH]->(sun_rit),
  (nute_gunray)-[:SPEAKS_WITH]->(sun_rit),
  (nute_gunray)-[:SPEAKS_WITH]->(poggle),
  (obi_wan)-[:SPEAKS_WITH]->(sun_rit),
  (obi_wan)-[:SPEAKS_WITH]->(poggle),
  (nute_gunray)-[:SPEAKS_WITH]->(obi_wan),
  (count_dooku)-[:SPEAKS_WITH]->(obi_wan),
  (anakin)-[:SPEAKS_WITH]->(sun_rit),
  (anakin)-[:SPEAKS_WITH]->(poggle),
  (anakin)-[:SPEAKS_WITH]->(nute_gunray),
  (anakin)-[:SPEAKS_WITH]->(count_dooku),
  (padme)-[:SPEAKS_WITH]->(sun_rit),
  (count_dooku)-[:SPEAKS_WITH]->(sun_rit),
  (padme)-[:SPEAKS_WITH]->(poggle),
  (count_dooku)-[:SPEAKS_WITH]->(poggle),
  (count_dooku)-[:SPEAKS_WITH]->(nute_gunray),
  (count_dooku)-[:SPEAKS_WITH]->(mace_windu),
  (ki_adi_mundi)-[:SPEAKS_WITH]->(plo_koon),
  (count_dooku)-[:SPEAKS_WITH]->(yoda),
  (padme)-[:SPEAKS_WITH]->(yoda),
  (count_dooku)-[:SPEAKS_WITH]->(emperor),
  (obi_wan)-[:SPEAKS_WITH]->(odd_ball),
  (anakin)-[:SPEAKS_WITH]->(odd_ball),
  (anakin)-[:SPEAKS_WITH]->(emperor),
  (general_grievous)-[:SPEAKS_WITH]->(obi_wan),
  (anakin)-[:SPEAKS_WITH]->(general_grievous),
  (anakin)-[:SPEAKS_WITH]->(bail_organa),
  (c_3po)-[:SPEAKS_WITH]->(obi_wan),
  (c_3po)-[:SPEAKS_WITH]->(emperor),
  (bail_organa)-[:SPEAKS_WITH]->(c_3po),
  (bail_organa)-[:SPEAKS_WITH]->(padme),
  (bail_organa)-[:SPEAKS_WITH]->(fang_zar),
  (bail_organa)-[:SPEAKS_WITH]->(mon_mothma),
  (bail_organa)-[:SPEAKS_WITH]->(giddean_danu),
  (fang_zar)-[:SPEAKS_WITH]->(padme),
  (fang_zar)-[:SPEAKS_WITH]->(mon_mothma),
  (fang_zar)-[:SPEAKS_WITH]->(giddean_danu),
  (mon_mothma)-[:SPEAKS_WITH]->(padme),
  (giddean_danu)-[:SPEAKS_WITH]->(padme),
  (giddean_danu)-[:SPEAKS_WITH]->(mon_mothma),
  (captain_typho)-[:SPEAKS_WITH]->(padme),
  (c_3po)-[:SPEAKS_WITH]->(captain_typho),
  (clone_commander_gree)-[:SPEAKS_WITH]->(yoda),
  (clone_commander_cody)-[:SPEAKS_WITH]->(obi_wan),
  (obi_wan)-[:SPEAKS_WITH]->(tion_medon),
  (general_grievous)-[:SPEAKS_WITH]->(nute_gunray),
  (anakin)-[:SPEAKS_WITH]->(clone_commander_cody),
  (clone_commander_cody)-[:SPEAKS_WITH]->(mace_windu),
  (clone_commander_cody)-[:SPEAKS_WITH]->(yoda),
  (bail_organa)-[:SPEAKS_WITH]->(captain_antilles),
  (bail_organa)-[:SPEAKS_WITH]->(qui_gon),
  (c_3po)-[:SPEAKS_WITH]->(yoda),
  (darth_vader)-[:SPEAKS_WITH]->(emperor),
  (c_3po)-[:SPEAKS_WITH]->(captain_antilles),
  (camie)-[:SPEAKS_WITH]->(luke),
  (biggs)-[:SPEAKS_WITH]->(camie),
  (biggs)-[:SPEAKS_WITH]->(luke),
  (darth_vader)-[:SPEAKS_WITH]->(leia),
  (beru)-[:SPEAKS_WITH]->(luke),
  (luke)-[:SPEAKS_WITH]->(owen),
  (c_3po)-[:SPEAKS_WITH]->(luke),
  (c_3po)-[:SPEAKS_WITH]->(leia),
  (leia)-[:SPEAKS_WITH]->(luke),
  (beru)-[:SPEAKS_WITH]->(leia),
  (luke)-[:SPEAKS_WITH]->(obi_wan),
  (leia)-[:SPEAKS_WITH]->(obi_wan),
  (motti)-[:SPEAKS_WITH]->(tarkin),
  (darth_vader)-[:SPEAKS_WITH]->(motti),
  (darth_vader)-[:SPEAKS_WITH]->(tarkin),
  (han)-[:SPEAKS_WITH]->(obi_wan),
  (han)-[:SPEAKS_WITH]->(luke),
  (greedo)-[:SPEAKS_WITH]->(han),
  (han)-[:SPEAKS_WITH]->(jabba),
  (c_3po)-[:SPEAKS_WITH]->(han),
  (leia)-[:SPEAKS_WITH]->(motti),
  (leia)-[:SPEAKS_WITH]->(tarkin),
  (han)-[:SPEAKS_WITH]->(leia),
  (darth_vader)-[:SPEAKS_WITH]->(obi_wan),
  (dodonna)-[:SPEAKS_WITH]->(gold_leader),
  (dodonna)-[:SPEAKS_WITH]->(wedge),
  (dodonna)-[:SPEAKS_WITH]->(luke),
  (gold_leader)-[:SPEAKS_WITH]->(wedge),
  (gold_leader)-[:SPEAKS_WITH]->(luke),
  (luke)-[:SPEAKS_WITH]->(wedge),
  (biggs)-[:SPEAKS_WITH]->(leia),
  (leia)-[:SPEAKS_WITH]->(red_leader),
  (luke)-[:SPEAKS_WITH]->(red_leader),
  (biggs)-[:SPEAKS_WITH]->(red_leader),
  (biggs)-[:SPEAKS_WITH]->(c_3po),
  (c_3po)-[:SPEAKS_WITH]->(red_leader),
  (red_leader)-[:SPEAKS_WITH]->(wedge),
  (gold_leader)-[:SPEAKS_WITH]->(red_leader),
  (biggs)-[:SPEAKS_WITH]->(wedge),
  (red_leader)-[:SPEAKS_WITH]->(red_ten),
  (biggs)-[:SPEAKS_WITH]->(gold_leader),
  (luke)-[:SPEAKS_WITH]->(red_ten),
  (han)-[:SPEAKS_WITH]->(rieekan),
  (leia)-[:SPEAKS_WITH]->(rieekan),
  (c_3po)-[:SPEAKS_WITH]->(derlin),
  (han)-[:SPEAKS_WITH]->(zev),
  (c_3po)-[:SPEAKS_WITH]->(rieekan),
  (ozzel)-[:SPEAKS_WITH]->(piett),
  (darth_vader)-[:SPEAKS_WITH]->(piett),
  (darth_vader)-[:SPEAKS_WITH]->(ozzel),
  (derlin)-[:SPEAKS_WITH]->(leia),
  (dack)-[:SPEAKS_WITH]->(luke),
  (janson)-[:SPEAKS_WITH]->(wedge),
  (luke)-[:SPEAKS_WITH]->(zev),
  (darth_vader)-[:SPEAKS_WITH]->(needa),
  (needa)-[:SPEAKS_WITH]->(piett),
  (luke)-[:SPEAKS_WITH]->(yoda),
  (boba_fett)-[:SPEAKS_WITH]->(piett),
  (boba_fett)-[:SPEAKS_WITH]->(darth_vader),
  (han)-[:SPEAKS_WITH]->(lando),
  (lando)-[:SPEAKS_WITH]->(leia),
  (c_3po)-[:SPEAKS_WITH]->(lando),
  (darth_vader)-[:SPEAKS_WITH]->(lando),
  (darth_vader)-[:SPEAKS_WITH]->(han),
  (boba_fett)-[:SPEAKS_WITH]->(lando),
  (boba_fett)-[:SPEAKS_WITH]->(c_3po),
  (c_3po)-[:SPEAKS_WITH]->(darth_vader),
  (boba_fett)-[:SPEAKS_WITH]->(han),
  (boba_fett)-[:SPEAKS_WITH]->(leia),
  (darth_vader)-[:SPEAKS_WITH]->(luke),
  (lando)-[:SPEAKS_WITH]->(luke),
  (darth_vader)-[:SPEAKS_WITH]->(jerjerrod),
  (bib_fortuna)-[:SPEAKS_WITH]->(c_3po),
  (c_3po)-[:SPEAKS_WITH]->(jabba),
  (jabba)-[:SPEAKS_WITH]->(luke),
  (boushh)-[:SPEAKS_WITH]->(jabba),
  (boushh)-[:SPEAKS_WITH]->(c_3po),
  (boushh)-[:SPEAKS_WITH]->(han),
  (boushh)-[:SPEAKS_WITH]->(leia),
  (bib_fortuna)-[:SPEAKS_WITH]->(luke),
  (bib_fortuna)-[:SPEAKS_WITH]->(jabba),
  (han)-[:SPEAKS_WITH]->(mon_mothma),
  (admiral_ackbar)-[:SPEAKS_WITH]->(han),
  (lando)-[:SPEAKS_WITH]->(mon_mothma),
  (admiral_ackbar)-[:SPEAKS_WITH]->(lando),
  (admiral_ackbar)-[:SPEAKS_WITH]->(mon_mothma),
  (c_3po)-[:SPEAKS_WITH]->(mon_mothma),
  (leia)-[:SPEAKS_WITH]->(mon_mothma),
  (luke)-[:SPEAKS_WITH]->(mon_mothma),
  (admiral_ackbar)-[:SPEAKS_WITH]->(c_3po),
  (admiral_ackbar)-[:SPEAKS_WITH]->(leia),
  (admiral_ackbar)-[:SPEAKS_WITH]->(luke),
  (emperor)-[:SPEAKS_WITH]->(luke),
  (lando)-[:SPEAKS_WITH]->(wedge),
  (admiral_ackbar)-[:SPEAKS_WITH]->(wedge),
  (anakin)-[:SPEAKS_WITH]->(darth_vader),
  (anakin)-[:SPEAKS_WITH]->(luke),
  (lor_san_tekka)-[:SPEAKS_WITH]->(poe),
  (kylo_ren)-[:SPEAKS_WITH]->(lor_san_tekka),
  (kylo_ren)-[:SPEAKS_WITH]->(poe),
  (captain_phasma)-[:SPEAKS_WITH]->(kylo_ren),
  (captain_phasma)-[:SPEAKS_WITH]->(lor_san_tekka),
  (captain_phasma)-[:SPEAKS_WITH]->(poe),
  (captain_phasma)-[:SPEAKS_WITH]->(finn),
  (general_hux)-[:SPEAKS_WITH]->(kylo_ren),
  (rey)-[:SPEAKS_WITH]->(unkar_plutt),
  (finn)-[:SPEAKS_WITH]->(poe),
  (general_hux)-[:SPEAKS_WITH]->(lieutenant_mitaka),
  (kylo_ren)-[:SPEAKS_WITH]->(lieutenant_mitaka),
  (captain_phasma)-[:SPEAKS_WITH]->(general_hux),
  (finn)-[:SPEAKS_WITH]->(rey),
  (han)-[:SPEAKS_WITH]->(rey),
  (finn)-[:SPEAKS_WITH]->(han),
  (bala_tik)-[:SPEAKS_WITH]->(han),
  (bala_tik)-[:SPEAKS_WITH]->(rey),
  (bala_tik)-[:SPEAKS_WITH]->(finn),
  (general_hux)-[:SPEAKS_WITH]->(snoke),
  (kylo_ren)-[:SPEAKS_WITH]->(snoke),
  (han)-[:SPEAKS_WITH]->(maz),
  (finn)-[:SPEAKS_WITH]->(maz),
  (maz)-[:SPEAKS_WITH]->(rey),
  (han)-[:SPEAKS_WITH]->(poe),
  (leia)-[:SPEAKS_WITH]->(poe),
  (finn)-[:SPEAKS_WITH]->(leia),
  (kylo_ren)-[:SPEAKS_WITH]->(rey),
  (poe)-[:SPEAKS_WITH]->(snap),
  (admiral_ackbar)-[:SPEAKS_WITH]->(poe),
  (c_3po)-[:SPEAKS_WITH]->(poe),
  (admiral_statura)-[:SPEAKS_WITH]->(poe),
  (han)-[:SPEAKS_WITH]->(snap),
  (admiral_ackbar)-[:SPEAKS_WITH]->(snap),
  (finn)-[:SPEAKS_WITH]->(snap),
  (leia)-[:SPEAKS_WITH]->(snap),
  (c_3po)-[:SPEAKS_WITH]->(snap),
  (admiral_statura)-[:SPEAKS_WITH]->(snap),
  (admiral_statura)-[:SPEAKS_WITH]->(han),
  (admiral_ackbar)-[:SPEAKS_WITH]->(finn),
  (admiral_ackbar)-[:SPEAKS_WITH]->(admiral_statura),
  (c_3po)-[:SPEAKS_WITH]->(finn),
  (admiral_statura)-[:SPEAKS_WITH]->(finn),
  (admiral_statura)-[:SPEAKS_WITH]->(leia),
  (admiral_statura)-[:SPEAKS_WITH]->(c_3po),
  (captain_phasma)-[:SPEAKS_WITH]->(han),
  (colonel_datoo)-[:SPEAKS_WITH]->(general_hux),
  (ello_asty)-[:SPEAKS_WITH]->(poe),
  (jess)-[:SPEAKS_WITH]->(snap),
  (han)-[:SPEAKS_WITH]->(kylo_ren),
  (finn)-[:SPEAKS_WITH]->(kylo_ren),
  (jess)-[:SPEAKS_WITH]->(niv_lek),
  (niv_lek)-[:SPEAKS_WITH]->(yolo_ziff),
  (niv_lek)-[:SPEAKS_WITH]->(poe),
  (ello_asty)-[:SPEAKS_WITH]->(niv_lek),
  (jess)-[:SPEAKS_WITH]->(yolo_ziff),
  (jess)-[:SPEAKS_WITH]->(poe),
  (ello_asty)-[:SPEAKS_WITH]->(jess),
  (poe)-[:SPEAKS_WITH]->(yolo_ziff),
  (ello_asty)-[:SPEAKS_WITH]->(yolo_ziff),
  (leia)-[:SPEAKS_WITH]->(rey),
  (luke)-[:SPEAKS_WITH]->(rey),
  (r2_d2)-[:APPEARS_IN]->(Episode1),
  (r2_d2)-[:APPEARS_IN]->(Episode2),
  (r2_d2)-[:APPEARS_IN]->(Episode3),
  (r2_d2)-[:APPEARS_IN]->(Episode4),
  (r2_d2)-[:APPEARS_IN]->(Episode5),
  (r2_d2)-[:APPEARS_IN]->(Episode6),
  (r2_d2)-[:APPEARS_IN]->(Episode7),
  (chewbacca)-[:APPEARS_IN]->(Episode4),
  (chewbacca)-[:APPEARS_IN]->(Episode5),
  (chewbacca)-[:APPEARS_IN]->(Episode6),
  (chewbacca)-[:APPEARS_IN]->(Episode7),
  (bb_8)-[:APPEARS_IN]->(Episode7),
  (qui_gon)-[:APPEARS_IN]->(Episode1),
  (qui_gon)-[:APPEARS_IN]->(Episode3),
  (nute_gunray)-[:APPEARS_IN]->(Episode1),
  (nute_gunray)-[:APPEARS_IN]->(Episode2),
  (nute_gunray)-[:APPEARS_IN]->(Episode3),
  (pk_4)-[:APPEARS_IN]->(Episode1),
  (pk_4)-[:APPEARS_IN]->(Episode2),
  (tc_14)-[:APPEARS_IN]->(Episode1),
  (obi_wan)-[:APPEARS_IN]->(Episode1),
  (obi_wan)-[:APPEARS_IN]->(Episode2),
  (obi_wan)-[:APPEARS_IN]->(Episode3),
  (obi_wan)-[:APPEARS_IN]->(Episode4),
  (obi_wan)-[:APPEARS_IN]->(Episode5),
  (obi_wan)-[:APPEARS_IN]->(Episode6),
  (dofine)-[:APPEARS_IN]->(Episode1),
  (rune)-[:APPEARS_IN]->(Episode1),
  (tey_how)-[:APPEARS_IN]->(Episode1),
  (emperor)-[:APPEARS_IN]->(Episode1),
  (emperor)-[:APPEARS_IN]->(Episode2),
  (emperor)-[:APPEARS_IN]->(Episode3),
  (emperor)-[:APPEARS_IN]->(Episode5),
  (emperor)-[:APPEARS_IN]->(Episode6),
  (captain_panaka)-[:APPEARS_IN]->(Episode1),
  (sio_bibble)-[:APPEARS_IN]->(Episode1),
  (sio_bibble)-[:APPEARS_IN]->(Episode2),
  (jar_jar)-[:APPEARS_IN]->(Episode1),
  (jar_jar)-[:APPEARS_IN]->(Episode2),
  (jar_jar)-[:APPEARS_IN]->(Episode3),
  (tarpals)-[:APPEARS_IN]->(Episode1),
  (boss_nass)-[:APPEARS_IN]->(Episode1),
  (padme)-[:APPEARS_IN]->(Episode1),
  (padme)-[:APPEARS_IN]->(Episode2),
  (padme)-[:APPEARS_IN]->(Episode3),
  (ric_olie)-[:APPEARS_IN]->(Episode1),
  (watto)-[:APPEARS_IN]->(Episode1),
  (watto)-[:APPEARS_IN]->(Episode2),
  (anakin)-[:APPEARS_IN]->(Episode1),
  (anakin)-[:APPEARS_IN]->(Episode2),
  (anakin)-[:APPEARS_IN]->(Episode3),
  (anakin)-[:APPEARS_IN]->(Episode6),
  (sebulba)-[:APPEARS_IN]->(Episode1),
  (jira)-[:APPEARS_IN]->(Episode1),
  (shmi)-[:APPEARS_IN]->(Episode1),
  (shmi)-[:APPEARS_IN]->(Episode2),
  (c_3po)-[:APPEARS_IN]->(Episode1),
  (c_3po)-[:APPEARS_IN]->(Episode2),
  (c_3po)-[:APPEARS_IN]->(Episode3),
  (c_3po)-[:APPEARS_IN]->(Episode4),
  (c_3po)-[:APPEARS_IN]->(Episode5),
  (c_3po)-[:APPEARS_IN]->(Episode6),
  (c_3po)-[:APPEARS_IN]->(Episode7),
  (darth_maul)-[:APPEARS_IN]->(Episode1),
  (kitster)-[:APPEARS_IN]->(Episode1),
  (wald)-[:APPEARS_IN]->(Episode1),
  (fode_beed)-[:APPEARS_IN]->(Episode1),
  (jabba)-[:APPEARS_IN]->(Episode1),
  (jabba)-[:APPEARS_IN]->(Episode4),
  (jabba)-[:APPEARS_IN]->(Episode6),
  (greedo)-[:APPEARS_IN]->(Episode1),
  (greedo)-[:APPEARS_IN]->(Episode4),
  (valorum)-[:APPEARS_IN]->(Episode1),
  (mace_windu)-[:APPEARS_IN]->(Episode1),
  (mace_windu)-[:APPEARS_IN]->(Episode2),
  (mace_windu)-[:APPEARS_IN]->(Episode3),
  (ki_adi_mundi)-[:APPEARS_IN]->(Episode1),
  (ki_adi_mundi)-[:APPEARS_IN]->(Episode2),
  (yoda)-[:APPEARS_IN]->(Episode1),
  (yoda)-[:APPEARS_IN]->(Episode2),
  (yoda)-[:APPEARS_IN]->(Episode3),
  (yoda)-[:APPEARS_IN]->(Episode5),
  (yoda)-[:APPEARS_IN]->(Episode6),
  (rabe)-[:APPEARS_IN]->(Episode1),
  (bail_organa)-[:APPEARS_IN]->(Episode1),
  (bail_organa)-[:APPEARS_IN]->(Episode2),
  (bail_organa)-[:APPEARS_IN]->(Episode3),
  (general_ceel)-[:APPEARS_IN]->(Episode1),
  (bravo_two)-[:APPEARS_IN]->(Episode1),
  (bravo_three)-[:APPEARS_IN]->(Episode1),
  (captain_typho)-[:APPEARS_IN]->(Episode2),
  (captain_typho)-[:APPEARS_IN]->(Episode3),
  (senator_ask_aak)-[:APPEARS_IN]->(Episode2),
  (orn_free_taa)-[:APPEARS_IN]->(Episode2),
  (sola)-[:APPEARS_IN]->(Episode2),
  (jobal)-[:APPEARS_IN]->(Episode2),
  (ruwee)-[:APPEARS_IN]->(Episode2),
  (taun_we)-[:APPEARS_IN]->(Episode2),
  (lama_su)-[:APPEARS_IN]->(Episode2),
  (boba_fett)-[:APPEARS_IN]->(Episode2),
  (boba_fett)-[:APPEARS_IN]->(Episode5),
  (jango_fett)-[:APPEARS_IN]->(Episode2),
  (owen)-[:APPEARS_IN]->(Episode2),
  (owen)-[:APPEARS_IN]->(Episode4),
  (beru)-[:APPEARS_IN]->(Episode2),
  (beru)-[:APPEARS_IN]->(Episode4),
  (cliegg)-[:APPEARS_IN]->(Episode2),
  (count_dooku)-[:APPEARS_IN]->(Episode2),
  (count_dooku)-[:APPEARS_IN]->(Episode3),
  (sun_rit)-[:APPEARS_IN]->(Episode2),
  (poggle)-[:APPEARS_IN]->(Episode2),
  (plo_koon)-[:APPEARS_IN]->(Episode2),
  (plo_koon)-[:APPEARS_IN]->(Episode3),
  (odd_ball)-[:APPEARS_IN]->(Episode3),
  (general_grievous)-[:APPEARS_IN]->(Episode3),
  (fang_zar)-[:APPEARS_IN]->(Episode3),
  (mon_mothma)-[:APPEARS_IN]->(Episode3),
  (mon_mothma)-[:APPEARS_IN]->(Episode6),
  (giddean_danu)-[:APPEARS_IN]->(Episode3),
  (clone_commander_gree)-[:APPEARS_IN]->(Episode3),
  (clone_commander_cody)-[:APPEARS_IN]->(Episode3),
  (tion_medon)-[:APPEARS_IN]->(Episode3),
  (captain_antilles)-[:APPEARS_IN]->(Episode3),
  (darth_vader)-[:APPEARS_IN]->(Episode3),
  (darth_vader)-[:APPEARS_IN]->(Episode4),
  (darth_vader)-[:APPEARS_IN]->(Episode5),
  (darth_vader)-[:APPEARS_IN]->(Episode6),
  (luke)-[:APPEARS_IN]->(Episode4),
  (luke)-[:APPEARS_IN]->(Episode5),
  (luke)-[:APPEARS_IN]->(Episode6),
  (luke)-[:APPEARS_IN]->(Episode7),
  (camie)-[:APPEARS_IN]->(Episode4),
  (biggs)-[:APPEARS_IN]->(Episode4),
  (leia)-[:APPEARS_IN]->(Episode4),
  (leia)-[:APPEARS_IN]->(Episode5),
  (leia)-[:APPEARS_IN]->(Episode6),
  (leia)-[:APPEARS_IN]->(Episode7),
  (motti)-[:APPEARS_IN]->(Episode4),
  (tarkin)-[:APPEARS_IN]->(Episode4),
  (han)-[:APPEARS_IN]->(Episode4),
  (han)-[:APPEARS_IN]->(Episode5),
  (han)-[:APPEARS_IN]->(Episode6),
  (han)-[:APPEARS_IN]->(Episode7),
  (dodonna)-[:APPEARS_IN]->(Episode4),
  (gold_leader)-[:APPEARS_IN]->(Episode4),
  (wedge)-[:APPEARS_IN]->(Episode4),
  (wedge)-[:APPEARS_IN]->(Episode5),
  (wedge)-[:APPEARS_IN]->(Episode6),
  (red_leader)-[:APPEARS_IN]->(Episode4),
  (red_ten)-[:APPEARS_IN]->(Episode4),
  (gold_five)-[:APPEARS_IN]->(Episode4),
  (rieekan)-[:APPEARS_IN]->(Episode5),
  (derlin)-[:APPEARS_IN]->(Episode5),
  (zev)-[:APPEARS_IN]->(Episode5),
  (piett)-[:APPEARS_IN]->(Episode5),
  (piett)-[:APPEARS_IN]->(Episode6),
  (ozzel)-[:APPEARS_IN]->(Episode5),
  (dack)-[:APPEARS_IN]->(Episode5),
  (janson)-[:APPEARS_IN]->(Episode5),
  (needa)-[:APPEARS_IN]->(Episode5),
  (lando)-[:APPEARS_IN]->(Episode5),
  (lando)-[:APPEARS_IN]->(Episode6),
  (jerjerrod)-[:APPEARS_IN]->(Episode6),
  (bib_fortuna)-[:APPEARS_IN]->(Episode6),
  (boushh)-[:APPEARS_IN]->(Episode6),
  (admiral_ackbar)-[:APPEARS_IN]->(Episode6),
  (admiral_ackbar)-[:APPEARS_IN]->(Episode7),
  (lor_san_tekka)-[:APPEARS_IN]->(Episode7),
  (poe)-[:APPEARS_IN]->(Episode7),
  (kylo_ren)-[:APPEARS_IN]->(Episode7),
  (captain_phasma)-[:APPEARS_IN]->(Episode7),
  (finn)-[:APPEARS_IN]->(Episode7),
  (unkar_plutt)-[:APPEARS_IN]->(Episode7),
  (rey)-[:APPEARS_IN]->(Episode7),
  (general_hux)-[:APPEARS_IN]->(Episode7),
  (lieutenant_mitaka)-[:APPEARS_IN]->(Episode7),
  (bala_tik)-[:APPEARS_IN]->(Episode7),
  (snoke)-[:APPEARS_IN]->(Episode7),
  (maz)-[:APPEARS_IN]->(Episode7),
  (snap)-[:APPEARS_IN]->(Episode7),
  (admiral_statura)-[:APPEARS_IN]->(Episode7),
  (yolo_ziff)-[:APPEARS_IN]->(Episode7),
  (colonel_datoo)-[:APPEARS_IN]->(Episode7),
  (ello_asty)-[:APPEARS_IN]->(Episode7),
  (jess)-[:APPEARS_IN]->(Episode7),
  (niv_lek)-[:APPEARS_IN]->(Episode7)

Let’s look at some basic information from the database. The following query extracts all the films that are included in the network.

MATCH (m:Movie)
RETURN m.name

It seems that the database correctly contains all the seven episodes of Star Wars.

Simple network properties

Now we can start comparing the individual episodes based on their network properties. Is the original trilogy different from the prequels in terms of its social network? And how does The Force Awakens compare to the rest?

Let’s start with looking at the number of characters in each of the episodes. The following query extracts characters and returns their count aggregated by the movie that they appear in.

MATCH (m:Movie)<-[:APPEARS_IN]-(character)
RETURN m.name AS movie, count(*) AS characters
ORDER BY m.name;

We can immediately see some differences between the movies. The original trilogy (Episodes IV to VI) has the smallest number of characters. On the other hand, Episode I: The Phantom Menace has the largest number of characters, almost twice as many.

How many interactions are there between the characters? In this query, we extract all the links between two characters that both appear within the same movie and return their count for each movie. This is a simplification because I’m assuming that if two characters have link between them, then they interact in every movie where they both appear.

MATCH (m)<-[:APPEARS_IN]-(character)-[:SPEAKS_WITH]-(character2)-[:APPEARS_IN]->(m)
RETURN m.name AS movie, count(*) AS edges
ORDER BY m.name;

The results show a similar story, where the original trilogy has smaller number of links between the characters and their social networks are smaller. This corresponds to the tighter and more organized structure of the original films, which have smaller number of characters that bind the story together more.

Extracting social network relations

We can also use the database to extract the social network for each of the Star Wars movies. The following query extracts all the characters that appear in a specific episode and all the interactions between them. I’m using the Episode VII as an example:

MATCH network=(m)<-[:APPEARS_IN]-(character1)-[r]-(character2)-[:APPEARS_IN]->(m)
WHERE m.name='Episode VII: The Force Awakens'
RETURN character1, r, character2

We can see that there are parts of the network that correspond to the Dark side characters, including Snoke, General Hux and others. There is also a cluster of nodes that represent Resistance pilots, and who interact mainly with each other and with Poe. Let’s explore the network in more detail.

Importance of characters in the network

A basic measure of centrality in a social network is the degree centrality. This is simply the number of connections each node has in the network. In our Star Wars network, this corresponds to the total number of scenes where each character speaks. The following query extracts the number of SPEAKS_WITH relations for each character and returns the top 10 results.

MATCH (ch1)-[:SPEAKS_WITH]-(ch2)
RETURN ch1.name AS name, count(*) AS degree
ORDER BY count(*) DESC LIMIT 10;

This result is strongly affected by the large social networks of the prequels. Anakin comes out at the top as the person that speaks with the largest number of other characters. And because of the prequels, even Jar Jar made it into the top 10.

We can instead look at who has the largest degree within the individual films. This query extracts the characters that speak to each other and appear within the same film, and counts the number of such connections for each character. I’m using the orignal Episode IV: A New Hope in the example.

MATCH (m)<-[:APPEARS_IN]-(ch1)-[:SPEAKS_WITH]-(ch2)-[:APPEARS_IN]->(m)
WHERE m.name='Episode IV: A New Hope'
RETURN ch1.name AS name, count(*) AS degree
ORDER BY count(*) DESC LIMIT 5;

Here, Luke Skywalker is the most central character, followed by Leia and the droids.

We can also visualize the results and look at the specific interactions. For example, the following query extracts all the characters that interact with Luke Skywalker, together with the movies that they appear in.

MATCH path=(luke:Person {name: 'LUKE'})-[:SPEAKS_WITH]-(other)-[:APPEARS_IN]-(movie)
RETURN path

Here we can see that some of the characters cluster around specific episodes (these are the characters that appear only the specific episode). Other characters that interact with Luke across several other episodes appear as more central nodes in the network.

Summary

This GraphGist showed how to do simple social network analysis using the Star Wars social network that I extracted from the film scripts. We looked at how to extract and summarize sub-networks for individual episodes, and for specific characters. Overall, this was my first experience with Neo4j and it was very easy to create the network and extract interesting information from the database.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.