Skip to content

Commit

Permalink
added task init
Browse files Browse the repository at this point in the history
  • Loading branch information
danlessa committed Jun 25, 2020
1 parent 57a42f4 commit 4d59a90
Show file tree
Hide file tree
Showing 14 changed files with 2,166 additions and 0 deletions.
176 changes: 176 additions & 0 deletions reference_tasks/task1.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Network Data Science with NetworkX and Python"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Load graphs from Excel spreadsheet files"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"link = (\"https://github.com/dnllvrvz/Social-Network-Dataset/\"\n",
" \"raw/master/Social%20Network%20Dataset.xlsx\")"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"network_data = pd.read_excel(link, sheet_name=['Elements', 'Connections'])"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"elements_data = network_data['Elements'] # node list\n",
"connections_data = network_data['Connections'] # edge list"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
"import networkx as nx"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
"edge_cols = ['Type', 'Weight', 'When']\n",
"\n",
"graph = nx.convert_matrix.from_pandas_edgelist(connections_data,\n",
" source='From',\n",
" target='To',\n",
" edge_attr=edge_cols)"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
"from random import sample\n",
"sampled_edges = sample(graph.edges, 10)"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'Type': 'Work', 'Weight': 0.8, 'When': 2017.0}"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"graph.edges[sampled_edges[0]]"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [],
"source": [
"node_dict = elements_data.set_index('Label').to_dict(orient='index')\n",
"nx.set_node_attributes(graph, node_dict)"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [],
"source": [
"sampled_nodes = sample(graph.nodes, 10)"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'Type': 'Student', 'School (ID)': 27, 'Answered the form': 'Yes'}"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"graph.nodes[sampled_nodes[0]]"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"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.7.6"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
217 changes: 217 additions & 0 deletions reference_tasks/task2.ipynb

Large diffs are not rendered by default.

246 changes: 246 additions & 0 deletions reference_tasks/task3.ipynb

Large diffs are not rendered by default.

220 changes: 220 additions & 0 deletions reference_tasks/task4.ipynb

Large diffs are not rendered by default.

225 changes: 225 additions & 0 deletions reference_tasks/task5.ipynb

Large diffs are not rendered by default.

300 changes: 300 additions & 0 deletions reference_tasks/task6.ipynb

Large diffs are not rendered by default.

291 changes: 291 additions & 0 deletions reference_tasks/task7.ipynb

Large diffs are not rendered by default.

46 changes: 46 additions & 0 deletions tasks/task1.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Network Data Science with NetworkX and Python"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Load graphs from Excel spreadsheet files"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"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.7.6"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
39 changes: 39 additions & 0 deletions tasks/task2.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Network Data Science with NetworkX and Python"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Visualize graphs with options and layouts\n"
]
}
],
"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.7.6"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
100 changes: 100 additions & 0 deletions tasks/task3.ipynb

Large diffs are not rendered by default.

51 changes: 51 additions & 0 deletions tasks/task4.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Network Data Science with NetworkX and Python\n",
"\n",
"## Generate random graphs"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import networkx as nx\n",
"import matplotlib.pyplot as plt"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"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.7.6"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
80 changes: 80 additions & 0 deletions tasks/task5.ipynb

Large diffs are not rendered by default.

84 changes: 84 additions & 0 deletions tasks/task6.ipynb

Large diffs are not rendered by default.

91 changes: 91 additions & 0 deletions tasks/task7.ipynb

Large diffs are not rendered by default.

0 comments on commit 4d59a90

Please sign in to comment.