Skip to content

Instantly share code, notes, and snippets.

@mikk-c
Last active November 7, 2018 13:35
Show Gist options
  • Save mikk-c/77f4e33359d9698a5606819422258fd7 to your computer and use it in GitHub Desktop.
Save mikk-c/77f4e33359d9698a5606819422258fd7 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import networkx as nx\n",
"import network_map as nm # From http://www.michelecoscia.com/?page_id=734\n",
"import backboning as bb # From http://www.michelecoscia.com/?page_id=287\n",
"\n",
"# This is one of the networks provided in http://www.michelecoscia.com/?page_id=734\n",
"G = nx.read_edgelist(\"aid_bipartite.txt\", delimiter = \"\\t\")"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Bipartite: True\n",
"Connected: True\n"
]
}
],
"source": [
"# 1.1\n",
"\"\"\"\n",
"Let's read the network. Node IDs are string, so no attempt to convert them to int.\n",
"Use of the standard networkx functions to test for bipartite (True) and connectedness\n",
"(True). We use \"connected_components\" to get the connected components of G, and then we\n",
"only take the one with the maximum length, which is the giant component. We use \"subgraph\"\n",
"to induce the subgraph. G is now the largest connected component of the network.\n",
"\"\"\"\n",
"print(\"Bipartite: %s\" % nx.is_bipartite(G))\n",
"print(\"Connected: %s\" % nx.is_connected(G))\n",
"G = G.subgraph(max(nx.connected_components(G), key = len))"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"# 1.2\n",
"\"\"\"\n",
"\"bipartite\" must be a dictionary with nodes as keys and their neighbors as values. So we\n",
"iterate over every node of G and we use the \"neighbor\" function to get the neighbor list.\n",
"\"nx.algorithms.bipartite.basic.sets\" sorts nodes in two different sets according to their\n",
"type in the bipartite network. We need to translate this into a dictionary whose keys are\n",
"the nodes and whose values are either 0 or 1 depending to which set the nodes belong to.\n",
"\"\"\"\n",
"\n",
"bipartite = {node: list(G.neighbors(node)) for node in G.nodes}\n",
"\n",
"keysets = nx.algorithms.bipartite.basic.sets(G)\n",
"keys = {}\n",
"for i in range(len(keysets)):\n",
" for node in keysets[i]:\n",
" keys[node] = i\n"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"G_sw's density = 1.0000\n",
"G_rw's density = 0.9636\n"
]
}
],
"source": [
"# 1.3\n",
"\"\"\"\n",
"We apply the simple weight and random walk strategies for netwotk projection. The functions\n",
"take the two dictionaries we just created as input. They return a dictionary that can be\n",
"used to create a new networkx graph. The dictionary has tuples of nodes as keys, which are\n",
"the edges. The values of the dictionary are the edge weights. So we iterate over the dictionary\n",
"and use \"add_edge\" to add the edge and its weight. We calculate the density with the built-in\n",
"networkx function, which revelas that the bipartite projections have connected all nodes to\n",
"all other nodes (minus some rare exceptions). We need to perform backboning.\n",
"\"\"\"\n",
"\n",
"edges_sw = nm.jaccard(bipartite, keys)\n",
"edges_rw = nm.ycn_edges(bipartite, keys)\n",
"\n",
"G_sw = nx.Graph()\n",
"for edge in edges_sw:\n",
" G_sw.add_edge(edge[0], edge[1], weight = edges_sw[edge])\n",
"\n",
"G_rw = nx.Graph()\n",
"for edge in edges_rw:\n",
" G_rw.add_edge(edge[0], edge[1], weight = edges_rw[edge] * 10)\n",
"\n",
"print(\"G_sw's density = %1.4f\" % nx.density(G_sw))\n",
"print(\"G_rw's density = %1.4f\" % nx.density(G_rw))"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
"# 2.1\n",
"\"\"\"\n",
"The backboning library wants as input a pandas dataframe whose columns are \"src\", \"trg\" and \"nij\".\n",
"We can use the \"to_pandas_edgelist\" to get the dataframe, and then rename the columns appropriately.\n",
"We also use \"make_symmetric\", because the backboning library assumes that the graphs are directed.\n",
"\"\"\"\n",
"G_sw = nx.to_pandas_edgelist(G_sw).rename(columns = {\"source\": \"src\", \"target\": \"trg\", \"weight\": \"nij\"})\n",
"G_rw = nx.to_pandas_edgelist(G_rw).rename(columns = {\"source\": \"src\", \"target\": \"trg\", \"weight\": \"nij\"})\n",
"\n",
"G_sw = bb.make_symmetric(G_sw)\n",
"G_rw = bb.make_symmetric(G_rw)\n"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"Calculating Naive score...\n",
"Calculating NC score...\n",
"Calculating Naive score...\n",
"Calculating NC score...\n"
]
}
],
"source": [
"# 2.2\n",
"\"\"\"\n",
"The \"naive\" and \"noise_corrected\" functions create a new column in the dataframe that is used as\n",
"new edge weights to extract the backbone of the network. They do not perform the cut directly,\n",
"you need to use the \"thresholding\" function for that. Remember that the backboning library always\n",
"assumes your graphs are directed.\n",
"\"\"\"\n",
"G_sw_naive = bb.naive(G_sw, undirected = True)\n",
"G_sw_nc = bb.noise_corrected(G_sw, undirected = True)\n",
"G_rw_naive = bb.naive(G_rw, undirected = True)\n",
"G_rw_nc = bb.noise_corrected(G_rw, undirected = True)"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
"# 2.3\n",
"\"\"\"\n",
"The \"test_densities\" function takes as input your dataframe, then:\n",
"start: the minimum threshold value it will test\n",
"stop: the maximum threshold value it will test\n",
"step: the increment for the threshold value.\n",
"So if you call bb.test_densities(x, 0, 1, 0.1), the function will test the following thresholds:\n",
"0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, and 0.9. \n",
"You need some trial and error to find the start, stop, step values to pin down the threshold value\n",
"that mantains 100% of nodes in the network with the (approximately) minimum number of edges.\n",
"The method returning the smallest number of edges and 100% of the nodes in the network is NC with\n",
"the Simple Weight. That is because the naive method has to select very low threshold values to\n",
"prevent isolated nodes, but that results in too many edges. Simple Weight works better with NC\n",
"than Random Walks, because NC is designes specifically for \"count\" type data (e.g. number of\n",
"common neighbors) which is exaclty what Simple Weight does. Random Walks returns a continuous\n",
"value, not a discrete count.\n",
"\"\"\"\n",
"# Some trial and error to find the parameters\n",
"G_sw_naive_thresholds = bb.test_densities(G_sw_naive, 0.2, 0.3, 0.01) # 100% nodes at a minimum of ~4397 edges (~38% of the network)\n",
"G_sw_nc_thresholds = bb.test_densities(G_sw_nc, 0.3, 0.4, 0.01) # 100% nodes at a minimum of ~961 edges (8% of the network)\n",
"G_rw_naive_thresholds = bb.test_densities(G_rw_naive, 0.00014, 0.00015, 0.000001) # 100% nodes at a minimum of ~9502 edges (~87% of the network)\n",
"G_rw_nc_thresholds = bb.test_densities(G_rw_nc, 0.01, 0.02, 0.001) # 100% nodes at a minimum of ~1400 edges (13% of the network)"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>threshold</th>\n",
" <th>#nodes</th>\n",
" <th>%nodes</th>\n",
" <th>#edges</th>\n",
" <th>%edges</th>\n",
" <th>avgdegree</th>\n",
" <th>%avgdegree</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>0.20</td>\n",
" <td>151</td>\n",
" <td>100.000000</td>\n",
" <td>6451</td>\n",
" <td>56.962472</td>\n",
" <td>85.443709</td>\n",
" <td>0.569625</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>0.21</td>\n",
" <td>151</td>\n",
" <td>100.000000</td>\n",
" <td>6362</td>\n",
" <td>56.176600</td>\n",
" <td>84.264901</td>\n",
" <td>0.561766</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>0.22</td>\n",
" <td>151</td>\n",
" <td>100.000000</td>\n",
" <td>6027</td>\n",
" <td>53.218543</td>\n",
" <td>79.827815</td>\n",
" <td>0.532185</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>0.23</td>\n",
" <td>151</td>\n",
" <td>100.000000</td>\n",
" <td>5735</td>\n",
" <td>50.640177</td>\n",
" <td>75.960265</td>\n",
" <td>0.506402</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>0.24</td>\n",
" <td>151</td>\n",
" <td>100.000000</td>\n",
" <td>5364</td>\n",
" <td>47.364238</td>\n",
" <td>71.046358</td>\n",
" <td>0.473642</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>0.25</td>\n",
" <td>151</td>\n",
" <td>100.000000</td>\n",
" <td>5001</td>\n",
" <td>44.158940</td>\n",
" <td>66.238411</td>\n",
" <td>0.441589</td>\n",
" </tr>\n",
" <tr>\n",
" <th>6</th>\n",
" <td>0.26</td>\n",
" <td>151</td>\n",
" <td>100.000000</td>\n",
" <td>4977</td>\n",
" <td>43.947020</td>\n",
" <td>65.920530</td>\n",
" <td>0.439470</td>\n",
" </tr>\n",
" <tr>\n",
" <th>7</th>\n",
" <td>0.27</td>\n",
" <td>151</td>\n",
" <td>100.000000</td>\n",
" <td>4691</td>\n",
" <td>41.421634</td>\n",
" <td>62.132450</td>\n",
" <td>0.414216</td>\n",
" </tr>\n",
" <tr>\n",
" <th>8</th>\n",
" <td>0.28</td>\n",
" <td>151</td>\n",
" <td>100.000000</td>\n",
" <td>4397</td>\n",
" <td>38.825607</td>\n",
" <td>58.238411</td>\n",
" <td>0.388256</td>\n",
" </tr>\n",
" <tr>\n",
" <th>9</th>\n",
" <td>0.29</td>\n",
" <td>150</td>\n",
" <td>99.337748</td>\n",
" <td>4204</td>\n",
" <td>37.121413</td>\n",
" <td>56.053333</td>\n",
" <td>0.373689</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" threshold #nodes %nodes #edges %edges avgdegree %avgdegree\n",
"0 0.20 151 100.000000 6451 56.962472 85.443709 0.569625\n",
"1 0.21 151 100.000000 6362 56.176600 84.264901 0.561766\n",
"2 0.22 151 100.000000 6027 53.218543 79.827815 0.532185\n",
"3 0.23 151 100.000000 5735 50.640177 75.960265 0.506402\n",
"4 0.24 151 100.000000 5364 47.364238 71.046358 0.473642\n",
"5 0.25 151 100.000000 5001 44.158940 66.238411 0.441589\n",
"6 0.26 151 100.000000 4977 43.947020 65.920530 0.439470\n",
"7 0.27 151 100.000000 4691 41.421634 62.132450 0.414216\n",
"8 0.28 151 100.000000 4397 38.825607 58.238411 0.388256\n",
"9 0.29 150 99.337748 4204 37.121413 56.053333 0.373689"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"G_sw_naive_thresholds"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>threshold</th>\n",
" <th>#nodes</th>\n",
" <th>%nodes</th>\n",
" <th>#edges</th>\n",
" <th>%edges</th>\n",
" <th>avgdegree</th>\n",
" <th>%avgdegree</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>0.30</td>\n",
" <td>151</td>\n",
" <td>100.000000</td>\n",
" <td>1353</td>\n",
" <td>11.947020</td>\n",
" <td>17.920530</td>\n",
" <td>0.119470</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>0.31</td>\n",
" <td>151</td>\n",
" <td>100.000000</td>\n",
" <td>1308</td>\n",
" <td>11.549669</td>\n",
" <td>17.324503</td>\n",
" <td>0.115497</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>0.32</td>\n",
" <td>151</td>\n",
" <td>100.000000</td>\n",
" <td>1249</td>\n",
" <td>11.028698</td>\n",
" <td>16.543046</td>\n",
" <td>0.110287</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>0.33</td>\n",
" <td>151</td>\n",
" <td>100.000000</td>\n",
" <td>1198</td>\n",
" <td>10.578366</td>\n",
" <td>15.867550</td>\n",
" <td>0.105784</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>0.34</td>\n",
" <td>151</td>\n",
" <td>100.000000</td>\n",
" <td>1151</td>\n",
" <td>10.163355</td>\n",
" <td>15.245033</td>\n",
" <td>0.101634</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>0.35</td>\n",
" <td>151</td>\n",
" <td>100.000000</td>\n",
" <td>1095</td>\n",
" <td>9.668874</td>\n",
" <td>14.503311</td>\n",
" <td>0.096689</td>\n",
" </tr>\n",
" <tr>\n",
" <th>6</th>\n",
" <td>0.36</td>\n",
" <td>151</td>\n",
" <td>100.000000</td>\n",
" <td>1045</td>\n",
" <td>9.227373</td>\n",
" <td>13.841060</td>\n",
" <td>0.092274</td>\n",
" </tr>\n",
" <tr>\n",
" <th>7</th>\n",
" <td>0.37</td>\n",
" <td>151</td>\n",
" <td>100.000000</td>\n",
" <td>1000</td>\n",
" <td>8.830022</td>\n",
" <td>13.245033</td>\n",
" <td>0.088300</td>\n",
" </tr>\n",
" <tr>\n",
" <th>8</th>\n",
" <td>0.38</td>\n",
" <td>151</td>\n",
" <td>100.000000</td>\n",
" <td>961</td>\n",
" <td>8.485651</td>\n",
" <td>12.728477</td>\n",
" <td>0.084857</td>\n",
" </tr>\n",
" <tr>\n",
" <th>9</th>\n",
" <td>0.39</td>\n",
" <td>150</td>\n",
" <td>99.337748</td>\n",
" <td>917</td>\n",
" <td>8.097130</td>\n",
" <td>12.226667</td>\n",
" <td>0.081511</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" threshold #nodes %nodes #edges %edges avgdegree %avgdegree\n",
"0 0.30 151 100.000000 1353 11.947020 17.920530 0.119470\n",
"1 0.31 151 100.000000 1308 11.549669 17.324503 0.115497\n",
"2 0.32 151 100.000000 1249 11.028698 16.543046 0.110287\n",
"3 0.33 151 100.000000 1198 10.578366 15.867550 0.105784\n",
"4 0.34 151 100.000000 1151 10.163355 15.245033 0.101634\n",
"5 0.35 151 100.000000 1095 9.668874 14.503311 0.096689\n",
"6 0.36 151 100.000000 1045 9.227373 13.841060 0.092274\n",
"7 0.37 151 100.000000 1000 8.830022 13.245033 0.088300\n",
"8 0.38 151 100.000000 961 8.485651 12.728477 0.084857\n",
"9 0.39 150 99.337748 917 8.097130 12.226667 0.081511"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"G_sw_nc_thresholds"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>threshold</th>\n",
" <th>#nodes</th>\n",
" <th>%nodes</th>\n",
" <th>#edges</th>\n",
" <th>%edges</th>\n",
" <th>avgdegree</th>\n",
" <th>%avgdegree</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>0.000140</td>\n",
" <td>151</td>\n",
" <td>100.000000</td>\n",
" <td>9594</td>\n",
" <td>87.913498</td>\n",
" <td>127.072848</td>\n",
" <td>0.879135</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>0.000141</td>\n",
" <td>151</td>\n",
" <td>100.000000</td>\n",
" <td>9536</td>\n",
" <td>87.382021</td>\n",
" <td>126.304636</td>\n",
" <td>0.873820</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>0.000142</td>\n",
" <td>151</td>\n",
" <td>100.000000</td>\n",
" <td>9535</td>\n",
" <td>87.372858</td>\n",
" <td>126.291391</td>\n",
" <td>0.873729</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>0.000143</td>\n",
" <td>151</td>\n",
" <td>100.000000</td>\n",
" <td>9528</td>\n",
" <td>87.308714</td>\n",
" <td>126.198675</td>\n",
" <td>0.873087</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>0.000144</td>\n",
" <td>151</td>\n",
" <td>100.000000</td>\n",
" <td>9528</td>\n",
" <td>87.308714</td>\n",
" <td>126.198675</td>\n",
" <td>0.873087</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>0.000145</td>\n",
" <td>151</td>\n",
" <td>100.000000</td>\n",
" <td>9521</td>\n",
" <td>87.244571</td>\n",
" <td>126.105960</td>\n",
" <td>0.872446</td>\n",
" </tr>\n",
" <tr>\n",
" <th>6</th>\n",
" <td>0.000146</td>\n",
" <td>151</td>\n",
" <td>100.000000</td>\n",
" <td>9511</td>\n",
" <td>87.152937</td>\n",
" <td>125.973510</td>\n",
" <td>0.871529</td>\n",
" </tr>\n",
" <tr>\n",
" <th>7</th>\n",
" <td>0.000147</td>\n",
" <td>151</td>\n",
" <td>100.000000</td>\n",
" <td>9511</td>\n",
" <td>87.152937</td>\n",
" <td>125.973510</td>\n",
" <td>0.871529</td>\n",
" </tr>\n",
" <tr>\n",
" <th>8</th>\n",
" <td>0.000148</td>\n",
" <td>151</td>\n",
" <td>100.000000</td>\n",
" <td>9502</td>\n",
" <td>87.070466</td>\n",
" <td>125.854305</td>\n",
" <td>0.870705</td>\n",
" </tr>\n",
" <tr>\n",
" <th>9</th>\n",
" <td>0.000149</td>\n",
" <td>150</td>\n",
" <td>99.337748</td>\n",
" <td>9434</td>\n",
" <td>86.447356</td>\n",
" <td>125.786667</td>\n",
" <td>0.870237</td>\n",
" </tr>\n",
" <tr>\n",
" <th>10</th>\n",
" <td>0.000150</td>\n",
" <td>150</td>\n",
" <td>99.337748</td>\n",
" <td>9419</td>\n",
" <td>86.309906</td>\n",
" <td>125.586667</td>\n",
" <td>0.868853</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" threshold #nodes %nodes #edges %edges avgdegree %avgdegree\n",
"0 0.000140 151 100.000000 9594 87.913498 127.072848 0.879135\n",
"1 0.000141 151 100.000000 9536 87.382021 126.304636 0.873820\n",
"2 0.000142 151 100.000000 9535 87.372858 126.291391 0.873729\n",
"3 0.000143 151 100.000000 9528 87.308714 126.198675 0.873087\n",
"4 0.000144 151 100.000000 9528 87.308714 126.198675 0.873087\n",
"5 0.000145 151 100.000000 9521 87.244571 126.105960 0.872446\n",
"6 0.000146 151 100.000000 9511 87.152937 125.973510 0.871529\n",
"7 0.000147 151 100.000000 9511 87.152937 125.973510 0.871529\n",
"8 0.000148 151 100.000000 9502 87.070466 125.854305 0.870705\n",
"9 0.000149 150 99.337748 9434 86.447356 125.786667 0.870237\n",
"10 0.000150 150 99.337748 9419 86.309906 125.586667 0.868853"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"G_rw_naive_thresholds"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>threshold</th>\n",
" <th>#nodes</th>\n",
" <th>%nodes</th>\n",
" <th>#edges</th>\n",
" <th>%edges</th>\n",
" <th>avgdegree</th>\n",
" <th>%avgdegree</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>0.010</td>\n",
" <td>151</td>\n",
" <td>100.000000</td>\n",
" <td>1600</td>\n",
" <td>14.661413</td>\n",
" <td>21.192053</td>\n",
" <td>0.146614</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>0.011</td>\n",
" <td>151</td>\n",
" <td>100.000000</td>\n",
" <td>1400</td>\n",
" <td>12.828736</td>\n",
" <td>18.543046</td>\n",
" <td>0.128287</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>0.012</td>\n",
" <td>150</td>\n",
" <td>99.337748</td>\n",
" <td>1226</td>\n",
" <td>11.234308</td>\n",
" <td>16.346667</td>\n",
" <td>0.113092</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>0.013</td>\n",
" <td>149</td>\n",
" <td>98.675497</td>\n",
" <td>1093</td>\n",
" <td>10.015578</td>\n",
" <td>14.671141</td>\n",
" <td>0.101500</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>0.014</td>\n",
" <td>148</td>\n",
" <td>98.013245</td>\n",
" <td>954</td>\n",
" <td>8.741867</td>\n",
" <td>12.891892</td>\n",
" <td>0.089191</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>0.015</td>\n",
" <td>144</td>\n",
" <td>95.364238</td>\n",
" <td>850</td>\n",
" <td>7.788876</td>\n",
" <td>11.805556</td>\n",
" <td>0.081675</td>\n",
" </tr>\n",
" <tr>\n",
" <th>6</th>\n",
" <td>0.016</td>\n",
" <td>135</td>\n",
" <td>89.403974</td>\n",
" <td>759</td>\n",
" <td>6.955008</td>\n",
" <td>11.244444</td>\n",
" <td>0.077793</td>\n",
" </tr>\n",
" <tr>\n",
" <th>7</th>\n",
" <td>0.017</td>\n",
" <td>128</td>\n",
" <td>84.768212</td>\n",
" <td>686</td>\n",
" <td>6.286081</td>\n",
" <td>10.718750</td>\n",
" <td>0.074156</td>\n",
" </tr>\n",
" <tr>\n",
" <th>8</th>\n",
" <td>0.018</td>\n",
" <td>124</td>\n",
" <td>82.119205</td>\n",
" <td>607</td>\n",
" <td>5.562174</td>\n",
" <td>9.790323</td>\n",
" <td>0.067733</td>\n",
" </tr>\n",
" <tr>\n",
" <th>9</th>\n",
" <td>0.019</td>\n",
" <td>122</td>\n",
" <td>80.794702</td>\n",
" <td>558</td>\n",
" <td>5.113168</td>\n",
" <td>9.147541</td>\n",
" <td>0.063286</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" threshold #nodes %nodes #edges %edges avgdegree %avgdegree\n",
"0 0.010 151 100.000000 1600 14.661413 21.192053 0.146614\n",
"1 0.011 151 100.000000 1400 12.828736 18.543046 0.128287\n",
"2 0.012 150 99.337748 1226 11.234308 16.346667 0.113092\n",
"3 0.013 149 98.675497 1093 10.015578 14.671141 0.101500\n",
"4 0.014 148 98.013245 954 8.741867 12.891892 0.089191\n",
"5 0.015 144 95.364238 850 7.788876 11.805556 0.081675\n",
"6 0.016 135 89.403974 759 6.955008 11.244444 0.077793\n",
"7 0.017 128 84.768212 686 6.286081 10.718750 0.074156\n",
"8 0.018 124 82.119205 607 5.562174 9.790323 0.067733\n",
"9 0.019 122 80.794702 558 5.113168 9.147541 0.063286"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"G_rw_nc_thresholds"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"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.6.5"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment