1
0
mirror of https://github.com/gsi-upm/sitc synced 2024-11-18 04:22:28 +00:00
sitc/sna/2a_Florentine_Families_Star_Wars.ipynb

375 lines
8.6 KiB
Plaintext
Raw Normal View History

2024-04-17 15:23:28 +00:00
{
"cells": [
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "skip"
}
},
"source": [
"![](images/EscUpmPolit_p.gif \"UPM\")"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "skip"
}
},
"source": [
"# Course Notes for Learning Intelligent Systems"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "skip"
}
},
"source": [
"Department of Telematic Engineering Systems, Universidad Politécnica de Madrid, © Carlos A. Iglesias"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "skip"
}
},
"source": [
"## [Introduction to Network Analysis](0_Intro_Network_Analysis.ipynb)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Exercise: Florentine families"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import networkx as nx\n",
"import warnings\n",
"warnings.simplefilter(action='ignore', category=FutureWarning)"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"G_florentine = nx.florentine_families_graph()"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"# Exercise: Star Wars"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"import networkx as nx\n",
"\n",
"# Taken from https://gist.github.com/codingthat/be03565bd97e789a3835b50235ad562f\n",
"# The original dataset is from:\n",
"# Gabasova, E. (2016). Star Wars social network. DOI: https://doi.org/10.5281/zenodo.1411479\n",
"# \n",
"# Simplified by Federico Albanese.\n",
"\n",
"characters = [\"R2-D2\",\n",
" \"CHEWBACCA\",\n",
" \"C-3PO\",\n",
" \"LUKE\",\n",
" \"DARTH VADER\",\n",
" \"CAMIE\",\n",
" \"BIGGS\",\n",
" \"LEIA\",\n",
" \"BERU\",\n",
" \"OWEN\",\n",
" \"OBI-WAN\",\n",
" \"MOTTI\",\n",
" \"TARKIN\",\n",
" \"HAN\",\n",
" \"DODONNA\",\n",
" \"GOLD LEADER\",\n",
" \"WEDGE\",\n",
" \"RED LEADER\",\n",
" \"RED TEN\"]\n",
"\n",
"\n",
"edges = [(\"CHEWBACCA\", \"R2-D2\"),\n",
" (\"C-3PO\",\"R2-D2\"),\n",
" (\"BERU\", \"R2-D2\"),\n",
" (\"LUKE\", \"R2-D2\"),\n",
" (\"OWEN\", \"R2-D2\"),\n",
" (\"OBI-WAN\", \"R2-D2\"),\n",
" (\"LEIA\", \"R2-D2\"),\n",
" (\"BIGGS\", \"R2-D2\"),\n",
" (\"HAN\", \"R2-D2\"),\n",
" (\"CHEWBACCA\", \"OBI-WAN\"),\n",
" (\"C-3PO\", \"CHEWBACCA\"),\n",
" (\"CHEWBACCA\", \"LUKE\"),\n",
" (\"CHEWBACCA\", \"HAN\"),\n",
" (\"CHEWBACCA\", \"LEIA\"),\n",
" (\"CAMIE\", \"LUKE\"),\n",
" (\"BIGGS\", \"CAMIE\"),\n",
" (\"BIGGS\", \"LUKE\"),\n",
" (\"DARTH VADER\", \"LEIA\"),\n",
" (\"BERU\", \"LUKE\"),\n",
" (\"BERU\", \"OWEN\"),\n",
" (\"BERU\", \"C-3PO\"),\n",
" (\"LUKE\", \"OWEN\"),\n",
" (\"C-3PO\", \"LUKE\"),\n",
" (\"C-3PO\", \"OWEN\"),\n",
" (\"C-3PO\", \"LEIA\"),\n",
" (\"LEIA\", \"LUKE\"),\n",
" (\"BERU\", \"LEIA\"),\n",
" (\"LUKE\", \"OBI-WAN\"),\n",
" (\"C-3PO\", \"OBI-WAN\"),\n",
" (\"LEIA\", \"OBI-WAN\"),\n",
" (\"MOTTI\", \"TARKIN\"),\n",
" (\"DARTH VADER\", \"MOTTI\"),\n",
" (\"DARTH VADER\", \"TARKIN\"),\n",
" (\"HAN\", \"OBI-WAN\"),\n",
" (\"HAN\", \"LUKE\"),\n",
" (\"C-3PO\", \"HAN\"),\n",
" (\"LEIA\", \"MOTT\"),\n",
" (\"LEIA\", \"TARKIN\"),\n",
" (\"HAN\", \"LEIA\"),\n",
" (\"DARTH VADER\", \"OBI-WAN\"),\n",
" (\"DODONNA\", \"GOLD LEADER\"),\n",
" (\"DODONNA\", \"WEDGE\"),\n",
" (\"DODONNA\", \"LUKE\"),\n",
" (\"GOLD LEADER\", \"WEDGE\"),\n",
" (\"GOLD LEADER\", \"LUKE\"),\n",
" (\"LUKE\", \"WEDGE\"),\n",
" (\"BIGGS\", \"LEIA\"),\n",
" (\"LEIA\", \"RED LEADER\"),\n",
" (\"LUKE\", \"RED LEADER\"),\n",
" (\"BIGGS\", \"RED LEADER\"),\n",
" (\"BIGGS\", \"C-3PO\"),\n",
" (\"C-3PO\", \"RED LEADER\"),\n",
" (\"RED LEADER\", \"WEDGE\"),\n",
" (\"GOLD LEADER\", \"RED LEADER\"),\n",
" (\"BIGGS\", \"WEDGE\"),\n",
" (\"RED LEADER\", \"RED TEN\"),\n",
" (\"BIGGS\", \"GOLD LEADER\"),\n",
" (\"LUKE\", \"RED TEN\")]\n",
"\n",
"G_starWars = nx.Graph()\n",
"\n",
"\n",
"G_starWars.add_nodes_from(characters)\n",
"G_starWars.add_edges_from(edges)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Exercise\n",
"In this exercise we are going to practice some of the concepts of the session.\n",
"\n",
"Answer the following questions using the object *G_starWars* and *G_florentine*."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Number of nodes"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Number of edges"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Get the list of nodes"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Get the list of edges"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Draw the graph\n",
"\n",
"Hint. Use different layouts (circular, spring, ...)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Think of interesting micro, meso and macro metrics"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Analyze ego networks of interesting nodes."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Analyze communities"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "skip"
}
},
"source": [
"## Licence"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "skip"
}
},
"source": [
"The notebook is freely licensed under under the [Creative Commons Attribution Share-Alike license](https://creativecommons.org/licenses/by/2.0/). \n",
"\n",
"© Carlos A. Iglesias, Universidad Politécnica de Madrid."
]
}
],
"metadata": {
"celltoolbar": "Slideshow",
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.7"
},
"latex_envs": {
"LaTeX_envs_menu_present": true,
"autocomplete": true,
"bibliofile": "biblio.bib",
"cite_by": "apalike",
"current_citInitial": 1,
"eqLabelWithNumbers": true,
"eqNumInitial": 1,
"hotkeys": {
"equation": "Ctrl-E",
"itemize": "Ctrl-I"
},
"labels_anchors": false,
"latex_user_defs": false,
"report_style_numbering": false,
"user_envs_cfg": false
}
},
"nbformat": 4,
"nbformat_minor": 4
}