{
  "nbformat_minor": 0, 
  "nbformat": 4, 
  "cells": [
    {
      "execution_count": null, 
      "cell_type": "code", 
      "source": [
        "%matplotlib inline"
      ], 
      "outputs": [], 
      "metadata": {
        "collapsed": false
      }
    }, 
    {
      "source": [
        "\n# Labels And Colors\n\n\nDraw a graph with matplotlib, color by degree.\n\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)\nimport matplotlib.pyplot as plt\nimport networkx as nx\n\nG = nx.cubical_graph()\npos = nx.spring_layout(G)  # positions for all nodes\n\n# nodes\nnx.draw_networkx_nodes(G, pos,\n                       nodelist=[0, 1, 2, 3],\n                       node_color='r',\n                       node_size=500,\n                       alpha=0.8)\nnx.draw_networkx_nodes(G, pos,\n                       nodelist=[4, 5, 6, 7],\n                       node_color='b',\n                       node_size=500,\n                       alpha=0.8)\n\n# edges\nnx.draw_networkx_edges(G, pos, width=1.0, alpha=0.5)\nnx.draw_networkx_edges(G, pos,\n                       edgelist=[(0, 1), (1, 2), (2, 3), (3, 0)],\n                       width=8, alpha=0.5, edge_color='r')\nnx.draw_networkx_edges(G, pos,\n                       edgelist=[(4, 5), (5, 6), (6, 7), (7, 4)],\n                       width=8, alpha=0.5, edge_color='b')\n\n\n# some math labels\nlabels = {}\nlabels[0] = r'$a$'\nlabels[1] = r'$b$'\nlabels[2] = r'$c$'\nlabels[3] = r'$d$'\nlabels[4] = r'$\\alpha$'\nlabels[5] = r'$\\beta$'\nlabels[6] = r'$\\gamma$'\nlabels[7] = r'$\\delta$'\nnx.draw_networkx_labels(G, pos, labels, font_size=16)\n\nplt.axis('off')\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"
      }
    }
  }
}