{
  "nbformat_minor": 0, 
  "nbformat": 4, 
  "cells": [
    {
      "execution_count": null, 
      "cell_type": "code", 
      "source": [
        "%matplotlib inline"
      ], 
      "outputs": [], 
      "metadata": {
        "collapsed": false
      }
    }, 
    {
      "source": [
        "\n# Weighted Graph\n\n\nAn example using Graph as a weighted network.\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.Graph()\n\nG.add_edge('a', 'b', weight=0.6)\nG.add_edge('a', 'c', weight=0.2)\nG.add_edge('c', 'd', weight=0.1)\nG.add_edge('c', 'e', weight=0.7)\nG.add_edge('c', 'f', weight=0.9)\nG.add_edge('a', 'd', weight=0.3)\n\nelarge = [(u, v) for (u, v, d) in G.edges(data=True) if d['weight'] > 0.5]\nesmall = [(u, v) for (u, v, d) in G.edges(data=True) if d['weight'] <= 0.5]\n\npos = nx.spring_layout(G)  # positions for all nodes\n\n# nodes\nnx.draw_networkx_nodes(G, pos, node_size=700)\n\n# edges\nnx.draw_networkx_edges(G, pos, edgelist=elarge,\n                       width=6)\nnx.draw_networkx_edges(G, pos, edgelist=esmall,\n                       width=6, alpha=0.5, edge_color='b', style='dashed')\n\n# labels\nnx.draw_networkx_labels(G, pos, font_size=20, font_family='sans-serif')\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"
      }
    }
  }
}