{ "cells": [ { "cell_type": "markdown", "id": "0e4847aa", "metadata": {}, "source": [ "# Network Measures\n", "\n", "Network structure can be quantified using different network measures. These parameters can be classified into two: centrality measures or node-level measures and network-level measures. \n", "\n", "## Centrality Measures (node-level measures)\n", "\n", "In network analysis, centrality measures identify the most \"important\" nodes inside a graph; in other words, how \"central\" a node is within the whole network. However, depending on how \"importance\" is defined, different nodes may be considered important. Because of its vast application and relatively easy computation, centrality is frequently the first measurement done in network analysis. Calculating it can help identify the influencers in a social media network or the disease super-spreaders during a pandemic. We discuss here some of the centrality measures used in network analysis.\n", "\n", "In weighted networks, we can also calculate the **node strength**, which is the sum of the weights of edges connected to the node. " ] }, { "cell_type": "markdown", "id": "1608f98f", "metadata": {}, "source": [ "**Degree centrality** is the number of edges connected to a given node. In a social network, this might mean the number of friends an individual has. It can be computed using the equation $\\frac{m}{n-1}$ , where m is the number of edges connected to a node and n is the total number of nodes. " ] }, { "cell_type": "markdown", "id": "edb5d0c3", "metadata": {}, "source": [ "### Example 1" ] }, { "cell_type": "markdown", "id": "1309c1d2", "metadata": {}, "source": [ "Let us consider the network of some of the characters from Noli Me Tangere shown in {numref}`noli`. \n", "\n", "```{figure} ./images/noli2.png\n", ":name: noli\n", ":width: 500px\n", "\n", "Network of characters from Noli Me Tangere\n", "```\n", "\n", "We can convert this to a networkx graph as shown here." ] }, { "cell_type": "code", "execution_count": 1, "id": "b782fcae", "metadata": { "ExecuteTime": { "end_time": "2022-04-01T13:10:07.338889Z", "start_time": "2022-04-01T13:10:05.873275Z" } }, "outputs": [ { "data": { "image/png": "iVBORw0KGgoAAAANSUhEUgAAAb4AAAEuCAYAAADx63eqAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/YYfK9AAAACXBIWXMAAAsTAAALEwEAmpwYAAArhElEQVR4nO3deXhU9cH+//dksjBh3xSVfZMoIEghpYCYR34EKUVKgQtZZNEKI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n1wAFwP9d+/4ocKykF+TluSuZiIgECN8qvvDwUjexYIz0qmKUX4ljOq3oFBGRYnyr+FxcbqzQIuApIAa4CEQC7Ut6QYsWbgomIiKBwreO8cXEQFqaywUuhcf4agHdgQTgFlf7slqN/YmIiBThWyewHzgAXbtW6qot19lsxonwZbxrg4iIBAffmups3964y0Jlr6dptULHjio9ERG5iW+N+MAt1+okMhIOHoRmzdyXS0REAoJvjfjAWOCyeLExVVkRNpvxepWeiIg44VuLWwoV3k/PDffjExERKcr3pjqLKrwD+759xsntru7AHh5uHNNbvlwjPRERKZFvF1+h1FTjgtNbtxqXIcvLM05Ob9HCOGVh/HgtZBERkTLxj+ITERFxE99b3CIiIuJBKj4REQkqKj4REQkqKj4REQkqKj4REQkqKj4REQkqKj4REQkqKj4REQkqKj4REQkqKj4REQkqKj4REQkqKj4REQkqKj4REQkqKj4REQkqKj4REQkqKj4REQkqKj4REQkqKj4REQkqKj4REQkqKj4REQkq/w9MkJ78DryTAwAAAABJRU5ErkJggg==\n", "text/plain": [ "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "import networkx as nx\n", "from alis.network_tools.plots import plot_degree_distribution\n", "from alis.network_tools.metrics import (\n", " degree_centrality, betweenness_centrality, closeness_centrality,\n", " eigenvector_centrality, average_degree\n", ")\n", "\n", "G = nx.Graph()\n", "G.add_nodes_from([\"A\",\"B\",\"C\",\"D\",\"E\",\"F\",\"G\"])\n", "G.add_edges_from([(\"A\",\"B\"),(\"A\",\"C\"),(\"A\",\"D\"),(\"C\",\"F\"),\n", "(\"D\",\"E\"),(\"D\",\"F\"),(\"D\",\"G\"),(\"E\",\"F\"),(\"F\",\"G\")])\n", "nx.draw(G, node_size=400, node_color='red', with_labels=True, font_weight='bold')" ] }, { "cell_type": "markdown", "id": "f4dc8fd0", "metadata": {}, "source": [ "And then calculate the degree centrality of each node." ] }, { "cell_type": "code", "execution_count": 2, "id": "1999a577", "metadata": { "ExecuteTime": { "end_time": "2022-04-01T13:10:07.342102Z", "start_time": "2022-04-01T13:10:07.340320Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Degree centrality:\n", "D:0.667 F:0.667 A:0.5 C:0.333 E:0.333 G:0.333 B:0.167 \n", "\n" ] } ], "source": [ "degree_centrality(G)" ] }, { "cell_type": "markdown", "id": "7e06c510", "metadata": {}, "source": [ "**Betweenness centrality** is the number of geodesic paths (shortest paths) that go through a given node. Nodes with high betweenness may be influential in a network because information tends to flow through them." ] }, { "cell_type": "code", "execution_count": 3, "id": "5d0f5fd5", "metadata": { "ExecuteTime": { "end_time": "2022-04-01T13:10:07.346513Z", "start_time": "2022-04-01T13:10:07.342755Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Betweenness centrality:\n", "A:0.367 D:0.367 F:0.2 C:0.0667 B:0.0 E:0.0 G:0.0 \n", "\n" ] } ], "source": [ "betweenness_centrality(G)" ] }, { "cell_type": "markdown", "id": "1c869afc", "metadata": {}, "source": [ "**Closeness centrality** is the number of steps required to access every other node from a given node. It is given by the equation inverse($\\frac{number of steps}{n-1}$)." ] }, { "cell_type": "code", "execution_count": 4, "id": "89b9aa21", "metadata": { "ExecuteTime": { "end_time": "2022-04-01T13:10:07.350891Z", "start_time": "2022-04-01T13:10:07.347983Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Closeness centrality:\n", "D:0.75 A:0.667 F:0.667 C:0.6 E:0.545 G:0.545 B:0.429 \n", "\n" ] } ], "source": [ "closeness_centrality(G)" ] }, { "cell_type": "markdown", "id": "1edecbe2", "metadata": {}, "source": [ "**Eigenvector centrality** is determined from the values of the first eigenvector of the graph adjacency matrix. The values are high for vertices that are connected to many other vertices that are, in turn, connected many others and so on." ] }, { "cell_type": "code", "execution_count": 5, "id": "615ea91f", "metadata": { "ExecuteTime": { "end_time": "2022-04-01T13:10:07.355693Z", "start_time": "2022-04-01T13:10:07.352286Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Eigenvector centrality:\n", "D:0.529 F:0.522 E:0.358 G:0.358 A:0.314 C:0.285 B:0.107 \n", "\n" ] } ], "source": [ "eigenvector_centrality(G)" ] }, { "cell_type": "markdown", "id": "e8ad5425", "metadata": {}, "source": [ "{numref}`centrality` illustrates the various centrality measures in a sample graph.\n", "\n", "```{figure} ./images/centrality1.png\n", ":name: centrality\n", ":width: 500px\n", "\n", "Illustration of various centrality measures\n", "```\n", "\n" ] }, { "cell_type": "markdown", "id": "b5f46735", "metadata": {}, "source": [ "### Network-level Measures\n", "\n", "The network measures tell us about the structure of the graph. Presented here are some of the network that are often calculated.\n", "\n", "1. Network size - number of nodes.\n", "2. Density - number of edges that exist / number of possible edges. If n is the number of nodes and m is the number of edges then density = $\\frac{2m}{n(n-1)}$ for an undirected graph and density = $\\frac{m}{n(n-1)}$ for a directed graph.\n", "3. Degree distribution - statistical distribution of node degrees in a network.\n", "4. Average path length - the fewest number of edges that you would have to go on to get from one node to another. \n", "5. Diameter - maximum path length.\n", "6. Clustering coefficient (Transitivity) - probability of two nodes that are connected to a common node being connected themselves. " ] }, { "cell_type": "code", "execution_count": 6, "id": "0f8ea9eb", "metadata": { "ExecuteTime": { "end_time": "2022-04-01T13:10:07.363330Z", "start_time": "2022-04-01T13:10:07.358346Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "number of nodes = 7\n", "density = 0.42857142857142855\n", "average path length = 1.7142857142857142\n", "diameter = 3\n", "average_degree = 2.5714285714285716\n", "average clustering coefficient = 0.38095238095238093\n" ] } ], "source": [ "print(\"number of nodes = \", G.number_of_nodes())\n", "print(\"density = \", nx.density(G))\n", "print(\"average path length = \", nx.average_shortest_path_length(G))\n", "print(\"diameter = \", nx.diameter(G))\n", "print(\"average_degree = \", average_degree(G))\n", "\n", "local_clustering_coefficient = nx.algorithms.cluster.clustering(G)\n", "av_local_clustering_coefficient = sum(local_clustering_coefficient.values())/len(local_clustering_coefficient)\n", "print(\"average clustering coefficient = \", av_local_clustering_coefficient)" ] }, { "cell_type": "code", "execution_count": 7, "id": "da2a0507", "metadata": { "ExecuteTime": { "end_time": "2022-04-01T13:10:07.442711Z", "start_time": "2022-04-01T13:10:07.370788Z" } }, "outputs": [ { "data": { "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYIAAAD4CAYAAADhNOGaAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/YYfK9AAAACXBIWXMAAAsTAAALEwEAmpwYAAAhfElEQVR4nO3deZQU9fnv8fcjEgFBURmvREQwV1xYHYcBAiIaWUQUIyhCoqKJqKgRl8QlBBe4cYmKC0bEwEWiIArJIAoJUUTFHRAEV9CD11F+AuNhGfbluX9Uz2QYumdqYKq7p/vzOqdOdXdVf+upKZhnvkt9y9wdERHJXgekOgAREUktJQIRkSynRCAikuWUCEREspwSgYhIljsw1QFUVaNGjbxZs2apDkOkar74IlifcEJq45CstXDhwrXunhNvW41LBM2aNWPBggWpDkOkarp1C9bz5qUyCsliZvZNom1qGhIRyXI1rkYgUiMNH57qCEQSUiIQSYazzkp1BCIJKRGIJMPixcG6XbtqLXbHjh0UFhaydevWai1Xaq46derQpEkTateuHfo7SgQiyTBsWLCu5s7iwsJCGjRoQLNmzTCzai1bah53p6ioiMLCQpo3bx76e+osFqnBtm7dyhFHHKEkIACYGUcccUSVa4iRJQIzq2NmH5jZEjP7xMzujrOPmdljZrbCzD42s9yo4hHJVEoCUta+/HuIsmloG3CmuxebWW1gvpnNdvf3yuxzNnB8bOkAPBlbi4hIkkSWCDx40EFx7G3t2FL+4Qd9gUmxfd8zs4Zm1tjdV0UVl0gma3bbK9Va3sr7zql0n1q1atG6dWt27NjBgQceyGWXXcawYcM44IDUtzzfddddPP300+Tk5LBp0yZat27NqFGjOPnkkwH47W9/y0033VT6vryJEyfSo0cPfvrTn8bdPmLECLp27cpZZ51VerNro0aNQsW2cuVK3nnnHQYNGgTAggULmDRpEo899tg+nOn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gR8r2KVGTG0R4jxqDHdf5e6LYq83Ap8R3EVeVtpfl5DnUSPEfs7Fsbe1Y0v50SNpf00g9LnUCGbWBDgH+FuCXar9mmRkIggh0dQWNVGnWHV4tpm1THUwYZhZM+AUgr/ayqpR16WC84Aacl1iTRCLgdXAf9y9xl6TEOcCNeO6PAL8AdidYHu1X5NsTQShpraoARYBx7p7W+BxoCC14VTOzOoD04Fh7r6h/OY4X0nL61LJedSY6+Luu9y9HcFd/flm1qrcLjXmmoQ4l7S/LmbWB1jt7gsr2i3OZ/t1TbI1EWTE1BbuvqGkOuzus4DaZtYoxWElZGa1CX55Pufu/4izS424LpWdR027LgDuvg6YB/Qqt6lGXJOyEp1LDbkunYHzzGwlwYzNZ5rZs+X2qfZrkq2JICOmtjCzo8yC6SzNLJ/gehalNqr4YnGOBz5z94cT7Jb21yXMedSU62JmOWbWMPa6LnAW8Hm53dL+mkC4c6kJ18Xdb3f3Ju7ejGBanrnu/utyu1X7NYly9tGUMbMpBCMEGplZIXAnQecRnpqpLfZJiPPoD1xjZjuBLcDFHhtWkIY6A5cAS2PtuAB3AE2hRl2XMOdRU65LY+AZCx4idQDwgru/bKmdBmZfhTmXmnJd9hL1NdEUEyIiWS5bm4ZERCRGiUBEJMspEYiIZDklAhGRLKdEICKS5ZQIRESynBKBiEiW+/+Jp7PmlnicHAAAAABJRU5ErkJggg==\n", "text/plain": [ "
" ] }, "metadata": { "needs_background": "light" }, "output_type": "display_data" } ], "source": [ "plot_degree_distribution(G)" ] }, { "cell_type": "markdown", "id": "10974dfe", "metadata": {}, "source": [ "## Exercise" ] }, { "cell_type": "markdown", "id": "4ab75744", "metadata": {}, "source": [ "Calculate the centrality and network measures of the graph in {numref}`centrality` . Determine the nodes with the highest centrality measures. " ] } ], "metadata": { "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.8.12" } }, "nbformat": 4, "nbformat_minor": 5 }