{ "cells": [ { "cell_type": "markdown", "source": [ "# Topologies\n", "\nSabaody implements all the topologies provided by [PyGMO version 1](http://esa.github.io/pygmo/documentation/topology.html)." ], "metadata": {} }, { "cell_type": "markdown", "source": [ "## One-way Ring\n", "\nThis topology is a directed cycle - migrants only flow in one direction around the ring." ], "metadata": {} }, { "cell_type": "code", "source": [ "#import tellurium\n", "#from sabaody import TopologyFactory\n", "from sabaody.topology import TopologyFactory\n", "\n", "# dummy problem and algorithm for generated islands\n", "class NoProblem:\n", " pass\n", "class NoAlgo:\n", " pass\n", "\n", "# create one way ring topology\n", "f = TopologyFactory(NoProblem)\n", "one_way_ring = f.createOneWayRing(NoAlgo,6)\n", "\n", "# draw the topology\n", "import networkx as nx\n", "nx.draw(one_way_ring, pos=nx.spring_layout(one_way_ring,0.01,random_state=0))\n", "import matplotlib\n", "matplotlib.pyplot.show()" ], "outputs": [], "execution_count": 16, "metadata": { "collapsed": false, "outputHidden": false, "inputHidden": false } }, { "cell_type": "markdown", "source": [ "## Bidirectional ring\n", "\nLike the one-way ring but migrants can flow in either direction." ], "metadata": {} }, { "cell_type": "code", "source": [ "bidir_ring = f.createBidirRing(NoAlgo,6)\n", "nx.draw(bidir_ring, pos=nx.spring_layout(bidir_ring,0.01,random_state=0))\n", "matplotlib.pyplot.show()" ], "outputs": [], "execution_count": 17, "metadata": { "collapsed": false, "outputHidden": false, "inputHidden": false } }, { "cell_type": "markdown", "source": [ "## Bidirectional chain\n", "\nA simple linear topology." ], "metadata": {} }, { "cell_type": "code", "source": [ "bidir_chain = f.createBidirChain(NoAlgo,3)\n", "nx.draw(bidir_chain, pos=nx.spring_layout(bidir_chain,0.01,random_state=0))\n", "matplotlib.pyplot.show()" ], "outputs": [], "execution_count": 18, "metadata": { "collapsed": false, "outputHidden": false, "inputHidden": false } }, { "cell_type": "markdown", "source": [ "## Lollipop\n", "\n", "A lollipop is a complete graph connected to a linear chain.\n", "\n", "