Skip to content

Instantly share code, notes, and snippets.

@tillahoffmann
Created March 1, 2016 12:49
Show Gist options
  • Save tillahoffmann/f850af4803a9bbec4354 to your computer and use it in GitHub Desktop.
Save tillahoffmann/f850af4803a9bbec4354 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"import networkx as nx"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"# Load the data in `citiesToCities.csv` into a table (you can write your own code or use the pandas library for\n",
"# data processing in python; see http://pandas.pydata.org/pandas-docs/stable/generated/pandas.read_csv.html for details)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"# Construct a directed, weighted graph of flights between airports (the library networkx provides convenient methods, \n",
"# e.g. see https://networkx.github.io/documentation/latest/tutorial/tutorial.html)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"# Visualise the network you have constructed. Is it consistent with your intuition?"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"# Use the graph to query the airports you can fly to from London"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"# Which airport has the smallest/largest number of destination airports?"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"# Which airport has the smallest/largest number of routes"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"# Are the in-degree (number of incoming flights from distinct airports) and the out-degree (number of outgoing \n",
"# flights from distinct airports) correlated?"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"# Develop a function that takes the location of a walker as input and returns the location of the walker at the next\n",
"# time step by randomly choosing a neighbour of the input location"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"# Develop a function that can take multiple steps at a time"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"# Simulate a trajectory starting in London and visualise it"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"# Run a simulation of 10,000 walkers starting in London and visualise the number of walkers at each airport after\n",
"# two time steps and 200 time steps"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 2",
"language": "python",
"name": "python2"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.11"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment