{
  "cells": [
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "%matplotlib inline"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\n# Graphs with Multiple Components\n\nFor each component, netgraph computes the node and edge layouts separately,\nand then arranges the individual components with respect to each other using\n`rectangle packing`__.\n\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "import matplotlib.pyplot as plt\n\nfrom itertools import combinations\nfrom netgraph import Graph\n\nedge_list = []\n\n# add 15 2-node components\nedge_list.extend([(ii, ii+1) for ii in range(30, 60, 2)])\n\n# add 10 3-node components\nfor ii in range(60, 90, 3):\n    edge_list.extend([(ii, ii+1), (ii, ii+2), (ii+1, ii+2)])\n\n# add a couple of larger components\nn = 90\nfor ii in [10, 20, 30]:\n    edge_list.extend(list(combinations(range(n, n+ii), 2)))\n    n += ii\n\nnodes = list(range(n))\nGraph(edge_list, nodes=nodes, node_size=1, edge_width=0.3, node_layout='circular')\nplt.show()"
      ]
    }
  ],
  "metadata": {
    "kernelspec": {
      "display_name": "Python 3",
      "language": "python",
      "name": "python3"
    },
    "language_info": {
      "codemirror_mode": {
        "name": "ipython",
        "version": 3
      },
      "file_extension": ".py",
      "mimetype": "text/x-python",
      "name": "python",
      "nbconvert_exporter": "python",
      "pygments_lexer": "ipython3",
      "version": "3.6.8"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}