{
  "nbformat_minor": 0, 
  "nbformat": 4, 
  "cells": [
    {
      "execution_count": null, 
      "cell_type": "code", 
      "source": [
        "%matplotlib inline"
      ], 
      "outputs": [], 
      "metadata": {
        "collapsed": false
      }
    }, 
    {
      "source": [
        "\n# Four Grids\n\n\nDraw a graph with matplotlib.\nYou must have matplotlib for this to work.\n\n"
      ], 
      "cell_type": "markdown", 
      "metadata": {}
    }, 
    {
      "execution_count": null, 
      "cell_type": "code", 
      "source": [
        "# Author: Aric Hagberg (hagberg@lanl.gov)\n\n#    Copyright (C) 2004-2017\n#    Aric Hagberg <hagberg@lanl.gov>\n#    Dan Schult <dschult@colgate.edu>\n#    Pieter Swart <swart@lanl.gov>\n#    All rights reserved.\n#    BSD license.\n\nimport matplotlib.pyplot as plt\nimport networkx as nx\n\nG = nx.grid_2d_graph(4, 4)  # 4x4 grid\n\npos = nx.spring_layout(G, iterations=100)\n\nplt.subplot(221)\nnx.draw(G, pos, font_size=8)\n\nplt.subplot(222)\nnx.draw(G, pos, node_color='k', node_size=0, with_labels=False)\n\nplt.subplot(223)\nnx.draw(G, pos, node_color='g', node_size=250, with_labels=False, width=6)\n\nplt.subplot(224)\nH = G.to_directed()\nnx.draw(H, pos, node_color='b', node_size=20, with_labels=False)\n\nplt.show()"
      ], 
      "outputs": [], 
      "metadata": {
        "collapsed": false
      }
    }
  ], 
  "metadata": {
    "kernelspec": {
      "display_name": "Python 2", 
      "name": "python2", 
      "language": "python"
    }, 
    "language_info": {
      "mimetype": "text/x-python", 
      "nbconvert_exporter": "python", 
      "name": "python", 
      "file_extension": ".py", 
      "version": "2.7.12", 
      "pygments_lexer": "ipython2", 
      "codemirror_mode": {
        "version": 2, 
        "name": "ipython"
      }
    }
  }
}