Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ jobs:
--rm --detach -v "$(pwd)/data:/data" \
--name graph-machine-learning-box \
graph-machine-learning:latest

# Run tests
cd docker


# Run the tests only for chapters managed by poetry
CHAPTERS=$(find Ch* -name poetry.lock -print0 | sed -e 's/\/poetry.lock//g' | xargs -0)


# Run tests
cd docker

./tests.sh $CHAPTERS
3 changes: 2 additions & 1 deletion Chapter03/04_Graph_Neural_Network.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@
"id": "VHU1UGiHfw1e"
},
"source": [
"In this demo, we will be using the PROTEINS dataset, already integrated in StellarGraph"
"In this demo, we will be using the PROTEINS dataset, already integrated in StellarGraph (although we need to override the url, given that the original data was removed)"
]
},
{
Expand Down Expand Up @@ -246,6 +246,7 @@
}
],
"source": [
"sg.datasets.PROTEINS.url = 'https://www.chrsmrrs.com/graphkerneldatasets/PROTEINS.zip'\n",
"dataset = sg.datasets.PROTEINS()\n",
"display(HTML(dataset.description))\n",
"graphs, graph_labels = dataset.load()"
Expand Down
103 changes: 56 additions & 47 deletions Chapter06/01_Social_network_analysis.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 1,
"metadata": {
"executionInfo": {
"elapsed": 2015,
Expand Down Expand Up @@ -90,8 +90,7 @@
"source": [
"!wget http://snap.stanford.edu/data/facebook_combined.txt.gz\n",
"!wget http://snap.stanford.edu/data/facebook.tar.gz\n",
"!gzip -d facebook_combined.txt.gz\n",
"!tar -xf facebook.tar.gz"
"!gzip -d facebook_combined.txt.gz"
]
},
{
Expand Down Expand Up @@ -180,7 +179,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 2,
"metadata": {
"executionInfo": {
"elapsed": 923,
Expand Down Expand Up @@ -228,7 +227,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 3,
"metadata": {
"executionInfo": {
"elapsed": 787,
Expand Down Expand Up @@ -296,7 +295,10 @@
"outputs": [],
"source": [
"plt.axis(\"off\")\n",
"nx.draw_networkx(G, pos=spring_pos, node_color=default_node_color, edge_color=default_edge_color, with_labels=False, node_size=35)"
"plt.figure(1,figsize=(12,12)) \n",
"nx.draw_networkx(G, pos=spring_pos, node_color=default_node_color, edge_color=default_edge_color, with_labels=False, node_size=35)\n",
"ax = plt.gca() # to get the current axis\n",
"ax.collections[0].set_edgecolor(\"#fff\")"
]
},
{
Expand Down Expand Up @@ -341,7 +343,10 @@
" pos=spring_pos, \n",
" nodelist=max_keys, \n",
" node_color=enhanced_edge_color,\n",
" node_size=max_vals)"
" node_size=max_vals)\n",
" \n",
" ax = plt.gca() # to get the current axis\n",
" ax.collections[0].set_edgecolor(\"#fff\")"
]
},
{
Expand Down Expand Up @@ -675,14 +680,25 @@
" print(node, \"is in community number\", parts.get(node))\n",
" \n",
"n_sizes = [5]*len(G.nodes())\n",
"\n",
"plt.axis(\"off\")\n",
"nx.draw_networkx(G, pos=spring_pos, cmap=plt.get_cmap(\"Blues\"), edge_color=default_edge_color, node_color=values, node_size=n_sizes, with_labels=False)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# enhance color and size of the ego-nodes\n",
"for node in ego_nodes:\n",
" n_sizes[node] = 250\n",
"\n",
"plt.axis(\"off\")\n",
"nx.draw_networkx(G, pos=spring_pos, cmap=plt.get_cmap(\"Blues\"), edge_color=default_edge_color, node_color=values, node_size=n_sizes, with_labels=False)\n",
"\n",
"# enhance color and size of the ego-nodes\n",
"nodes = nx.draw_networkx_nodes(G,spring_pos,ego_nodes,node_color=[parts.get(node) for node in ego_nodes])\n",
"nodes = nx.draw_networkx_nodes(G, spring_pos, ego_nodes,node_color=[parts.get(node) for node in ego_nodes])\n",
"nodes.set_edgecolor(enhanced_node_color)"
]
},
Expand Down Expand Up @@ -933,7 +949,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 4,
"metadata": {
"id": "baistC-ZdaRf"
},
Expand Down Expand Up @@ -1046,7 +1062,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 5,
"metadata": {
"id": "2C3TwPVTdgeM"
},
Expand All @@ -1059,7 +1075,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 6,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
Expand All @@ -1078,12 +1094,36 @@
"id": "oZIj_NqvVzmU",
"outputId": "990227b3-7f01-4ef6-d036-9346c7ae5eca"
},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"{'features': array([1., 1., 1., ..., 0., 0., 0.])}"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# check features has been correctly assigned\n",
"G.nodes[0]"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
"# dump the graph on file\n",
"import pickle\n",
"\n",
"with open('test.gpickle', 'wb') as f:\n",
" pickle.dump(G, f, pickle.HIGHEST_PROTOCOL)"
]
},
{
"cell_type": "markdown",
"metadata": {
Expand All @@ -1096,35 +1136,6 @@
"More in detail, TODO"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 1000
},
"executionInfo": {
"elapsed": 14891,
"status": "ok",
"timestamp": 1616871410804,
"user": {
"displayName": "Aldo Marzullo",
"photoUrl": "https://lh3.googleusercontent.com/a-/AOh14GjBD_mZewcZ8LCqkD20Nku4DR5OCGFqYkxawoUjgg=s64",
"userId": "17245895923239449231"
},
"user_tz": -60
},
"id": "Li-IypwmIW9V",
"outputId": "580084bf-ff08-406d-b335-7f791b93e9fe"
},
"outputs": [],
"source": [
"!pip install stellargraph\n",
"!pip install node2vec==0.3.3\n",
"!pip install git+https://github.com/palash1992/GEM.git"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down Expand Up @@ -1710,9 +1721,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "O1YkgCx5rh25"
},
"metadata": {},
"outputs": [],
"source": []
}
Expand All @@ -1726,7 +1735,7 @@
"provenance": []
},
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
Expand All @@ -1740,7 +1749,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.5.0"
"version": "3.9.12"
}
},
"nbformat": 4,
Expand Down
Loading