Skip to content

Commit d6a357d

Browse files
committed
Fixed bug in recipe 14.7 due to new version of NetworkX: the list of connected components is no longer sorted by decreasing order of size. We have to sort it ourselves.
1 parent 980ea82 commit d6a357d

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

notebooks/chapter14_graphgeo/07_gps.ipynb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"metadata": {
33
"name": "",
4-
"signature": "sha256:05964b43c8096a6f0d89e7904089b06f543a8ab1f0ca334746073911b177858f"
4+
"signature": "sha256:4f9da7c7bea11c53a1ea0cb8e549909ee6ffb6a06c45e7e8ad7738bc2b865545"
55
},
66
"nbformat": 3,
77
"nbformat_minor": 0,
@@ -82,7 +82,11 @@
8282
"cell_type": "code",
8383
"collapsed": false,
8484
"input": [
85-
"sg = list(nx.connected_component_subgraphs(g.to_undirected()))[0]\n",
85+
"sgs = list(nx.connected_component_subgraphs(\n",
86+
" g.to_undirected()))\n",
87+
"largest = np.argmax([len(sg) \n",
88+
" for sg in sgs])\n",
89+
"sg = sgs[largest]\n",
8690
"len(sg)"
8791
],
8892
"language": "python",

0 commit comments

Comments
 (0)