{ "cells": [ { "cell_type": "markdown", "id": "6102410e", "metadata": {}, "source": [ "# Facebook Network Analysis\n", "This notebook contains a social network analysis mainly executed with the library of NetworkX. In detail, the facebook circles (friends lists) of ten people will be examined and scrutinized in order to extract all kinds of valuable information. The dataset can be found at this link: [Stanford Facebook Dataset](http://snap.stanford.edu/data/ego-Facebook.html). Moreover, as known, a facebook network is undirected and has no weights because one user can become friends with another user just once. Looking at the dataset from a graph analysis perspective:\n", "* Each node represents an anonymized facebook user that belongs to one of those ten friends lists.\n", "* Each edge corresponds to the friendship of two facebook users that belong to this network. In other words, two users must become friends on facebook in order for them to be connected in the particular network.\n", "\n", "Note: Nodes $0, 107, 348, 414, 686, 698, 1684, 1912, 3437, 3980$ are the ones whose friends list will be examined. That means that they are in the spotlight of this analysis. Those nodes are considered the `spotlight nodes`" ] }, { "cell_type": "markdown", "id": "98129b2d", "metadata": {}, "source": [ "## Import packages" ] }, { "cell_type": "code", "execution_count": 1, "id": "90d6ae38", "metadata": {}, "outputs": [], "source": [ "import pandas as pd\n", "import numpy as np\n", "import networkx as nx\n", "import matplotlib.pyplot as plt\n", "from random import randint\n", "\n", "%matplotlib inline" ] }, { "cell_type": "markdown", "id": "0bad96df", "metadata": {}, "source": [ "## Analysis\n", "The edges are loaded from the `data` folder and saved in a dataframe. Each edge is a new row and for each edge there is a `start_node` and an `end_node` column" ] }, { "cell_type": "code", "execution_count": 2, "id": "b7478799", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " | start_node | \n", "end_node | \n", "
---|---|---|
0 | \n", "0 | \n", "1 | \n", "
1 | \n", "0 | \n", "2 | \n", "
2 | \n", "0 | \n", "3 | \n", "
3 | \n", "0 | \n", "4 | \n", "
4 | \n", "0 | \n", "5 | \n", "
... | \n", "... | \n", "... | \n", "
88229 | \n", "4026 | \n", "4030 | \n", "
88230 | \n", "4027 | \n", "4031 | \n", "
88231 | \n", "4027 | \n", "4032 | \n", "
88232 | \n", "4027 | \n", "4038 | \n", "
88233 | \n", "4031 | \n", "4038 | \n", "
88234 rows × 2 columns
\n", "