{
  "nbformat_minor": 0, 
  "nbformat": 4, 
  "cells": [
    {
      "execution_count": null, 
      "cell_type": "code", 
      "source": [
        "%matplotlib inline"
      ], 
      "outputs": [], 
      "metadata": {
        "collapsed": false
      }
    }, 
    {
      "source": [
        "\n# Davis Club\n\n\nDavis Southern Club Women\n\nShows how to make unipartite projections of the graph and compute the\nproperties of those graphs.\n\nThese data were collected by Davis et al. in the 1930s.\nThey represent observed attendance at 14 social events by 18 Southern women.\nThe graph is bipartite (clubs, women).\n\n"
      ], 
      "cell_type": "markdown", 
      "metadata": {}
    }, 
    {
      "execution_count": null, 
      "cell_type": "code", 
      "source": [
        "import matplotlib.pyplot as plt\nimport networkx as nx\nimport networkx.algorithms.bipartite as bipartite\n\nG = nx.davis_southern_women_graph()\nwomen = G.graph['top']\nclubs = G.graph['bottom']\n\nprint(\"Biadjacency matrix\")\nprint(bipartite.biadjacency_matrix(G, women, clubs))\n\n# project bipartite graph onto women nodes\nW = bipartite.projected_graph(G, women)\nprint('')\nprint(\"#Friends, Member\")\nfor w in women:\n    print('%d %s' % (W.degree(w), w))\n\n# project bipartite graph onto women nodes keeping number of co-occurence\n# the degree computed is weighted and counts the total number of shared contacts\nW = bipartite.weighted_projected_graph(G, women)\nprint('')\nprint(\"#Friend meetings, Member\")\nfor w in women:\n    print('%d %s' % (W.degree(w, weight='weight'), w))\n\nnx.draw(G)\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"
      }
    }
  }
}