diff --git a/2022-round-1/dtekinoglu/Outreachy_Networkx.ipynb b/2022-round-1/dtekinoglu/Outreachy_Networkx.ipynb new file mode 100644 index 0000000..9228f69 --- /dev/null +++ b/2022-round-1/dtekinoglu/Outreachy_Networkx.ipynb @@ -0,0 +1,170 @@ +{ + "nbformat": 4, + "nbformat_minor": 0, + "metadata": { + "colab": { + "name": "Outreachy_Networkx.ipynb", + "provenance": [] + }, + "kernelspec": { + "name": "python3", + "display_name": "Python 3" + }, + "language_info": { + "name": "python" + } + }, + "cells": [ + { + "cell_type": "code", + "source": [ + "import matplotlib.pyplot as plt\n", + "import networkx as nx" + ], + "metadata": { + "id": "VJbhNxefTDYm" + }, + "execution_count": 1, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "ER_1 = nx.erdos_renyi_graph(100,0.3) #Creating an ER graph with N = 100 and p = 0.3\n", + "degreeCentralities = nx.degree_centrality(ER_1)\n", + "plt.hist(list(degreeCentralities.values())) # Plotting degree centrality distribution\n", + "plt.show()" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/", + "height": 265 + }, + "id": "vHDBMqcfP2lB", + "outputId": "7bb13aa7-189d-4310-817c-0091c5649013" + }, + "execution_count": 3, + "outputs": [ + { + "output_type": "display_data", + "data": { + "text/plain": [ + "
" + ], + "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXAAAAD4CAYAAAD1jb0+AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+WH4yJAAALmUlEQVR4nO3db4xld13H8c+XVjDyJ9mmk6ZBZJBUYzGRkgmSqAQCSpFIMSZGjGYfkKyYEjXwwPVPooEnRSP6hKg1EPpAQIwSmlTRpqESEjFOFaGUkEIpSlPoYkmAqEjL1wdzNx3G3c7s3Dtz97t9vZKbe+655879/XIn75w9Z87d6u4AMM+T1j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NeT/Pa6x3MczjPnB5N8T3dfl+SNSd5dVc9Y1xhXoaqelORtSd607rGsioA/5kBfDVBVL0/yW0le3d3fuJDXXmSWmW+6+4HF/X1J7kxy3VEOdgUu9DN6b5Kz/7KY+PkmS8x5cSjhPxfLd2XnmPD3HdE4V2W/+T49yQ8mubOq7k/yoiS3Lk5kzvyM130Q/mK5Zeeq1PuycwLj7AmQ5+3Z5rrs/CJfs2f9FUk+l50TmCcWy1ese05HON8TSZ6yWL4yyb05x8mii+l2wPles2v5p5JsL5afl28/wXVfBpzgWnLOG2fnmJ2Tgg9cCr/Te7a/M4+dxBz5GR/5txFO0ef5aoCqenN2fqlvzc4hhKcl+cuqSpJ/7+5Xd/fDVfWW7Hw/TJK8ubsfXsM0DmyZ+Sb5gSR/WlXfys6/4m7q7nvWMpEDOuB837D4F8c3k3wlycnFaz9ZVe9Lck+SR5Lc2N2PrmUiF2CZOSd5cZI3V9U3k3wryesvkd/p87125GfsUnqAoRwDBxhKwAGGEnCAoQQcYCgBBxhKwAGGEnCAof4PWcsZQ3mSTbwAAAAASUVORK5CYII=\n" + }, + "metadata": { + "needs_background": "light" + } + } + ] + }, + { + "cell_type": "code", + "source": [ + "ER_2 = nx.erdos_renyi_graph(100,0.6) #Creating an ER graph with N = 100 and p = 0.6\n", + "degreeCentralities = nx.degree_centrality(ER_2)\n", + "plt.hist(list(degreeCentralities.values())) # Plotting degree centrality distribution\n", + "plt.show()" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/", + "height": 266 + }, + "id": "P-M7utQ1S-9g", + "outputId": "aa22eadf-4db0-46c3-f889-de4365d5ba19" + }, + "execution_count": 4, + "outputs": [ + { + "output_type": "display_data", + "data": { + "text/plain": [ + "
" + ], + "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXAAAAD5CAYAAAA+0W6bAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZX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6h38PfHDYbY9Do/RLVR3o7p8DHgAunGSxYzDMHD0P3F1V/1dVPwC+z2LArcv5Zfl+W5xfWNk8Xc3Rwycr3XZ1pvhhwMksHsQ/h6MfBrz/GOs/wNEPMWeAk7rl93Z/CKdNq/ZJ9gxs6lm+Eni4jn4A8gMWP/zY0C0f1z2P2O8G4B3d8kbgaY7xYdHxcBuy3y3Arp6+fgS8Zx3P73L9Nje/w/bcrXc+sJ/u3JpubOJzPO0/jEtZ/C/ys8BfdGN/CfxBn3V7A/wq4AlgL/AI8PtrPbHj6hn4m6637wL3A+f3bPvHwDPd7Y/WupdJ9gv8OvB4N/44cN1a9zKmfsPiocEnu76uXufz27ffVud3mJ67xzcCO/psO9E59kxMSWqUZ2JKUqMMcElqlAEuSY0ywCWpUQa4JDXKAJekRhngktQoA1ySGvX/1erasKnFN3kAAAAASUVORK5CYII=\n" + }, + "metadata": { + "needs_background": "light" + } + } + ] + }, + { + "cell_type": "markdown", + "source": [ + "\n", + "# **Why does degree centrality distribution changes?**\n", + "Before commenting on why degree centrality distribution changes, let's first state what degree centrality means. The degree centrality for a node v is the fraction of nodes it is connected to. Thus, the more number of edges a node has, the higher its degree centrality is.(See: [Link](https://networkx.org/documentation/stable/reference/algorithms/generated/networkx.algorithms.centrality.degree_centrality.html))\n", + "\n", + "Given this definition, we can conclude that degree centrality for a node v can increase \n", + "\n", + "* if number of nodes in the graph decreases without any decrease in number of edges of v, or\n", + "* if number of edges of v increases without any increase in number of nodes in the graph. \n", + "\n", + "
\n", + "\n", + "**Observations:** Based on these information, let's analyze histograms of $ER_1$ and $ER_2$. We can easily see that both plots look like normal distribution pattern. It is expected since these are Erdos-Renyi graphs. However, degree centrality values are different in two histograms. (See x-axis values). The plot makes peak around 0.30 for $ER_1$ whereas this value is ~0.60 for $ER_2$. This means that the most common degree centrality value among nodes of $ER_1$ is 0.30 while it is 0.60 for nodes of $ER_2$. Moreover, the least degree centrality value in $ER_1$ is less than 0.10 whereas it is greater than 0.45 for $ER_2$.\n", + "\n", + "
\n", + "\n", + "**Reasoning:** Based on our observations, degree centrality values of nodes are higher for $ER_2$. In our implementation, both graphs has 100 nodes. However, in the first graph $ER_1$, edge probability is 0.3 whereas it is 0.6 in the second graph $ER_2$. Therefore, it is expected that number of edges for a node will be greater in the second graph. Since number of nodes is the same for both graphs, it is more probable for a node to has higher degree centrality in the second graph.\n" + ], + "metadata": { + "id": "LHH5kxmKTm_9" + } + }, + { + "cell_type": "code", + "source": [ + "BA = nx.barabasi_albert_graph(n= 100,m=3)\n", + "degreeCentralities = nx.degree_centrality(BA)\n", + "plt.hist(list(degreeCentralities.values())) # Plotting degree centrality distribution\n", + "plt.show()" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/", + "height": 265 + }, + "id": "HHAvcZtmTuuV", + "outputId": "6ab90828-1079-4662-efed-71ffffa277f1" + }, + "execution_count": 6, + "outputs": [ + { + "output_type": "display_data", + "data": { + "text/plain": [ + "
" + ], + "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXAAAAD4CAYAAAD1jb0+AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+WH4yJAAANtUlEQVR4nO3dX4xc51nH8e8Pu2mgQGM3i2XFJeuoplUqkQSW0FIoatxCaKC2RBSlArQqlixBQaAigaFXIC6cG0ouEJWVlLpSoQ6BYqsRBeMmICSadp24+eeWOMZRbTnxNk1oU1Aqpw8Xe9Is67Vndmdmx+/6+5FGc/68x+d5fFa/nLwzZ52qQpLUnu8ZdwGSpOUxwCWpUQa4JDXKAJekRhngktSotSt5siuvvLImJydX8pSS1LzDhw9/raomFm5f0QCfnJxkZmZmJU8pSc1L8vRi251CkaRGGeCS1CgDXJIaZYBLUqMMcElqlAEuSY0ywCWpUQa4JDXKAJekRq3ok5iDmNx131jOe2L3LWM5ryT14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si9JDVqtc+BS9KqZYBLUqMMcElqlAEuSY0ywCWpUQa4JDXKAJekRv0fHrQZA69QzCkAAAAASUVORK5CYII=\n" + }, + "metadata": { + "needs_background": "light" + } + } + ] + }, + { + "cell_type": "markdown", + "source": [ + "# **Why does the degree centrality distribution change between these 2 random graph generators?**\n", + "\n", + "When we compare degree centrality distributions of these 2 graph generators, we can easily see that Erdos-Renyi graph has a distribution looks like normal distribution. In Barabasi-Albert graph, the histogram shows that there is a small number of nodes with high degree centrality, and most of other nodes have very small degree values. I.e. A few nodes take most of edges. (It is Power Law Distribution).\n", + "\n", + "In order to understand the reason of this difference, we should understand how these two random graphs are generated.\n", + "\n", + "\n", + "* **Barabasi-Albert Graph:** Starts with $m$ nodes and no edge initially. New nodes are added to the graph one at a time. Each new node is connected to $m$ existing nodes with a probability that is proportional to the number of links that the existing nodes already have. I.e. New nodes will probably be attached to existing nodes with high degree. (See: [Link](https://networkx.org/documentation/networkx-1.9.1/reference/generated/networkx.generators.random_graphs.barabasi_albert_graph.html))\n", + "* **Erdos-Renyi Graph:** The probability of an edge existing between two nodes is the same for any pair of nodes in the graph.(See: [Link](https://networkx.org/documentation/stable/reference/generated/networkx.generators.random_graphs.erdos_renyi_graph.html))\n", + "\n", + "Considering these information, the difference makes sense. Barabasi-Albert has a few nodes with high degree values, and most of its nodes have very few edges. In Erdos-Renyi graph, degrees of most nodes are about the same as expected. \n" + ], + "metadata": { + "id": "8G9f1HywVAsr" + } + } + ] +} \ No newline at end of file diff --git a/2022-round-1/dtekinoglu/nx_tutorial_script.py b/2022-round-1/dtekinoglu/nx_tutorial_script.py new file mode 100644 index 0000000..eeb4601 --- /dev/null +++ b/2022-round-1/dtekinoglu/nx_tutorial_script.py @@ -0,0 +1,19 @@ +import networkx as nx + +G = nx.Graph() + +nodeList = [0,"Outreachy","Dilara","Networkx",("t1","t2"),3] # 6 Nodes in total + +G.add_nodes_from(nodeList) # Adding all nodes from nodeList + +edgeList = [(0,3),(0,("t1","t2")),("Dilara","Networkx"), + ("Outreachy",3),("Dilara","Outreachy"),("Networkx","Outreachy"), + ("Outreachy",0),("Networkx",("t1","t2"))] + +G.add_edges_from(edgeList) # Adding edges from edgeList + +nx.draw(G, with_labels=True, font_weight='bold') # Drawing the graph + +shortestPaths = dict(nx.all_pairs_shortest_path(G)) # Finding shortest paths for all pairs of nodes in G +for key in shortestPaths: + print(shortestPaths[key]) \ No newline at end of file