{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "%load_ext autoreload\n", "%autoreload 2\n", "\n", "import os\n", "import wget\n", "import zipfile\n", "import numpy as np\n", "import pandas as pd\n", "import networkx as nx\n", "import plotly.graph_objects as go\n", "# from utils import *\n", "from collections import Counter\n", "from tqdm import tqdm\n", "import time\n", "import geopandas as gpd\n", "import gdown # for downloading files from google drive\n", "import shutil\n", "# ignore warnings\n", "import warnings\n", "import sys\n", "warnings.filterwarnings(\"ignore\")" ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
GraphNumber of NodesNumber of EdgesAverage DegreeAverage Clustering Coefficientlog NAverage Shortest Path Lengthbetweenness centrality
0Brightkite Checkins Graph649329297390.2427230.7139998.7784803.0133690.000534
1Gowalla Checkins Graph30736279040.8656040.5483728.0304103.5080310.001277
2Foursquare Checkins Graph2324246702212.308090.652737.7510452.1861120.000938
3Brightkite Friendship Graph5420146905.4206640.2185718.5978515.2318070.000664
4(Filtered) Gowalla Friendship Graph229455484.8369660.2342937.7380525.3964880.001331
5Foursquare Friendship Graph139753237.6206160.1834857.2420826.458410.001531
\n", "
" ], "text/plain": [ " Graph Number of Nodes Number of Edges \\\n", "0 Brightkite Checkins Graph 6493 292973 \n", "1 Gowalla Checkins Graph 3073 62790 \n", "2 Foursquare Checkins Graph 2324 246702 \n", "3 Brightkite Friendship Graph 5420 14690 \n", "4 (Filtered) Gowalla Friendship Graph 2294 5548 \n", "5 Foursquare Friendship Graph 1397 5323 \n", "\n", " Average Degree Average Clustering Coefficient log N \\\n", "0 90.242723 0.713999 8.778480 \n", "1 40.865604 0.548372 8.030410 \n", "2 212.30809 0.65273 7.751045 \n", "3 5.420664 0.218571 8.597851 \n", "4 4.836966 0.234293 7.738052 \n", "5 7.620616 0.183485 7.242082 \n", "\n", " Average Shortest Path Length betweenness centrality \n", "0 3.013369 0.000534 \n", "1 3.508031 0.001277 \n", "2 2.186112 0.000938 \n", "3 5.231807 0.000664 \n", "4 5.396488 0.001331 \n", "5 6.45841 0.001531 " ] }, "execution_count": 14, "metadata": {}, "output_type": "execute_result" } ], "source": [ "analysis_results = pd.read_pickle('analysis_results.pkl')\n", "analysis_results" ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
GraphNumber of NodesNumber of EdgesAverage DegreeAverage Clustering Coefficientlog NAverage Shortest Path Lengthbetweenness centralityomega-coefficient
0Brightkite Checkins Graph649329297390.2427230.7139998.7784803.0133690.000534NaN
1Gowalla Checkins Graph30736279040.8656040.5483728.0304103.5080310.001277NaN
2Foursquare Checkins Graph2324246702212.308090.652737.7510452.1861120.000938NaN
3Brightkite Friendship Graph5420146905.4206640.2185718.5978515.2318070.000664NaN
4(Filtered) Gowalla Friendship Graph229455484.8369660.2342937.7380525.3964880.001331NaN
5Foursquare Friendship Graph139753237.6206160.1834857.2420826.458410.001531NaN
\n", "
" ], "text/plain": [ " Graph Number of Nodes Number of Edges \\\n", "0 Brightkite Checkins Graph 6493 292973 \n", "1 Gowalla Checkins Graph 3073 62790 \n", "2 Foursquare Checkins Graph 2324 246702 \n", "3 Brightkite Friendship Graph 5420 14690 \n", "4 (Filtered) Gowalla Friendship Graph 2294 5548 \n", "5 Foursquare Friendship Graph 1397 5323 \n", "\n", " Average Degree Average Clustering Coefficient log N \\\n", "0 90.242723 0.713999 8.778480 \n", "1 40.865604 0.548372 8.030410 \n", "2 212.30809 0.65273 7.751045 \n", "3 5.420664 0.218571 8.597851 \n", "4 4.836966 0.234293 7.738052 \n", "5 7.620616 0.183485 7.242082 \n", "\n", " Average Shortest Path Length betweenness centrality omega-coefficient \n", "0 3.013369 0.000534 NaN \n", "1 3.508031 0.001277 NaN \n", "2 2.186112 0.000938 NaN \n", "3 5.231807 0.000664 NaN \n", "4 5.396488 0.001331 NaN \n", "5 6.45841 0.001531 NaN " ] }, "execution_count": 15, "metadata": {}, "output_type": "execute_result" } ], "source": [ "analysis_results['omega-coefficient'] = np.nan\n", "analysis_results" ] }, { "cell_type": "code", "execution_count": 16, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
GraphNumber of NodesNumber of EdgesAverage DegreeAverage Clustering Coefficientlog NAverage Shortest Path Lengthbetweenness centralityomega-coefficient
0Brightkite Checkins Graph649329297390.2427230.7139998.7784803.0133690.000534NaN
1Gowalla Checkins Graph30736279040.8656040.5483728.0304103.5080310.001277NaN
2Foursquare Checkins Graph2324246702212.308090.652737.7510452.1861120.000938NaN
3Brightkite Friendship Graph5420146905.4206640.2185718.5978515.2318070.000664NaN
4(Filtered) Gowalla Friendship Graph229455484.8369660.2342937.7380525.3964880.001331NaN
5Foursquare Friendship Graph139753237.6206160.1834857.2420826.458410.001531NaN
\n", "
" ], "text/plain": [ " Graph Number of Nodes Number of Edges \\\n", "0 Brightkite Checkins Graph 6493 292973 \n", "1 Gowalla Checkins Graph 3073 62790 \n", "2 Foursquare Checkins Graph 2324 246702 \n", "3 Brightkite Friendship Graph 5420 14690 \n", "4 (Filtered) Gowalla Friendship Graph 2294 5548 \n", "5 Foursquare Friendship Graph 1397 5323 \n", "\n", " Average Degree Average Clustering Coefficient log N \\\n", "0 90.242723 0.713999 8.778480 \n", "1 40.865604 0.548372 8.030410 \n", "2 212.30809 0.65273 7.751045 \n", "3 5.420664 0.218571 8.597851 \n", "4 4.836966 0.234293 7.738052 \n", "5 7.620616 0.183485 7.242082 \n", "\n", " Average Shortest Path Length betweenness centrality omega-coefficient \n", "0 3.013369 0.000534 NaN \n", "1 3.508031 0.001277 NaN \n", "2 2.186112 0.000938 NaN \n", "3 5.231807 0.000664 NaN \n", "4 5.396488 0.001331 NaN \n", "5 6.45841 0.001531 NaN " ] }, "execution_count": 16, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# rename (Filtered) Gowalla Friendship Graph in Gowalla Friendship Graph\n", "analysis_results.loc[analysis_results['Graph'] == 'Filtered Gowalla Friendship Graph', 'Graph'] = 'Gowalla Friendship Graph'\n", "analysis_results" ] }, { "cell_type": "code", "execution_count": 18, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
GraphNumber of NodesNumber of EdgesAverage DegreeAverage Clustering Coefficientlog NAverage Shortest Path Lengthbetweenness centralityomega-coefficient
0Brightkite Checkins Graph649329297390.2427230.7139998.7784803.0133690.000534-0.180
1Gowalla Checkins Graph30736279040.8656040.5483728.0304103.5080310.001277-0.240
2Foursquare Checkins Graph2324246702212.308090.652737.7510452.1861120.000938-0.056
3Brightkite Friendship Graph5420146905.4206640.2185718.5978515.2318070.000664NaN
4(Filtered) Gowalla Friendship Graph229455484.8369660.2342937.7380525.3964880.001331NaN
5Foursquare Friendship Graph139753237.6206160.1834857.2420826.458410.001531NaN
\n", "
" ], "text/plain": [ " Graph Number of Nodes Number of Edges \\\n", "0 Brightkite Checkins Graph 6493 292973 \n", "1 Gowalla Checkins Graph 3073 62790 \n", "2 Foursquare Checkins Graph 2324 246702 \n", "3 Brightkite Friendship Graph 5420 14690 \n", "4 (Filtered) Gowalla Friendship Graph 2294 5548 \n", "5 Foursquare Friendship Graph 1397 5323 \n", "\n", " Average Degree Average Clustering Coefficient log N \\\n", "0 90.242723 0.713999 8.778480 \n", "1 40.865604 0.548372 8.030410 \n", "2 212.30809 0.65273 7.751045 \n", "3 5.420664 0.218571 8.597851 \n", "4 4.836966 0.234293 7.738052 \n", "5 7.620616 0.183485 7.242082 \n", "\n", " Average Shortest Path Length betweenness centrality omega-coefficient \n", "0 3.013369 0.000534 -0.180 \n", "1 3.508031 0.001277 -0.240 \n", "2 2.186112 0.000938 -0.056 \n", "3 5.231807 0.000664 NaN \n", "4 5.396488 0.001331 NaN \n", "5 6.45841 0.001531 NaN " ] }, "execution_count": 18, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Foursquare Checkins Graph : -0.056\n", "# Gowalla Checkins Graph : -0.24\n", "# Brightkite Checkins Graph : -0.18\n", "\n", "# add omega-coefficient to the respective graphs\n", "analysis_results.loc[analysis_results['Graph'] == 'Foursquare Checkins Graph', 'omega-coefficient'] = -0.056\n", "analysis_results.loc[analysis_results['Graph'] == 'Gowalla Checkins Graph', 'omega-coefficient'] = -0.24\n", "analysis_results.loc[analysis_results['Graph'] == 'Brightkite Checkins Graph', 'omega-coefficient'] = -0.18\n", "analysis_results" ] }, { "cell_type": "code", "execution_count": 25, "metadata": {}, "outputs": [], "source": [ "# rename (Filtered) Gowalla Friendship Graph in Gowalla Friendship Graph\n", "analysis_results.loc[analysis_results['Graph'] == '(Filtered) Gowalla Friendship Graph', 'Graph'] = 'Gowalla Friendship Graph'" ] }, { "cell_type": "code", "execution_count": 26, "metadata": {}, "outputs": [], "source": [ "# FourSquare Friendship Graph : -0.17\n", "# Gowalla Friendship Graph : -0.25\n", "# Brightkite Friendship Graph : -0.20\n", "\n", "# add omega-coefficient to the respective graphs\n", "analysis_results.loc[analysis_results['Graph'] == 'Foursquare Friendship Graph', 'omega-coefficient'] = -0.17\n", "analysis_results.loc[analysis_results['Graph'] == 'Gowalla Friendship Graph', 'omega-coefficient'] = -0.25\n", "analysis_results.loc[analysis_results['Graph'] == 'Brightkite Friendship Graph', 'omega-coefficient'] = -0.20" ] }, { "cell_type": "code", "execution_count": 27, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
GraphNumber of NodesNumber of EdgesAverage DegreeAverage Clustering Coefficientlog NAverage Shortest Path Lengthbetweenness centralityomega-coefficient
0Brightkite Checkins Graph649329297390.2427230.7139998.7784803.0133690.000534-0.180
1Gowalla Checkins Graph30736279040.8656040.5483728.0304103.5080310.001277-0.240
2Foursquare Checkins Graph2324246702212.308090.652737.7510452.1861120.000938-0.056
3Brightkite Friendship Graph5420146905.4206640.2185718.5978515.2318070.000664-0.200
4Gowalla Friendship Graph229455484.8369660.2342937.7380525.3964880.001331-0.250
5Foursquare Friendship Graph139753237.6206160.1834857.2420826.458410.001531-0.170
\n", "
" ], "text/plain": [ " Graph Number of Nodes Number of Edges Average Degree \\\n", "0 Brightkite Checkins Graph 6493 292973 90.242723 \n", "1 Gowalla Checkins Graph 3073 62790 40.865604 \n", "2 Foursquare Checkins Graph 2324 246702 212.30809 \n", "3 Brightkite Friendship Graph 5420 14690 5.420664 \n", "4 Gowalla Friendship Graph 2294 5548 4.836966 \n", "5 Foursquare Friendship Graph 1397 5323 7.620616 \n", "\n", " Average Clustering Coefficient log N Average Shortest Path Length \\\n", "0 0.713999 8.778480 3.013369 \n", "1 0.548372 8.030410 3.508031 \n", "2 0.65273 7.751045 2.186112 \n", "3 0.218571 8.597851 5.231807 \n", "4 0.234293 7.738052 5.396488 \n", "5 0.183485 7.242082 6.45841 \n", "\n", " betweenness centrality omega-coefficient \n", "0 0.000534 -0.180 \n", "1 0.001277 -0.240 \n", "2 0.000938 -0.056 \n", "3 0.000664 -0.200 \n", "4 0.001331 -0.250 \n", "5 0.001531 -0.170 " ] }, "execution_count": 27, "metadata": {}, "output_type": "execute_result" } ], "source": [ "analysis_results\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# save the results into a pickle file\n", "analysis_results.to_pickle('analysis_results.pkl')" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3.10.8 64-bit", "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.10.9 (main, Dec 19 2022, 17:35:49) [GCC 12.2.0]" }, "orig_nbformat": 4, "vscode": { "interpreter": { "hash": "e7370f93d1d0cde622a1f8e1c04877d8463912d04d973331ad4851f04de6915a" } } }, "nbformat": 4, "nbformat_minor": 2 }