{ "cells": [ { "attachments": {}, "cell_type": "markdown", "id": "88ec1393", "metadata": {}, "source": [ "# The Pop2net basics" ] }, { "attachments": {}, "cell_type": "markdown", "id": "afe2f725", "metadata": {}, "source": [ "After the installation of Pop2net, the first thing we have to do is to import the package in order to use it:" ] }, { "cell_type": "code", "execution_count": 2, "id": "66f1e942", "metadata": {}, "outputs": [], "source": [ "import pop2net as p2n" ] }, { "cell_type": "code", "execution_count": 3, "id": "11437145", "metadata": { "nbsphinx": "hidden" }, "outputs": [], "source": [ "# this is a hidden cell which sets seeds for consistent outputs\n", "\n", "import random\n", "\n", "import numpy as np\n", "\n", "random.seed(0)\n", "np.random.seed(0)" ] }, { "attachments": {}, "cell_type": "markdown", "id": "e10276d1", "metadata": {}, "source": [ "## Model" ] }, { "attachments": {}, "cell_type": "markdown", "id": "9fb10101", "metadata": {}, "source": [ "In Pop2net, `Model` is the most important object class because almost everything happens inside - or at least in regard to - a `Model`.\n", "You can imagine a `Model` as the world where all the entities we create live.\n", "Therefore, everthing you can do in Pop2net starts with creating an instance of `p2n.Model`." ] }, { "cell_type": "code", "execution_count": 4, "id": "a45d0610", "metadata": {}, "outputs": [], "source": [ "model = p2n.Model()" ] }, { "attachments": {}, "cell_type": "markdown", "id": "ccf523a4", "metadata": {}, "source": [ "A `Model` has three very important attributes:\n", "\n", "1. `model.g` is a network-graph which stores all agents, locations and their relations to each other as a bipartite network:" ] }, { "cell_type": "code", "execution_count": 5, "id": "dada088d", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "model.g" ] }, { "attachments": {}, "cell_type": "markdown", "id": "f04ebd5a", "metadata": {}, "source": [ "You never need to access `model.g` yourself unless you are a very experienced Pop2net user.\n", "In most cases, anything you want to do with the network can be done using the convenient methods provided by Pop2net." ] }, { "attachments": {}, "cell_type": "markdown", "id": "9042024d", "metadata": {}, "source": [ "2. `model.agents` returns a list of all agents stored in `model.g`:" ] }, { "cell_type": "code", "execution_count": 6, "id": "0dacf7b8", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "AgentList (0 objects)" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "model.agents" ] }, { "attachments": {}, "cell_type": "markdown", "id": "84d91656", "metadata": {}, "source": [ "3. `Model.locations` returns a list of all locations stored in `Model.g`:" ] }, { "cell_type": "code", "execution_count": 7, "id": "74a80455", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "LocationList (0 objects)" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "model.locations" ] }, { "attachments": {}, "cell_type": "markdown", "id": "db2f33cc", "metadata": {}, "source": [ "## Agents and locations" ] }, { "attachments": {}, "cell_type": "markdown", "id": "1dd62fc5", "metadata": {}, "source": [ "Next, we create our first agent:" ] }, { "cell_type": "code", "execution_count": 8, "id": "8c81fc9c", "metadata": {}, "outputs": [], "source": [ "agent = p2n.Agent(model)" ] }, { "attachments": {}, "cell_type": "markdown", "id": "980c7e42", "metadata": {}, "source": [ "Whenever a new instance of an `Agent` is created, it gets automatically added to the given instance of `Model`.\n", "This means that the created `Agent` instance is represented as a node in `model.g` ..." ] }, { "cell_type": "code", "execution_count": 9, "id": "302d54e2", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "NodeView((1,))" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "model.g.nodes" ] }, { "attachments": {}, "cell_type": "markdown", "id": "664c02d0", "metadata": {}, "source": [ "... and gets returned in `model.agents`:" ] }, { "cell_type": "code", "execution_count": 10, "id": "df47cf70", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "AgentList (1 object)" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "model.agents" ] }, { "attachments": {}, "cell_type": "markdown", "id": "3c18239b", "metadata": {}, "source": [ "The same applies to locations:" ] }, { "cell_type": "code", "execution_count": 11, "id": "2bd49b2f", "metadata": {}, "outputs": [], "source": [ "location = p2n.Location(model)" ] }, { "cell_type": "code", "execution_count": 12, "id": "520398a8", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "NodeView((1, 2))" ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "model.g.nodes" ] }, { "cell_type": "code", "execution_count": 13, "id": "a8663258", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "LocationList (1 object)" ] }, "execution_count": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ "model.locations" ] }, { "attachments": {}, "cell_type": "markdown", "id": "a10c9928", "metadata": {}, "source": [ "## A quick look: Plotting a network graph\n", "\n", "Often the best thing you can do to understand things is to look at them.\n", "In Pop2net, the `NetworkInspector` helps you to understand the network you are building.\n", "For instance, using the `NetworkInsepctor`, you can visualize the bipartite network of agents and locations:" ] }, { "cell_type": "code", "execution_count": 14, "id": "3fd61e09", "metadata": {}, "outputs": [ { "data": { "application/javascript": "'use strict';\n(function(root) {\n function now() {\n return new Date();\n }\n\n const force = true;\n\n if (typeof root._bokeh_onload_callbacks === \"undefined\" || force === true) {\n root._bokeh_onload_callbacks = [];\n root._bokeh_is_loading = undefined;\n }\n\nconst JS_MIME_TYPE = 'application/javascript';\n const HTML_MIME_TYPE = 'text/html';\n const EXEC_MIME_TYPE = 'application/vnd.bokehjs_exec.v0+json';\n const CLASS_NAME = 'output_bokeh rendered_html';\n\n /**\n * Render data to the DOM node\n */\n function render(props, node) {\n const script = document.createElement(\"script\");\n node.appendChild(script);\n }\n\n /**\n * Handle when an output is cleared or removed\n */\n function handleClearOutput(event, handle) {\n function drop(id) {\n const view = Bokeh.index.get_by_id(id)\n if (view != null) {\n view.model.document.clear()\n Bokeh.index.delete(view)\n }\n }\n\n const cell = handle.cell;\n\n const id = cell.output_area._bokeh_element_id;\n const server_id = cell.output_area._bokeh_server_id;\n\n // Clean up Bokeh references\n if (id != null) {\n drop(id)\n }\n\n if (server_id !== undefined) {\n // Clean up Bokeh references\n const cmd_clean = \"from bokeh.io.state import curstate; print(curstate().uuid_to_server['\" + server_id + \"'].get_sessions()[0].document.roots[0]._id)\";\n cell.notebook.kernel.execute(cmd_clean, {\n iopub: {\n output: function(msg) {\n const id = msg.content.text.trim()\n drop(id)\n }\n }\n });\n // Destroy server and session\n const cmd_destroy = \"import bokeh.io.notebook as ion; ion.destroy_server('\" + server_id + \"')\";\n cell.notebook.kernel.execute(cmd_destroy);\n }\n }\n\n /**\n * Handle when a new output is added\n */\n function handleAddOutput(event, handle) {\n const output_area = handle.output_area;\n const output = handle.output;\n\n // limit handleAddOutput to display_data with EXEC_MIME_TYPE content only\n if ((output.output_type != \"display_data\") || (!Object.prototype.hasOwnProperty.call(output.data, EXEC_MIME_TYPE))) {\n return\n }\n\n const toinsert = output_area.element.find(\".\" + CLASS_NAME.split(' ')[0]);\n\n if (output.metadata[EXEC_MIME_TYPE][\"id\"] !== undefined) {\n toinsert[toinsert.length - 1].firstChild.textContent = output.data[JS_MIME_TYPE];\n // store reference to embed id on output_area\n output_area._bokeh_element_id = output.metadata[EXEC_MIME_TYPE][\"id\"];\n }\n if (output.metadata[EXEC_MIME_TYPE][\"server_id\"] !== undefined) {\n const bk_div = document.createElement(\"div\");\n bk_div.innerHTML = output.data[HTML_MIME_TYPE];\n const script_attrs = bk_div.children[0].attributes;\n for (let i = 0; i < script_attrs.length; i++) {\n toinsert[toinsert.length - 1].firstChild.setAttribute(script_attrs[i].name, script_attrs[i].value);\n toinsert[toinsert.length - 1].firstChild.textContent = bk_div.children[0].textContent\n }\n // store reference to server id on output_area\n output_area._bokeh_server_id = output.metadata[EXEC_MIME_TYPE][\"server_id\"];\n }\n }\n\n function register_renderer(events, OutputArea) {\n\n function append_mime(data, metadata, element) {\n // create a DOM node to render to\n const toinsert = this.create_output_subarea(\n metadata,\n CLASS_NAME,\n EXEC_MIME_TYPE\n );\n this.keyboard_manager.register_events(toinsert);\n // Render to node\n const props = {data: data, metadata: metadata[EXEC_MIME_TYPE]};\n render(props, toinsert[toinsert.length - 1]);\n element.append(toinsert);\n return toinsert\n }\n\n /* Handle when an output is cleared or removed */\n events.on('clear_output.CodeCell', handleClearOutput);\n events.on('delete.Cell', handleClearOutput);\n\n /* Handle when a new output is added */\n events.on('output_added.OutputArea', handleAddOutput);\n\n /**\n * Register the mime type and append_mime function with output_area\n */\n OutputArea.prototype.register_mime_type(EXEC_MIME_TYPE, append_mime, {\n /* Is output safe? */\n safe: true,\n /* Index of renderer in `output_area.display_order` */\n index: 0\n });\n }\n\n // register the mime type if in Jupyter Notebook environment and previously unregistered\n if (root.Jupyter !== undefined) {\n const events = require('base/js/events');\n const OutputArea = require('notebook/js/outputarea').OutputArea;\n\n if (OutputArea.prototype.mime_types().indexOf(EXEC_MIME_TYPE) == -1) {\n register_renderer(events, OutputArea);\n }\n }\n if (typeof (root._bokeh_timeout) === \"undefined\" || force === true) {\n root._bokeh_timeout = Date.now() + 5000;\n root._bokeh_failed_load = false;\n }\n\n const NB_LOAD_WARNING = {'data': {'text/html':\n \"
\\n\"+\n \"

\\n\"+\n \"BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this \\n\"+\n \"may be due to a slow or bad network connection. Possible fixes:\\n\"+\n \"

\\n\"+\n \"\\n\"+\n \"\\n\"+\n \"from bokeh.resources import INLINE\\n\"+\n \"output_notebook(resources=INLINE)\\n\"+\n \"\\n\"+\n \"
\"}};\n\n function display_loaded(error = null) {\n const el = document.getElementById(null);\n if (el != null) {\n const html = (() => {\n if (typeof root.Bokeh === \"undefined\") {\n if (error == null) {\n return \"BokehJS is loading ...\";\n } else {\n return \"BokehJS failed to load.\";\n }\n } else {\n const prefix = `BokehJS ${root.Bokeh.version}`;\n if (error == null) {\n return `${prefix} successfully loaded.`;\n } else {\n return `${prefix} encountered errors while loading and may not function as expected.`;\n }\n }\n })();\n el.innerHTML = html;\n\n if (error != null) {\n const wrapper = document.createElement(\"div\");\n wrapper.style.overflow = \"auto\";\n wrapper.style.height = \"5em\";\n wrapper.style.resize = \"vertical\";\n const content = document.createElement(\"div\");\n content.style.fontFamily = \"monospace\";\n content.style.whiteSpace = \"pre-wrap\";\n content.style.backgroundColor = \"rgb(255, 221, 221)\";\n content.textContent = error.stack ?? error.toString();\n wrapper.append(content);\n el.append(wrapper);\n }\n } else if (Date.now() < root._bokeh_timeout) {\n setTimeout(() => display_loaded(error), 100);\n }\n }\n\n function run_callbacks() {\n try {\n root._bokeh_onload_callbacks.forEach(function(callback) {\n if (callback != null)\n callback();\n });\n } finally {\n delete root._bokeh_onload_callbacks\n }\n console.debug(\"Bokeh: all callbacks have finished\");\n }\n\n function load_libs(css_urls, js_urls, callback) {\n if (css_urls == null) css_urls = [];\n if (js_urls == null) js_urls = [];\n\n root._bokeh_onload_callbacks.push(callback);\n if (root._bokeh_is_loading > 0) {\n console.debug(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n return null;\n }\n if (js_urls == null || js_urls.length === 0) {\n run_callbacks();\n return null;\n }\n console.debug(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n root._bokeh_is_loading = css_urls.length + js_urls.length;\n\n function on_load() {\n root._bokeh_is_loading--;\n if (root._bokeh_is_loading === 0) {\n console.debug(\"Bokeh: all BokehJS libraries/stylesheets loaded\");\n run_callbacks()\n }\n }\n\n function on_error(url) {\n console.error(\"failed to load \" + url);\n }\n\n for (let i = 0; i < css_urls.length; i++) {\n const url = css_urls[i];\n const element = document.createElement(\"link\");\n element.onload = on_load;\n element.onerror = on_error.bind(null, url);\n element.rel = \"stylesheet\";\n element.type = \"text/css\";\n element.href = url;\n console.debug(\"Bokeh: injecting link tag for BokehJS stylesheet: \", url);\n document.body.appendChild(element);\n }\n\n for (let i = 0; i < js_urls.length; i++) {\n const url = js_urls[i];\n const element = document.createElement('script');\n element.onload = on_load;\n element.onerror = on_error.bind(null, url);\n element.async = false;\n element.src = url;\n console.debug(\"Bokeh: injecting script tag for BokehJS library: \", url);\n document.head.appendChild(element);\n }\n };\n\n function inject_raw_css(css) {\n const element = document.createElement(\"style\");\n element.appendChild(document.createTextNode(css));\n document.body.appendChild(element);\n }\n\n const js_urls = [\"https://cdn.bokeh.org/bokeh/release/bokeh-3.7.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-gl-3.7.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-3.7.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-3.7.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-mathjax-3.7.1.min.js\"];\n const css_urls = [];\n\n const inline_js = [ function(Bokeh) {\n Bokeh.set_log_level(\"info\");\n },\nfunction(Bokeh) {\n }\n ];\n\n function run_inline_js() {\n if (root.Bokeh !== undefined || force === true) {\n try {\n for (let i = 0; i < inline_js.length; i++) {\n inline_js[i].call(root, root.Bokeh);\n }\n\n } catch (error) {throw error;\n }} else if (Date.now() < root._bokeh_timeout) {\n setTimeout(run_inline_js, 100);\n } else if (!root._bokeh_failed_load) {\n console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n root._bokeh_failed_load = true;\n } else if (force !== true) {\n const cell = $(document.getElementById(null)).parents('.cell').data().cell;\n cell.output_area.append_execute_result(NB_LOAD_WARNING)\n }\n }\n\n if (root._bokeh_is_loading === 0) {\n console.debug(\"Bokeh: BokehJS loaded, going straight to plotting\");\n run_inline_js();\n } else {\n load_libs(css_urls, js_urls, function() {\n console.debug(\"Bokeh: BokehJS plotting callback run at\", now());\n run_inline_js();\n });\n }\n}(window));", "application/vnd.bokehjs_load.v0+json": "" }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "\n", "
\n" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/javascript": "(function(root) {\n function embed_document(root) {\n const docs_json = {\"3ffecf7d-89f9-47ef-9dec-e1dd7cd53898\":{\"version\":\"3.7.1\",\"title\":\"Bokeh Application\",\"roots\":[{\"type\":\"object\",\"name\":\"Figure\",\"id\":\"p1001\",\"attributes\":{\"width\":400,\"height\":400,\"x_range\":{\"type\":\"object\",\"name\":\"DataRange1d\",\"id\":\"p1002\"},\"y_range\":{\"type\":\"object\",\"name\":\"DataRange1d\",\"id\":\"p1003\"},\"x_scale\":{\"type\":\"object\",\"name\":\"LinearScale\",\"id\":\"p1010\"},\"y_scale\":{\"type\":\"object\",\"name\":\"LinearScale\",\"id\":\"p1011\"},\"title\":{\"type\":\"object\",\"name\":\"Title\",\"id\":\"p1008\"},\"renderers\":[{\"type\":\"object\",\"name\":\"GraphRenderer\",\"id\":\"p1033\",\"attributes\":{\"layout_provider\":{\"type\":\"object\",\"name\":\"StaticLayoutProvider\",\"id\":\"p1050\",\"attributes\":{\"graph_layout\":{\"type\":\"map\",\"entries\":[[1,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"9nhmgCZG1L8AAAAAAADwPw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[2,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"+nhmgCZG1D8AAAAAAADwvw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}]]}}},\"node_renderer\":{\"type\":\"object\",\"name\":\"GlyphRenderer\",\"id\":\"p1038\",\"attributes\":{\"data_source\":{\"type\":\"object\",\"name\":\"ColumnDataSource\",\"id\":\"p1035\",\"attributes\":{\"selected\":{\"type\":\"object\",\"name\":\"Selection\",\"id\":\"p1036\",\"attributes\":{\"indices\":[],\"line_indices\":[]}},\"selection_policy\":{\"type\":\"object\",\"name\":\"UnionRenderers\",\"id\":\"p1037\"},\"data\":{\"type\":\"map\",\"entries\":[[\"type\",[\"Agent\",\"Location\"]],[\"label\",[null,\"Location\"]],[\"bipartite\",[0,1]],[\"index\",[1,2]],[\"_marker\",[\"circle\",\"square\"]],[\"_color\",[\"firebrick\",\"steelblue\"]],[\"_alpha\",[0.5,0.5]],[\"_size\",[10,10]],[\"start_display\",[\"none\",\"none\"]],[\"end_display\",[\"none\",\"none\"]],[\"index_display\",[1,1]],[\"type_display\",[1,1]],[\"label_display\",[\"none\",1]]]}}},\"view\":{\"type\":\"object\",\"name\":\"CDSView\",\"id\":\"p1039\",\"attributes\":{\"filter\":{\"type\":\"object\",\"name\":\"AllIndices\",\"id\":\"p1040\"}}},\"glyph\":{\"type\":\"object\",\"name\":\"Scatter\",\"id\":\"p1051\",\"attributes\":{\"size\":{\"type\":\"field\",\"field\":\"_size\"},\"line_color\":{\"type\":\"field\",\"field\":\"_color\"},\"line_alpha\":{\"type\":\"field\",\"field\":\"_alpha\"},\"fill_color\":{\"type\":\"field\",\"field\":\"_color\"},\"fill_alpha\":{\"type\":\"field\",\"field\":\"_alpha\"},\"marker\":{\"type\":\"field\",\"field\":\"_marker\"}}}}},\"edge_renderer\":{\"type\":\"object\",\"name\":\"GlyphRenderer\",\"id\":\"p1045\",\"attributes\":{\"data_source\":{\"type\":\"object\",\"name\":\"ColumnDataSource\",\"id\":\"p1042\",\"attributes\":{\"selected\":{\"type\":\"object\",\"name\":\"Selection\",\"id\":\"p1043\",\"attributes\":{\"indices\":[],\"line_indices\":[]}},\"selection_policy\":{\"type\":\"object\",\"name\":\"UnionRenderers\",\"id\":\"p1044\"},\"data\":{\"type\":\"map\",\"entries\":[[\"start\",[]],[\"end\",[]],[\"start_display\",[]],[\"end_display\",[]],[\"index_display\",[]],[\"type_display\",[]],[\"label_display\",[]]]}}},\"view\":{\"type\":\"object\",\"name\":\"CDSView\",\"id\":\"p1046\",\"attributes\":{\"filter\":{\"type\":\"object\",\"name\":\"AllIndices\",\"id\":\"p1047\"}}},\"glyph\":{\"type\":\"object\",\"name\":\"MultiLine\",\"id\":\"p1041\"}}},\"selection_policy\":{\"type\":\"object\",\"name\":\"NodesOnly\",\"id\":\"p1048\"},\"inspection_policy\":{\"type\":\"object\",\"name\":\"NodesOnly\",\"id\":\"p1049\"}}}],\"toolbar\":{\"type\":\"object\",\"name\":\"Toolbar\",\"id\":\"p1009\",\"attributes\":{\"tools\":[{\"type\":\"object\",\"name\":\"BoxZoomTool\",\"id\":\"p1022\",\"attributes\":{\"dimensions\":\"both\",\"overlay\":{\"type\":\"object\",\"name\":\"BoxAnnotation\",\"id\":\"p1023\",\"attributes\":{\"syncable\":false,\"line_color\":\"black\",\"line_alpha\":1.0,\"line_width\":2,\"line_dash\":[4,4],\"fill_color\":\"lightgrey\",\"fill_alpha\":0.5,\"level\":\"overlay\",\"visible\":false,\"left\":{\"type\":\"number\",\"value\":\"nan\"},\"right\":{\"type\":\"number\",\"value\":\"nan\"},\"top\":{\"type\":\"number\",\"value\":\"nan\"},\"bottom\":{\"type\":\"number\",\"value\":\"nan\"},\"left_units\":\"canvas\",\"right_units\":\"canvas\",\"top_units\":\"canvas\",\"bottom_units\":\"canvas\",\"handles\":{\"type\":\"object\",\"name\":\"BoxInteractionHandles\",\"id\":\"p1029\",\"attributes\":{\"all\":{\"type\":\"object\",\"name\":\"AreaVisuals\",\"id\":\"p1028\",\"attributes\":{\"fill_color\":\"white\",\"hover_fill_color\":\"lightgray\"}}}}}}}},{\"type\":\"object\",\"name\":\"ResetTool\",\"id\":\"p1030\"},{\"type\":\"object\",\"name\":\"WheelZoomTool\",\"id\":\"p1031\",\"attributes\":{\"renderers\":\"auto\"}},{\"type\":\"object\",\"name\":\"PanTool\",\"id\":\"p1032\"},{\"type\":\"object\",\"name\":\"HoverTool\",\"id\":\"p1052\",\"attributes\":{\"renderers\":[{\"id\":\"p1045\"},{\"id\":\"p1038\"}],\"tooltips\":\"
\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n
start:@start
end:@end
index:@index
type:@type
label:@label
\",\"line_policy\":\"interp\"}}],\"logo\":null}},\"left\":[{\"type\":\"object\",\"name\":\"LinearAxis\",\"id\":\"p1017\",\"attributes\":{\"visible\":false,\"ticker\":{\"type\":\"object\",\"name\":\"BasicTicker\",\"id\":\"p1018\",\"attributes\":{\"mantissas\":[1,2,5]}},\"formatter\":{\"type\":\"object\",\"name\":\"BasicTickFormatter\",\"id\":\"p1019\"},\"major_label_policy\":{\"type\":\"object\",\"name\":\"AllLabels\",\"id\":\"p1020\"}}}],\"below\":[{\"type\":\"object\",\"name\":\"LinearAxis\",\"id\":\"p1012\",\"attributes\":{\"visible\":false,\"ticker\":{\"type\":\"object\",\"name\":\"BasicTicker\",\"id\":\"p1013\",\"attributes\":{\"mantissas\":[1,2,5]}},\"formatter\":{\"type\":\"object\",\"name\":\"BasicTickFormatter\",\"id\":\"p1014\"},\"major_label_policy\":{\"type\":\"object\",\"name\":\"AllLabels\",\"id\":\"p1015\"}}}],\"center\":[{\"type\":\"object\",\"name\":\"Grid\",\"id\":\"p1016\",\"attributes\":{\"axis\":{\"id\":\"p1012\"},\"grid_line_color\":null}},{\"type\":\"object\",\"name\":\"Grid\",\"id\":\"p1021\",\"attributes\":{\"dimension\":1,\"axis\":{\"id\":\"p1017\"},\"grid_line_color\":null}}]}}]}};\n const render_items = [{\"docid\":\"3ffecf7d-89f9-47ef-9dec-e1dd7cd53898\",\"roots\":{\"p1001\":\"d581b411-f5d7-463a-9b8c-10722a8b53bc\"},\"root_ids\":[\"p1001\"],\"notebook_comms_target\":\"p1053\"}];\n void root.Bokeh.embed.embed_items_notebook(docs_json, render_items);\n }\n if (root.Bokeh !== undefined) {\n embed_document(root);\n } else {\n let attempts = 0;\n const timer = setInterval(function(root) {\n if (root.Bokeh !== undefined) {\n clearInterval(timer);\n embed_document(root);\n } else {\n attempts++;\n if (attempts > 100) {\n clearInterval(timer);\n console.log(\"Bokeh: ERROR: Unable to run BokehJS code because BokehJS library is missing\");\n }\n }\n }, 10, root)\n }\n})(window);", "application/vnd.bokehjs_exec.v0+json": "" }, "metadata": { "application/vnd.bokehjs_exec.v0+json": { "id": "p1001" } }, "output_type": "display_data" } ], "source": [ "inspector = p2n.NetworkInspector(model)\n", "inspector.plot_bipartite_network()" ] }, { "attachments": {}, "cell_type": "markdown", "id": "429bd100", "metadata": {}, "source": [ "In the NetworkInspector's network visualizations, agents are always depicted as circles, while locations are represented as squares.\n", "You can also hover over the nodes to view additional information about them.\n", "(By the way: the network visualization is just a wrapper around the great little network visualization tool [BokehGraph](https://github.com/luerhard/bokehgraph).)\n", "\n", "To be honest, the above is not really a network because there are only two nodes without any edge.\n", "However, the graph gives an intuitive overview of the entities in your model." ] }, { "attachments": {}, "cell_type": "markdown", "id": "c87200b4", "metadata": {}, "source": [ "There is also a method to plot the graph at the agent level:" ] }, { "cell_type": "code", "execution_count": 15, "id": "555a973e", "metadata": {}, "outputs": [ { "data": { "application/javascript": "'use strict';\n(function(root) {\n function now() {\n return new Date();\n }\n\n const force = true;\n\n if (typeof root._bokeh_onload_callbacks === \"undefined\" || force === true) {\n root._bokeh_onload_callbacks = [];\n root._bokeh_is_loading = undefined;\n }\n\nconst JS_MIME_TYPE = 'application/javascript';\n const HTML_MIME_TYPE = 'text/html';\n const EXEC_MIME_TYPE = 'application/vnd.bokehjs_exec.v0+json';\n const CLASS_NAME = 'output_bokeh rendered_html';\n\n /**\n * Render data to the DOM node\n */\n function render(props, node) {\n const script = document.createElement(\"script\");\n node.appendChild(script);\n }\n\n /**\n * Handle when an output is cleared or removed\n */\n function handleClearOutput(event, handle) {\n function drop(id) {\n const view = Bokeh.index.get_by_id(id)\n if (view != null) {\n view.model.document.clear()\n Bokeh.index.delete(view)\n }\n }\n\n const cell = handle.cell;\n\n const id = cell.output_area._bokeh_element_id;\n const server_id = cell.output_area._bokeh_server_id;\n\n // Clean up Bokeh references\n if (id != null) {\n drop(id)\n }\n\n if (server_id !== undefined) {\n // Clean up Bokeh references\n const cmd_clean = \"from bokeh.io.state import curstate; print(curstate().uuid_to_server['\" + server_id + \"'].get_sessions()[0].document.roots[0]._id)\";\n cell.notebook.kernel.execute(cmd_clean, {\n iopub: {\n output: function(msg) {\n const id = msg.content.text.trim()\n drop(id)\n }\n }\n });\n // Destroy server and session\n const cmd_destroy = \"import bokeh.io.notebook as ion; ion.destroy_server('\" + server_id + \"')\";\n cell.notebook.kernel.execute(cmd_destroy);\n }\n }\n\n /**\n * Handle when a new output is added\n */\n function handleAddOutput(event, handle) {\n const output_area = handle.output_area;\n const output = handle.output;\n\n // limit handleAddOutput to display_data with EXEC_MIME_TYPE content only\n if ((output.output_type != \"display_data\") || (!Object.prototype.hasOwnProperty.call(output.data, EXEC_MIME_TYPE))) {\n return\n }\n\n const toinsert = output_area.element.find(\".\" + CLASS_NAME.split(' ')[0]);\n\n if (output.metadata[EXEC_MIME_TYPE][\"id\"] !== undefined) {\n toinsert[toinsert.length - 1].firstChild.textContent = output.data[JS_MIME_TYPE];\n // store reference to embed id on output_area\n output_area._bokeh_element_id = output.metadata[EXEC_MIME_TYPE][\"id\"];\n }\n if (output.metadata[EXEC_MIME_TYPE][\"server_id\"] !== undefined) {\n const bk_div = document.createElement(\"div\");\n bk_div.innerHTML = output.data[HTML_MIME_TYPE];\n const script_attrs = bk_div.children[0].attributes;\n for (let i = 0; i < script_attrs.length; i++) {\n toinsert[toinsert.length - 1].firstChild.setAttribute(script_attrs[i].name, script_attrs[i].value);\n toinsert[toinsert.length - 1].firstChild.textContent = bk_div.children[0].textContent\n }\n // store reference to server id on output_area\n output_area._bokeh_server_id = output.metadata[EXEC_MIME_TYPE][\"server_id\"];\n }\n }\n\n function register_renderer(events, OutputArea) {\n\n function append_mime(data, metadata, element) {\n // create a DOM node to render to\n const toinsert = this.create_output_subarea(\n metadata,\n CLASS_NAME,\n EXEC_MIME_TYPE\n );\n this.keyboard_manager.register_events(toinsert);\n // Render to node\n const props = {data: data, metadata: metadata[EXEC_MIME_TYPE]};\n render(props, toinsert[toinsert.length - 1]);\n element.append(toinsert);\n return toinsert\n }\n\n /* Handle when an output is cleared or removed */\n events.on('clear_output.CodeCell', handleClearOutput);\n events.on('delete.Cell', handleClearOutput);\n\n /* Handle when a new output is added */\n events.on('output_added.OutputArea', handleAddOutput);\n\n /**\n * Register the mime type and append_mime function with output_area\n */\n OutputArea.prototype.register_mime_type(EXEC_MIME_TYPE, append_mime, {\n /* Is output safe? */\n safe: true,\n /* Index of renderer in `output_area.display_order` */\n index: 0\n });\n }\n\n // register the mime type if in Jupyter Notebook environment and previously unregistered\n if (root.Jupyter !== undefined) {\n const events = require('base/js/events');\n const OutputArea = require('notebook/js/outputarea').OutputArea;\n\n if (OutputArea.prototype.mime_types().indexOf(EXEC_MIME_TYPE) == -1) {\n register_renderer(events, OutputArea);\n }\n }\n if (typeof (root._bokeh_timeout) === \"undefined\" || force === true) {\n root._bokeh_timeout = Date.now() + 5000;\n root._bokeh_failed_load = false;\n }\n\n const NB_LOAD_WARNING = {'data': {'text/html':\n \"
\\n\"+\n \"

\\n\"+\n \"BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this \\n\"+\n \"may be due to a slow or bad network connection. Possible fixes:\\n\"+\n \"

\\n\"+\n \"\\n\"+\n \"\\n\"+\n \"from bokeh.resources import INLINE\\n\"+\n \"output_notebook(resources=INLINE)\\n\"+\n \"\\n\"+\n \"
\"}};\n\n function display_loaded(error = null) {\n const el = document.getElementById(null);\n if (el != null) {\n const html = (() => {\n if (typeof root.Bokeh === \"undefined\") {\n if (error == null) {\n return \"BokehJS is loading ...\";\n } else {\n return \"BokehJS failed to load.\";\n }\n } else {\n const prefix = `BokehJS ${root.Bokeh.version}`;\n if (error == null) {\n return `${prefix} successfully loaded.`;\n } else {\n return `${prefix} encountered errors while loading and may not function as expected.`;\n }\n }\n })();\n el.innerHTML = html;\n\n if (error != null) {\n const wrapper = document.createElement(\"div\");\n wrapper.style.overflow = \"auto\";\n wrapper.style.height = \"5em\";\n wrapper.style.resize = \"vertical\";\n const content = document.createElement(\"div\");\n content.style.fontFamily = \"monospace\";\n content.style.whiteSpace = \"pre-wrap\";\n content.style.backgroundColor = \"rgb(255, 221, 221)\";\n content.textContent = error.stack ?? error.toString();\n wrapper.append(content);\n el.append(wrapper);\n }\n } else if (Date.now() < root._bokeh_timeout) {\n setTimeout(() => display_loaded(error), 100);\n }\n }\n\n function run_callbacks() {\n try {\n root._bokeh_onload_callbacks.forEach(function(callback) {\n if (callback != null)\n callback();\n });\n } finally {\n delete root._bokeh_onload_callbacks\n }\n console.debug(\"Bokeh: all callbacks have finished\");\n }\n\n function load_libs(css_urls, js_urls, callback) {\n if (css_urls == null) css_urls = [];\n if (js_urls == null) js_urls = [];\n\n root._bokeh_onload_callbacks.push(callback);\n if (root._bokeh_is_loading > 0) {\n console.debug(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n return null;\n }\n if (js_urls == null || js_urls.length === 0) {\n run_callbacks();\n return null;\n }\n console.debug(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n root._bokeh_is_loading = css_urls.length + js_urls.length;\n\n function on_load() {\n root._bokeh_is_loading--;\n if (root._bokeh_is_loading === 0) {\n console.debug(\"Bokeh: all BokehJS libraries/stylesheets loaded\");\n run_callbacks()\n }\n }\n\n function on_error(url) {\n console.error(\"failed to load \" + url);\n }\n\n for (let i = 0; i < css_urls.length; i++) {\n const url = css_urls[i];\n const element = document.createElement(\"link\");\n element.onload = on_load;\n element.onerror = on_error.bind(null, url);\n element.rel = \"stylesheet\";\n element.type = \"text/css\";\n element.href = url;\n console.debug(\"Bokeh: injecting link tag for BokehJS stylesheet: \", url);\n document.body.appendChild(element);\n }\n\n for (let i = 0; i < js_urls.length; i++) {\n const url = js_urls[i];\n const element = document.createElement('script');\n element.onload = on_load;\n element.onerror = on_error.bind(null, url);\n element.async = false;\n element.src = url;\n console.debug(\"Bokeh: injecting script tag for BokehJS library: \", url);\n document.head.appendChild(element);\n }\n };\n\n function inject_raw_css(css) {\n const element = document.createElement(\"style\");\n element.appendChild(document.createTextNode(css));\n document.body.appendChild(element);\n }\n\n const js_urls = [\"https://cdn.bokeh.org/bokeh/release/bokeh-3.7.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-gl-3.7.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-3.7.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-3.7.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-mathjax-3.7.1.min.js\"];\n const css_urls = [];\n\n const inline_js = [ function(Bokeh) {\n Bokeh.set_log_level(\"info\");\n },\nfunction(Bokeh) {\n }\n ];\n\n function run_inline_js() {\n if (root.Bokeh !== undefined || force === true) {\n try {\n for (let i = 0; i < inline_js.length; i++) {\n inline_js[i].call(root, root.Bokeh);\n }\n\n } catch (error) {throw error;\n }} else if (Date.now() < root._bokeh_timeout) {\n setTimeout(run_inline_js, 100);\n } else if (!root._bokeh_failed_load) {\n console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n root._bokeh_failed_load = true;\n } else if (force !== true) {\n const cell = $(document.getElementById(null)).parents('.cell').data().cell;\n cell.output_area.append_execute_result(NB_LOAD_WARNING)\n }\n }\n\n if (root._bokeh_is_loading === 0) {\n console.debug(\"Bokeh: BokehJS loaded, going straight to plotting\");\n run_inline_js();\n } else {\n load_libs(css_urls, js_urls, function() {\n console.debug(\"Bokeh: BokehJS plotting callback run at\", now());\n run_inline_js();\n });\n }\n}(window));", "application/vnd.bokehjs_load.v0+json": "" }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "\n", "
\n" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/javascript": "(function(root) {\n function embed_document(root) {\n const docs_json = {\"c7e7d5a1-990d-4ae6-8d83-847327a04b10\":{\"version\":\"3.7.1\",\"title\":\"Bokeh Application\",\"roots\":[{\"type\":\"object\",\"name\":\"Figure\",\"id\":\"p1056\",\"attributes\":{\"width\":400,\"height\":400,\"x_range\":{\"type\":\"object\",\"name\":\"DataRange1d\",\"id\":\"p1057\"},\"y_range\":{\"type\":\"object\",\"name\":\"DataRange1d\",\"id\":\"p1058\"},\"x_scale\":{\"type\":\"object\",\"name\":\"LinearScale\",\"id\":\"p1065\"},\"y_scale\":{\"type\":\"object\",\"name\":\"LinearScale\",\"id\":\"p1066\"},\"title\":{\"type\":\"object\",\"name\":\"Title\",\"id\":\"p1063\"},\"renderers\":[{\"type\":\"object\",\"name\":\"GraphRenderer\",\"id\":\"p1088\",\"attributes\":{\"layout_provider\":{\"type\":\"object\",\"name\":\"StaticLayoutProvider\",\"id\":\"p1105\",\"attributes\":{\"graph_layout\":{\"type\":\"map\",\"entries\":[[1,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"AAAAAAAAAAAAAAAAAAAAAA==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}]]}}},\"node_renderer\":{\"type\":\"object\",\"name\":\"GlyphRenderer\",\"id\":\"p1093\",\"attributes\":{\"data_source\":{\"type\":\"object\",\"name\":\"ColumnDataSource\",\"id\":\"p1090\",\"attributes\":{\"selected\":{\"type\":\"object\",\"name\":\"Selection\",\"id\":\"p1091\",\"attributes\":{\"indices\":[],\"line_indices\":[]}},\"selection_policy\":{\"type\":\"object\",\"name\":\"UnionRenderers\",\"id\":\"p1092\"},\"data\":{\"type\":\"map\",\"entries\":[[\"type\",[\"Agent\"]],[\"index\",[1]],[\"_marker\",[\"circle\"]],[\"_color\",[\"firebrick\"]],[\"_alpha\",[0.5]],[\"_size\",[10]],[\"start_display\",[\"none\"]],[\"end_display\",[\"none\"]],[\"index_display\",[1]],[\"type_display\",[1]]]}}},\"view\":{\"type\":\"object\",\"name\":\"CDSView\",\"id\":\"p1094\",\"attributes\":{\"filter\":{\"type\":\"object\",\"name\":\"AllIndices\",\"id\":\"p1095\"}}},\"glyph\":{\"type\":\"object\",\"name\":\"Scatter\",\"id\":\"p1106\",\"attributes\":{\"size\":{\"type\":\"field\",\"field\":\"_size\"},\"line_color\":{\"type\":\"field\",\"field\":\"_color\"},\"line_alpha\":{\"type\":\"field\",\"field\":\"_alpha\"},\"fill_color\":{\"type\":\"field\",\"field\":\"_color\"},\"fill_alpha\":{\"type\":\"field\",\"field\":\"_alpha\"},\"marker\":{\"type\":\"field\",\"field\":\"_marker\"}}}}},\"edge_renderer\":{\"type\":\"object\",\"name\":\"GlyphRenderer\",\"id\":\"p1100\",\"attributes\":{\"data_source\":{\"type\":\"object\",\"name\":\"ColumnDataSource\",\"id\":\"p1097\",\"attributes\":{\"selected\":{\"type\":\"object\",\"name\":\"Selection\",\"id\":\"p1098\",\"attributes\":{\"indices\":[],\"line_indices\":[]}},\"selection_policy\":{\"type\":\"object\",\"name\":\"UnionRenderers\",\"id\":\"p1099\"},\"data\":{\"type\":\"map\",\"entries\":[[\"start\",[]],[\"end\",[]],[\"start_display\",[]],[\"end_display\",[]],[\"index_display\",[]],[\"type_display\",[]]]}}},\"view\":{\"type\":\"object\",\"name\":\"CDSView\",\"id\":\"p1101\",\"attributes\":{\"filter\":{\"type\":\"object\",\"name\":\"AllIndices\",\"id\":\"p1102\"}}},\"glyph\":{\"type\":\"object\",\"name\":\"MultiLine\",\"id\":\"p1096\"}}},\"selection_policy\":{\"type\":\"object\",\"name\":\"NodesOnly\",\"id\":\"p1103\"},\"inspection_policy\":{\"type\":\"object\",\"name\":\"NodesOnly\",\"id\":\"p1104\"}}}],\"toolbar\":{\"type\":\"object\",\"name\":\"Toolbar\",\"id\":\"p1064\",\"attributes\":{\"tools\":[{\"type\":\"object\",\"name\":\"BoxZoomTool\",\"id\":\"p1077\",\"attributes\":{\"dimensions\":\"both\",\"overlay\":{\"type\":\"object\",\"name\":\"BoxAnnotation\",\"id\":\"p1078\",\"attributes\":{\"syncable\":false,\"line_color\":\"black\",\"line_alpha\":1.0,\"line_width\":2,\"line_dash\":[4,4],\"fill_color\":\"lightgrey\",\"fill_alpha\":0.5,\"level\":\"overlay\",\"visible\":false,\"left\":{\"type\":\"number\",\"value\":\"nan\"},\"right\":{\"type\":\"number\",\"value\":\"nan\"},\"top\":{\"type\":\"number\",\"value\":\"nan\"},\"bottom\":{\"type\":\"number\",\"value\":\"nan\"},\"left_units\":\"canvas\",\"right_units\":\"canvas\",\"top_units\":\"canvas\",\"bottom_units\":\"canvas\",\"handles\":{\"type\":\"object\",\"name\":\"BoxInteractionHandles\",\"id\":\"p1084\",\"attributes\":{\"all\":{\"type\":\"object\",\"name\":\"AreaVisuals\",\"id\":\"p1083\",\"attributes\":{\"fill_color\":\"white\",\"hover_fill_color\":\"lightgray\"}}}}}}}},{\"type\":\"object\",\"name\":\"ResetTool\",\"id\":\"p1085\"},{\"type\":\"object\",\"name\":\"WheelZoomTool\",\"id\":\"p1086\",\"attributes\":{\"renderers\":\"auto\"}},{\"type\":\"object\",\"name\":\"PanTool\",\"id\":\"p1087\"},{\"type\":\"object\",\"name\":\"HoverTool\",\"id\":\"p1107\",\"attributes\":{\"renderers\":[{\"id\":\"p1100\"},{\"id\":\"p1093\"}],\"tooltips\":\"
\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n
start:@start
end:@end
index:@index
type:@type
\",\"line_policy\":\"interp\"}}],\"logo\":null}},\"left\":[{\"type\":\"object\",\"name\":\"LinearAxis\",\"id\":\"p1072\",\"attributes\":{\"visible\":false,\"ticker\":{\"type\":\"object\",\"name\":\"BasicTicker\",\"id\":\"p1073\",\"attributes\":{\"mantissas\":[1,2,5]}},\"formatter\":{\"type\":\"object\",\"name\":\"BasicTickFormatter\",\"id\":\"p1074\"},\"major_label_policy\":{\"type\":\"object\",\"name\":\"AllLabels\",\"id\":\"p1075\"}}}],\"below\":[{\"type\":\"object\",\"name\":\"LinearAxis\",\"id\":\"p1067\",\"attributes\":{\"visible\":false,\"ticker\":{\"type\":\"object\",\"name\":\"BasicTicker\",\"id\":\"p1068\",\"attributes\":{\"mantissas\":[1,2,5]}},\"formatter\":{\"type\":\"object\",\"name\":\"BasicTickFormatter\",\"id\":\"p1069\"},\"major_label_policy\":{\"type\":\"object\",\"name\":\"AllLabels\",\"id\":\"p1070\"}}}],\"center\":[{\"type\":\"object\",\"name\":\"Grid\",\"id\":\"p1071\",\"attributes\":{\"axis\":{\"id\":\"p1067\"},\"grid_line_color\":null}},{\"type\":\"object\",\"name\":\"Grid\",\"id\":\"p1076\",\"attributes\":{\"dimension\":1,\"axis\":{\"id\":\"p1072\"},\"grid_line_color\":null}}]}}]}};\n const render_items = [{\"docid\":\"c7e7d5a1-990d-4ae6-8d83-847327a04b10\",\"roots\":{\"p1056\":\"e72d0bcb-3e90-4e30-92f2-caa443fc394a\"},\"root_ids\":[\"p1056\"],\"notebook_comms_target\":\"p1108\"}];\n void root.Bokeh.embed.embed_items_notebook(docs_json, render_items);\n }\n if (root.Bokeh !== undefined) {\n embed_document(root);\n } else {\n let attempts = 0;\n const timer = setInterval(function(root) {\n if (root.Bokeh !== undefined) {\n clearInterval(timer);\n embed_document(root);\n } else {\n attempts++;\n if (attempts > 100) {\n clearInterval(timer);\n console.log(\"Bokeh: ERROR: Unable to run BokehJS code because BokehJS library is missing\");\n }\n }\n }, 10, root)\n }\n})(window);", "application/vnd.bokehjs_exec.v0+json": "" }, "metadata": { "application/vnd.bokehjs_exec.v0+json": { "id": "p1056" } }, "output_type": "display_data" } ], "source": [ "inspector.plot_agent_network()" ] }, { "cell_type": "markdown", "id": "1879f59d", "metadata": {}, "source": [ "And there is also a method to plot both graphs!" ] }, { "cell_type": "code", "execution_count": 16, "id": "e8a21f35", "metadata": {}, "outputs": [ { "data": { "application/javascript": "'use strict';\n(function(root) {\n function now() {\n return new Date();\n }\n\n const force = true;\n\n if (typeof root._bokeh_onload_callbacks === \"undefined\" || force === true) {\n root._bokeh_onload_callbacks = [];\n root._bokeh_is_loading = undefined;\n }\n\nconst JS_MIME_TYPE = 'application/javascript';\n const HTML_MIME_TYPE = 'text/html';\n const EXEC_MIME_TYPE = 'application/vnd.bokehjs_exec.v0+json';\n const CLASS_NAME = 'output_bokeh rendered_html';\n\n /**\n * Render data to the DOM node\n */\n function render(props, node) {\n const script = document.createElement(\"script\");\n node.appendChild(script);\n }\n\n /**\n * Handle when an output is cleared or removed\n */\n function handleClearOutput(event, handle) {\n function drop(id) {\n const view = Bokeh.index.get_by_id(id)\n if (view != null) {\n view.model.document.clear()\n Bokeh.index.delete(view)\n }\n }\n\n const cell = handle.cell;\n\n const id = cell.output_area._bokeh_element_id;\n const server_id = cell.output_area._bokeh_server_id;\n\n // Clean up Bokeh references\n if (id != null) {\n drop(id)\n }\n\n if (server_id !== undefined) {\n // Clean up Bokeh references\n const cmd_clean = \"from bokeh.io.state import curstate; print(curstate().uuid_to_server['\" + server_id + \"'].get_sessions()[0].document.roots[0]._id)\";\n cell.notebook.kernel.execute(cmd_clean, {\n iopub: {\n output: function(msg) {\n const id = msg.content.text.trim()\n drop(id)\n }\n }\n });\n // Destroy server and session\n const cmd_destroy = \"import bokeh.io.notebook as ion; ion.destroy_server('\" + server_id + \"')\";\n cell.notebook.kernel.execute(cmd_destroy);\n }\n }\n\n /**\n * Handle when a new output is added\n */\n function handleAddOutput(event, handle) {\n const output_area = handle.output_area;\n const output = handle.output;\n\n // limit handleAddOutput to display_data with EXEC_MIME_TYPE content only\n if ((output.output_type != \"display_data\") || (!Object.prototype.hasOwnProperty.call(output.data, EXEC_MIME_TYPE))) {\n return\n }\n\n const toinsert = output_area.element.find(\".\" + CLASS_NAME.split(' ')[0]);\n\n if (output.metadata[EXEC_MIME_TYPE][\"id\"] !== undefined) {\n toinsert[toinsert.length - 1].firstChild.textContent = output.data[JS_MIME_TYPE];\n // store reference to embed id on output_area\n output_area._bokeh_element_id = output.metadata[EXEC_MIME_TYPE][\"id\"];\n }\n if (output.metadata[EXEC_MIME_TYPE][\"server_id\"] !== undefined) {\n const bk_div = document.createElement(\"div\");\n bk_div.innerHTML = output.data[HTML_MIME_TYPE];\n const script_attrs = bk_div.children[0].attributes;\n for (let i = 0; i < script_attrs.length; i++) {\n toinsert[toinsert.length - 1].firstChild.setAttribute(script_attrs[i].name, script_attrs[i].value);\n toinsert[toinsert.length - 1].firstChild.textContent = bk_div.children[0].textContent\n }\n // store reference to server id on output_area\n output_area._bokeh_server_id = output.metadata[EXEC_MIME_TYPE][\"server_id\"];\n }\n }\n\n function register_renderer(events, OutputArea) {\n\n function append_mime(data, metadata, element) {\n // create a DOM node to render to\n const toinsert = this.create_output_subarea(\n metadata,\n CLASS_NAME,\n EXEC_MIME_TYPE\n );\n this.keyboard_manager.register_events(toinsert);\n // Render to node\n const props = {data: data, metadata: metadata[EXEC_MIME_TYPE]};\n render(props, toinsert[toinsert.length - 1]);\n element.append(toinsert);\n return toinsert\n }\n\n /* Handle when an output is cleared or removed */\n events.on('clear_output.CodeCell', handleClearOutput);\n events.on('delete.Cell', handleClearOutput);\n\n /* Handle when a new output is added */\n events.on('output_added.OutputArea', handleAddOutput);\n\n /**\n * Register the mime type and append_mime function with output_area\n */\n OutputArea.prototype.register_mime_type(EXEC_MIME_TYPE, append_mime, {\n /* Is output safe? */\n safe: true,\n /* Index of renderer in `output_area.display_order` */\n index: 0\n });\n }\n\n // register the mime type if in Jupyter Notebook environment and previously unregistered\n if (root.Jupyter !== undefined) {\n const events = require('base/js/events');\n const OutputArea = require('notebook/js/outputarea').OutputArea;\n\n if (OutputArea.prototype.mime_types().indexOf(EXEC_MIME_TYPE) == -1) {\n register_renderer(events, OutputArea);\n }\n }\n if (typeof (root._bokeh_timeout) === \"undefined\" || force === true) {\n root._bokeh_timeout = Date.now() + 5000;\n root._bokeh_failed_load = false;\n }\n\n const NB_LOAD_WARNING = {'data': {'text/html':\n \"
\\n\"+\n \"

\\n\"+\n \"BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this \\n\"+\n \"may be due to a slow or bad network connection. Possible fixes:\\n\"+\n \"

\\n\"+\n \"\\n\"+\n \"\\n\"+\n \"from bokeh.resources import INLINE\\n\"+\n \"output_notebook(resources=INLINE)\\n\"+\n \"\\n\"+\n \"
\"}};\n\n function display_loaded(error = null) {\n const el = document.getElementById(null);\n if (el != null) {\n const html = (() => {\n if (typeof root.Bokeh === \"undefined\") {\n if (error == null) {\n return \"BokehJS is loading ...\";\n } else {\n return \"BokehJS failed to load.\";\n }\n } else {\n const prefix = `BokehJS ${root.Bokeh.version}`;\n if (error == null) {\n return `${prefix} successfully loaded.`;\n } else {\n return `${prefix} encountered errors while loading and may not function as expected.`;\n }\n }\n })();\n el.innerHTML = html;\n\n if (error != null) {\n const wrapper = document.createElement(\"div\");\n wrapper.style.overflow = \"auto\";\n wrapper.style.height = \"5em\";\n wrapper.style.resize = \"vertical\";\n const content = document.createElement(\"div\");\n content.style.fontFamily = \"monospace\";\n content.style.whiteSpace = \"pre-wrap\";\n content.style.backgroundColor = \"rgb(255, 221, 221)\";\n content.textContent = error.stack ?? error.toString();\n wrapper.append(content);\n el.append(wrapper);\n }\n } else if (Date.now() < root._bokeh_timeout) {\n setTimeout(() => display_loaded(error), 100);\n }\n }\n\n function run_callbacks() {\n try {\n root._bokeh_onload_callbacks.forEach(function(callback) {\n if (callback != null)\n callback();\n });\n } finally {\n delete root._bokeh_onload_callbacks\n }\n console.debug(\"Bokeh: all callbacks have finished\");\n }\n\n function load_libs(css_urls, js_urls, callback) {\n if (css_urls == null) css_urls = [];\n if (js_urls == null) js_urls = [];\n\n root._bokeh_onload_callbacks.push(callback);\n if (root._bokeh_is_loading > 0) {\n console.debug(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n return null;\n }\n if (js_urls == null || js_urls.length === 0) {\n run_callbacks();\n return null;\n }\n console.debug(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n root._bokeh_is_loading = css_urls.length + js_urls.length;\n\n function on_load() {\n root._bokeh_is_loading--;\n if (root._bokeh_is_loading === 0) {\n console.debug(\"Bokeh: all BokehJS libraries/stylesheets loaded\");\n run_callbacks()\n }\n }\n\n function on_error(url) {\n console.error(\"failed to load \" + url);\n }\n\n for (let i = 0; i < css_urls.length; i++) {\n const url = css_urls[i];\n const element = document.createElement(\"link\");\n element.onload = on_load;\n element.onerror = on_error.bind(null, url);\n element.rel = \"stylesheet\";\n element.type = \"text/css\";\n element.href = url;\n console.debug(\"Bokeh: injecting link tag for BokehJS stylesheet: \", url);\n document.body.appendChild(element);\n }\n\n for (let i = 0; i < js_urls.length; i++) {\n const url = js_urls[i];\n const element = document.createElement('script');\n element.onload = on_load;\n element.onerror = on_error.bind(null, url);\n element.async = false;\n element.src = url;\n console.debug(\"Bokeh: injecting script tag for BokehJS library: \", url);\n document.head.appendChild(element);\n }\n };\n\n function inject_raw_css(css) {\n const element = document.createElement(\"style\");\n element.appendChild(document.createTextNode(css));\n document.body.appendChild(element);\n }\n\n const js_urls = [\"https://cdn.bokeh.org/bokeh/release/bokeh-3.7.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-gl-3.7.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-3.7.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-3.7.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-mathjax-3.7.1.min.js\"];\n const css_urls = [];\n\n const inline_js = [ function(Bokeh) {\n Bokeh.set_log_level(\"info\");\n },\nfunction(Bokeh) {\n }\n ];\n\n function run_inline_js() {\n if (root.Bokeh !== undefined || force === true) {\n try {\n for (let i = 0; i < inline_js.length; i++) {\n inline_js[i].call(root, root.Bokeh);\n }\n\n } catch (error) {throw error;\n }} else if (Date.now() < root._bokeh_timeout) {\n setTimeout(run_inline_js, 100);\n } else if (!root._bokeh_failed_load) {\n console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n root._bokeh_failed_load = true;\n } else if (force !== true) {\n const cell = $(document.getElementById(null)).parents('.cell').data().cell;\n cell.output_area.append_execute_result(NB_LOAD_WARNING)\n }\n }\n\n if (root._bokeh_is_loading === 0) {\n console.debug(\"Bokeh: BokehJS loaded, going straight to plotting\");\n run_inline_js();\n } else {\n load_libs(css_urls, js_urls, function() {\n console.debug(\"Bokeh: BokehJS plotting callback run at\", now());\n run_inline_js();\n });\n }\n}(window));", "application/vnd.bokehjs_load.v0+json": "" }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "\n", "
\n" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/javascript": "(function(root) {\n function embed_document(root) {\n const docs_json = {\"2bc5da3e-559c-49c3-a309-ba8665d96841\":{\"version\":\"3.7.1\",\"title\":\"Bokeh Application\",\"roots\":[{\"type\":\"object\",\"name\":\"Figure\",\"id\":\"p1110\",\"attributes\":{\"width\":400,\"height\":400,\"x_range\":{\"type\":\"object\",\"name\":\"DataRange1d\",\"id\":\"p1111\"},\"y_range\":{\"type\":\"object\",\"name\":\"DataRange1d\",\"id\":\"p1112\"},\"x_scale\":{\"type\":\"object\",\"name\":\"LinearScale\",\"id\":\"p1119\"},\"y_scale\":{\"type\":\"object\",\"name\":\"LinearScale\",\"id\":\"p1120\"},\"title\":{\"type\":\"object\",\"name\":\"Title\",\"id\":\"p1117\"},\"renderers\":[{\"type\":\"object\",\"name\":\"GraphRenderer\",\"id\":\"p1142\",\"attributes\":{\"layout_provider\":{\"type\":\"object\",\"name\":\"StaticLayoutProvider\",\"id\":\"p1159\",\"attributes\":{\"graph_layout\":{\"type\":\"map\",\"entries\":[[1,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"n/w+3gYDrb8AAAAAAADwvw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[2,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"n/w+3gYDrT8AAAAAAADwPw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}]]}}},\"node_renderer\":{\"type\":\"object\",\"name\":\"GlyphRenderer\",\"id\":\"p1147\",\"attributes\":{\"data_source\":{\"type\":\"object\",\"name\":\"ColumnDataSource\",\"id\":\"p1144\",\"attributes\":{\"selected\":{\"type\":\"object\",\"name\":\"Selection\",\"id\":\"p1145\",\"attributes\":{\"indices\":[],\"line_indices\":[]}},\"selection_policy\":{\"type\":\"object\",\"name\":\"UnionRenderers\",\"id\":\"p1146\"},\"data\":{\"type\":\"map\",\"entries\":[[\"type\",[\"Agent\",\"Location\"]],[\"label\",[null,\"Location\"]],[\"bipartite\",[0,1]],[\"index\",[1,2]],[\"_marker\",[\"circle\",\"square\"]],[\"_color\",[\"firebrick\",\"steelblue\"]],[\"_alpha\",[0.5,0.5]],[\"_size\",[10,10]],[\"start_display\",[\"none\",\"none\"]],[\"end_display\",[\"none\",\"none\"]],[\"index_display\",[1,1]],[\"type_display\",[1,1]],[\"label_display\",[\"none\",1]]]}}},\"view\":{\"type\":\"object\",\"name\":\"CDSView\",\"id\":\"p1148\",\"attributes\":{\"filter\":{\"type\":\"object\",\"name\":\"AllIndices\",\"id\":\"p1149\"}}},\"glyph\":{\"type\":\"object\",\"name\":\"Scatter\",\"id\":\"p1160\",\"attributes\":{\"size\":{\"type\":\"field\",\"field\":\"_size\"},\"line_color\":{\"type\":\"field\",\"field\":\"_color\"},\"line_alpha\":{\"type\":\"field\",\"field\":\"_alpha\"},\"fill_color\":{\"type\":\"field\",\"field\":\"_color\"},\"fill_alpha\":{\"type\":\"field\",\"field\":\"_alpha\"},\"marker\":{\"type\":\"field\",\"field\":\"_marker\"}}}}},\"edge_renderer\":{\"type\":\"object\",\"name\":\"GlyphRenderer\",\"id\":\"p1154\",\"attributes\":{\"data_source\":{\"type\":\"object\",\"name\":\"ColumnDataSource\",\"id\":\"p1151\",\"attributes\":{\"selected\":{\"type\":\"object\",\"name\":\"Selection\",\"id\":\"p1152\",\"attributes\":{\"indices\":[],\"line_indices\":[]}},\"selection_policy\":{\"type\":\"object\",\"name\":\"UnionRenderers\",\"id\":\"p1153\"},\"data\":{\"type\":\"map\",\"entries\":[[\"start\",[]],[\"end\",[]],[\"start_display\",[]],[\"end_display\",[]],[\"index_display\",[]],[\"type_display\",[]],[\"label_display\",[]]]}}},\"view\":{\"type\":\"object\",\"name\":\"CDSView\",\"id\":\"p1155\",\"attributes\":{\"filter\":{\"type\":\"object\",\"name\":\"AllIndices\",\"id\":\"p1156\"}}},\"glyph\":{\"type\":\"object\",\"name\":\"MultiLine\",\"id\":\"p1150\"}}},\"selection_policy\":{\"type\":\"object\",\"name\":\"NodesOnly\",\"id\":\"p1157\"},\"inspection_policy\":{\"type\":\"object\",\"name\":\"NodesOnly\",\"id\":\"p1158\"}}}],\"toolbar\":{\"type\":\"object\",\"name\":\"Toolbar\",\"id\":\"p1118\",\"attributes\":{\"tools\":[{\"type\":\"object\",\"name\":\"BoxZoomTool\",\"id\":\"p1131\",\"attributes\":{\"dimensions\":\"both\",\"overlay\":{\"type\":\"object\",\"name\":\"BoxAnnotation\",\"id\":\"p1132\",\"attributes\":{\"syncable\":false,\"line_color\":\"black\",\"line_alpha\":1.0,\"line_width\":2,\"line_dash\":[4,4],\"fill_color\":\"lightgrey\",\"fill_alpha\":0.5,\"level\":\"overlay\",\"visible\":false,\"left\":{\"type\":\"number\",\"value\":\"nan\"},\"right\":{\"type\":\"number\",\"value\":\"nan\"},\"top\":{\"type\":\"number\",\"value\":\"nan\"},\"bottom\":{\"type\":\"number\",\"value\":\"nan\"},\"left_units\":\"canvas\",\"right_units\":\"canvas\",\"top_units\":\"canvas\",\"bottom_units\":\"canvas\",\"handles\":{\"type\":\"object\",\"name\":\"BoxInteractionHandles\",\"id\":\"p1138\",\"attributes\":{\"all\":{\"type\":\"object\",\"name\":\"AreaVisuals\",\"id\":\"p1137\",\"attributes\":{\"fill_color\":\"white\",\"hover_fill_color\":\"lightgray\"}}}}}}}},{\"type\":\"object\",\"name\":\"ResetTool\",\"id\":\"p1139\"},{\"type\":\"object\",\"name\":\"WheelZoomTool\",\"id\":\"p1140\",\"attributes\":{\"renderers\":\"auto\"}},{\"type\":\"object\",\"name\":\"PanTool\",\"id\":\"p1141\"},{\"type\":\"object\",\"name\":\"HoverTool\",\"id\":\"p1161\",\"attributes\":{\"renderers\":[{\"id\":\"p1154\"},{\"id\":\"p1147\"}],\"tooltips\":\"
\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n
start:@start
end:@end
index:@index
type:@type
label:@label
\",\"line_policy\":\"interp\"}}],\"logo\":null}},\"left\":[{\"type\":\"object\",\"name\":\"LinearAxis\",\"id\":\"p1126\",\"attributes\":{\"visible\":false,\"ticker\":{\"type\":\"object\",\"name\":\"BasicTicker\",\"id\":\"p1127\",\"attributes\":{\"mantissas\":[1,2,5]}},\"formatter\":{\"type\":\"object\",\"name\":\"BasicTickFormatter\",\"id\":\"p1128\"},\"major_label_policy\":{\"type\":\"object\",\"name\":\"AllLabels\",\"id\":\"p1129\"}}}],\"below\":[{\"type\":\"object\",\"name\":\"LinearAxis\",\"id\":\"p1121\",\"attributes\":{\"visible\":false,\"ticker\":{\"type\":\"object\",\"name\":\"BasicTicker\",\"id\":\"p1122\",\"attributes\":{\"mantissas\":[1,2,5]}},\"formatter\":{\"type\":\"object\",\"name\":\"BasicTickFormatter\",\"id\":\"p1123\"},\"major_label_policy\":{\"type\":\"object\",\"name\":\"AllLabels\",\"id\":\"p1124\"}}}],\"center\":[{\"type\":\"object\",\"name\":\"Grid\",\"id\":\"p1125\",\"attributes\":{\"axis\":{\"id\":\"p1121\"},\"grid_line_color\":null}},{\"type\":\"object\",\"name\":\"Grid\",\"id\":\"p1130\",\"attributes\":{\"dimension\":1,\"axis\":{\"id\":\"p1126\"},\"grid_line_color\":null}}]}}]}};\n const render_items = [{\"docid\":\"2bc5da3e-559c-49c3-a309-ba8665d96841\",\"roots\":{\"p1110\":\"e0b636ea-ea0f-4572-9bf0-601291d35cf6\"},\"root_ids\":[\"p1110\"],\"notebook_comms_target\":\"p1162\"}];\n void root.Bokeh.embed.embed_items_notebook(docs_json, render_items);\n }\n if (root.Bokeh !== undefined) {\n embed_document(root);\n } else {\n let attempts = 0;\n const timer = setInterval(function(root) {\n if (root.Bokeh !== undefined) {\n clearInterval(timer);\n embed_document(root);\n } else {\n attempts++;\n if (attempts > 100) {\n clearInterval(timer);\n console.log(\"Bokeh: ERROR: Unable to run BokehJS code because BokehJS library is missing\");\n }\n }\n }, 10, root)\n }\n})(window);", "application/vnd.bokehjs_exec.v0+json": "" }, "metadata": { "application/vnd.bokehjs_exec.v0+json": { "id": "p1110" } }, "output_type": "display_data" }, { "data": { "application/javascript": "'use strict';\n(function(root) {\n function now() {\n return new Date();\n }\n\n const force = true;\n\n if (typeof root._bokeh_onload_callbacks === \"undefined\" || force === true) {\n root._bokeh_onload_callbacks = [];\n root._bokeh_is_loading = undefined;\n }\n\nconst JS_MIME_TYPE = 'application/javascript';\n const HTML_MIME_TYPE = 'text/html';\n const EXEC_MIME_TYPE = 'application/vnd.bokehjs_exec.v0+json';\n const CLASS_NAME = 'output_bokeh rendered_html';\n\n /**\n * Render data to the DOM node\n */\n function render(props, node) {\n const script = document.createElement(\"script\");\n node.appendChild(script);\n }\n\n /**\n * Handle when an output is cleared or removed\n */\n function handleClearOutput(event, handle) {\n function drop(id) {\n const view = Bokeh.index.get_by_id(id)\n if (view != null) {\n view.model.document.clear()\n Bokeh.index.delete(view)\n }\n }\n\n const cell = handle.cell;\n\n const id = cell.output_area._bokeh_element_id;\n const server_id = cell.output_area._bokeh_server_id;\n\n // Clean up Bokeh references\n if (id != null) {\n drop(id)\n }\n\n if (server_id !== undefined) {\n // Clean up Bokeh references\n const cmd_clean = \"from bokeh.io.state import curstate; print(curstate().uuid_to_server['\" + server_id + \"'].get_sessions()[0].document.roots[0]._id)\";\n cell.notebook.kernel.execute(cmd_clean, {\n iopub: {\n output: function(msg) {\n const id = msg.content.text.trim()\n drop(id)\n }\n }\n });\n // Destroy server and session\n const cmd_destroy = \"import bokeh.io.notebook as ion; ion.destroy_server('\" + server_id + \"')\";\n cell.notebook.kernel.execute(cmd_destroy);\n }\n }\n\n /**\n * Handle when a new output is added\n */\n function handleAddOutput(event, handle) {\n const output_area = handle.output_area;\n const output = handle.output;\n\n // limit handleAddOutput to display_data with EXEC_MIME_TYPE content only\n if ((output.output_type != \"display_data\") || (!Object.prototype.hasOwnProperty.call(output.data, EXEC_MIME_TYPE))) {\n return\n }\n\n const toinsert = output_area.element.find(\".\" + CLASS_NAME.split(' ')[0]);\n\n if (output.metadata[EXEC_MIME_TYPE][\"id\"] !== undefined) {\n toinsert[toinsert.length - 1].firstChild.textContent = output.data[JS_MIME_TYPE];\n // store reference to embed id on output_area\n output_area._bokeh_element_id = output.metadata[EXEC_MIME_TYPE][\"id\"];\n }\n if (output.metadata[EXEC_MIME_TYPE][\"server_id\"] !== undefined) {\n const bk_div = document.createElement(\"div\");\n bk_div.innerHTML = output.data[HTML_MIME_TYPE];\n const script_attrs = bk_div.children[0].attributes;\n for (let i = 0; i < script_attrs.length; i++) {\n toinsert[toinsert.length - 1].firstChild.setAttribute(script_attrs[i].name, script_attrs[i].value);\n toinsert[toinsert.length - 1].firstChild.textContent = bk_div.children[0].textContent\n }\n // store reference to server id on output_area\n output_area._bokeh_server_id = output.metadata[EXEC_MIME_TYPE][\"server_id\"];\n }\n }\n\n function register_renderer(events, OutputArea) {\n\n function append_mime(data, metadata, element) {\n // create a DOM node to render to\n const toinsert = this.create_output_subarea(\n metadata,\n CLASS_NAME,\n EXEC_MIME_TYPE\n );\n this.keyboard_manager.register_events(toinsert);\n // Render to node\n const props = {data: data, metadata: metadata[EXEC_MIME_TYPE]};\n render(props, toinsert[toinsert.length - 1]);\n element.append(toinsert);\n return toinsert\n }\n\n /* Handle when an output is cleared or removed */\n events.on('clear_output.CodeCell', handleClearOutput);\n events.on('delete.Cell', handleClearOutput);\n\n /* Handle when a new output is added */\n events.on('output_added.OutputArea', handleAddOutput);\n\n /**\n * Register the mime type and append_mime function with output_area\n */\n OutputArea.prototype.register_mime_type(EXEC_MIME_TYPE, append_mime, {\n /* Is output safe? */\n safe: true,\n /* Index of renderer in `output_area.display_order` */\n index: 0\n });\n }\n\n // register the mime type if in Jupyter Notebook environment and previously unregistered\n if (root.Jupyter !== undefined) {\n const events = require('base/js/events');\n const OutputArea = require('notebook/js/outputarea').OutputArea;\n\n if (OutputArea.prototype.mime_types().indexOf(EXEC_MIME_TYPE) == -1) {\n register_renderer(events, OutputArea);\n }\n }\n if (typeof (root._bokeh_timeout) === \"undefined\" || force === true) {\n root._bokeh_timeout = Date.now() + 5000;\n root._bokeh_failed_load = false;\n }\n\n const NB_LOAD_WARNING = {'data': {'text/html':\n \"
\\n\"+\n \"

\\n\"+\n \"BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this \\n\"+\n \"may be due to a slow or bad network connection. Possible fixes:\\n\"+\n \"

\\n\"+\n \"\\n\"+\n \"\\n\"+\n \"from bokeh.resources import INLINE\\n\"+\n \"output_notebook(resources=INLINE)\\n\"+\n \"\\n\"+\n \"
\"}};\n\n function display_loaded(error = null) {\n const el = document.getElementById(null);\n if (el != null) {\n const html = (() => {\n if (typeof root.Bokeh === \"undefined\") {\n if (error == null) {\n return \"BokehJS is loading ...\";\n } else {\n return \"BokehJS failed to load.\";\n }\n } else {\n const prefix = `BokehJS ${root.Bokeh.version}`;\n if (error == null) {\n return `${prefix} successfully loaded.`;\n } else {\n return `${prefix} encountered errors while loading and may not function as expected.`;\n }\n }\n })();\n el.innerHTML = html;\n\n if (error != null) {\n const wrapper = document.createElement(\"div\");\n wrapper.style.overflow = \"auto\";\n wrapper.style.height = \"5em\";\n wrapper.style.resize = \"vertical\";\n const content = document.createElement(\"div\");\n content.style.fontFamily = \"monospace\";\n content.style.whiteSpace = \"pre-wrap\";\n content.style.backgroundColor = \"rgb(255, 221, 221)\";\n content.textContent = error.stack ?? error.toString();\n wrapper.append(content);\n el.append(wrapper);\n }\n } else if (Date.now() < root._bokeh_timeout) {\n setTimeout(() => display_loaded(error), 100);\n }\n }\n\n function run_callbacks() {\n try {\n root._bokeh_onload_callbacks.forEach(function(callback) {\n if (callback != null)\n callback();\n });\n } finally {\n delete root._bokeh_onload_callbacks\n }\n console.debug(\"Bokeh: all callbacks have finished\");\n }\n\n function load_libs(css_urls, js_urls, callback) {\n if (css_urls == null) css_urls = [];\n if (js_urls == null) js_urls = [];\n\n root._bokeh_onload_callbacks.push(callback);\n if (root._bokeh_is_loading > 0) {\n console.debug(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n return null;\n }\n if (js_urls == null || js_urls.length === 0) {\n run_callbacks();\n return null;\n }\n console.debug(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n root._bokeh_is_loading = css_urls.length + js_urls.length;\n\n function on_load() {\n root._bokeh_is_loading--;\n if (root._bokeh_is_loading === 0) {\n console.debug(\"Bokeh: all BokehJS libraries/stylesheets loaded\");\n run_callbacks()\n }\n }\n\n function on_error(url) {\n console.error(\"failed to load \" + url);\n }\n\n for (let i = 0; i < css_urls.length; i++) {\n const url = css_urls[i];\n const element = document.createElement(\"link\");\n element.onload = on_load;\n element.onerror = on_error.bind(null, url);\n element.rel = \"stylesheet\";\n element.type = \"text/css\";\n element.href = url;\n console.debug(\"Bokeh: injecting link tag for BokehJS stylesheet: \", url);\n document.body.appendChild(element);\n }\n\n for (let i = 0; i < js_urls.length; i++) {\n const url = js_urls[i];\n const element = document.createElement('script');\n element.onload = on_load;\n element.onerror = on_error.bind(null, url);\n element.async = false;\n element.src = url;\n console.debug(\"Bokeh: injecting script tag for BokehJS library: \", url);\n document.head.appendChild(element);\n }\n };\n\n function inject_raw_css(css) {\n const element = document.createElement(\"style\");\n element.appendChild(document.createTextNode(css));\n document.body.appendChild(element);\n }\n\n const js_urls = [\"https://cdn.bokeh.org/bokeh/release/bokeh-3.7.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-gl-3.7.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-3.7.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-3.7.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-mathjax-3.7.1.min.js\"];\n const css_urls = [];\n\n const inline_js = [ function(Bokeh) {\n Bokeh.set_log_level(\"info\");\n },\nfunction(Bokeh) {\n }\n ];\n\n function run_inline_js() {\n if (root.Bokeh !== undefined || force === true) {\n try {\n for (let i = 0; i < inline_js.length; i++) {\n inline_js[i].call(root, root.Bokeh);\n }\n\n } catch (error) {throw error;\n }} else if (Date.now() < root._bokeh_timeout) {\n setTimeout(run_inline_js, 100);\n } else if (!root._bokeh_failed_load) {\n console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n root._bokeh_failed_load = true;\n } else if (force !== true) {\n const cell = $(document.getElementById(null)).parents('.cell').data().cell;\n cell.output_area.append_execute_result(NB_LOAD_WARNING)\n }\n }\n\n if (root._bokeh_is_loading === 0) {\n console.debug(\"Bokeh: BokehJS loaded, going straight to plotting\");\n run_inline_js();\n } else {\n load_libs(css_urls, js_urls, function() {\n console.debug(\"Bokeh: BokehJS plotting callback run at\", now());\n run_inline_js();\n });\n }\n}(window));", "application/vnd.bokehjs_load.v0+json": "" }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "\n", "
\n" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/javascript": "(function(root) {\n function embed_document(root) {\n const docs_json = {\"56c6b0ca-6182-452e-b4c9-416632105c44\":{\"version\":\"3.7.1\",\"title\":\"Bokeh Application\",\"roots\":[{\"type\":\"object\",\"name\":\"Figure\",\"id\":\"p1165\",\"attributes\":{\"width\":400,\"height\":400,\"x_range\":{\"type\":\"object\",\"name\":\"DataRange1d\",\"id\":\"p1166\"},\"y_range\":{\"type\":\"object\",\"name\":\"DataRange1d\",\"id\":\"p1167\"},\"x_scale\":{\"type\":\"object\",\"name\":\"LinearScale\",\"id\":\"p1174\"},\"y_scale\":{\"type\":\"object\",\"name\":\"LinearScale\",\"id\":\"p1175\"},\"title\":{\"type\":\"object\",\"name\":\"Title\",\"id\":\"p1172\"},\"renderers\":[{\"type\":\"object\",\"name\":\"GraphRenderer\",\"id\":\"p1197\",\"attributes\":{\"layout_provider\":{\"type\":\"object\",\"name\":\"StaticLayoutProvider\",\"id\":\"p1214\",\"attributes\":{\"graph_layout\":{\"type\":\"map\",\"entries\":[[1,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"AAAAAAAAAAAAAAAAAAAAAA==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}]]}}},\"node_renderer\":{\"type\":\"object\",\"name\":\"GlyphRenderer\",\"id\":\"p1202\",\"attributes\":{\"data_source\":{\"type\":\"object\",\"name\":\"ColumnDataSource\",\"id\":\"p1199\",\"attributes\":{\"selected\":{\"type\":\"object\",\"name\":\"Selection\",\"id\":\"p1200\",\"attributes\":{\"indices\":[],\"line_indices\":[]}},\"selection_policy\":{\"type\":\"object\",\"name\":\"UnionRenderers\",\"id\":\"p1201\"},\"data\":{\"type\":\"map\",\"entries\":[[\"type\",[\"Agent\"]],[\"index\",[1]],[\"_marker\",[\"circle\"]],[\"_color\",[\"firebrick\"]],[\"_alpha\",[0.5]],[\"_size\",[10]],[\"start_display\",[\"none\"]],[\"end_display\",[\"none\"]],[\"index_display\",[1]],[\"type_display\",[1]]]}}},\"view\":{\"type\":\"object\",\"name\":\"CDSView\",\"id\":\"p1203\",\"attributes\":{\"filter\":{\"type\":\"object\",\"name\":\"AllIndices\",\"id\":\"p1204\"}}},\"glyph\":{\"type\":\"object\",\"name\":\"Scatter\",\"id\":\"p1215\",\"attributes\":{\"size\":{\"type\":\"field\",\"field\":\"_size\"},\"line_color\":{\"type\":\"field\",\"field\":\"_color\"},\"line_alpha\":{\"type\":\"field\",\"field\":\"_alpha\"},\"fill_color\":{\"type\":\"field\",\"field\":\"_color\"},\"fill_alpha\":{\"type\":\"field\",\"field\":\"_alpha\"},\"marker\":{\"type\":\"field\",\"field\":\"_marker\"}}}}},\"edge_renderer\":{\"type\":\"object\",\"name\":\"GlyphRenderer\",\"id\":\"p1209\",\"attributes\":{\"data_source\":{\"type\":\"object\",\"name\":\"ColumnDataSource\",\"id\":\"p1206\",\"attributes\":{\"selected\":{\"type\":\"object\",\"name\":\"Selection\",\"id\":\"p1207\",\"attributes\":{\"indices\":[],\"line_indices\":[]}},\"selection_policy\":{\"type\":\"object\",\"name\":\"UnionRenderers\",\"id\":\"p1208\"},\"data\":{\"type\":\"map\",\"entries\":[[\"start\",[]],[\"end\",[]],[\"start_display\",[]],[\"end_display\",[]],[\"index_display\",[]],[\"type_display\",[]]]}}},\"view\":{\"type\":\"object\",\"name\":\"CDSView\",\"id\":\"p1210\",\"attributes\":{\"filter\":{\"type\":\"object\",\"name\":\"AllIndices\",\"id\":\"p1211\"}}},\"glyph\":{\"type\":\"object\",\"name\":\"MultiLine\",\"id\":\"p1205\"}}},\"selection_policy\":{\"type\":\"object\",\"name\":\"NodesOnly\",\"id\":\"p1212\"},\"inspection_policy\":{\"type\":\"object\",\"name\":\"NodesOnly\",\"id\":\"p1213\"}}}],\"toolbar\":{\"type\":\"object\",\"name\":\"Toolbar\",\"id\":\"p1173\",\"attributes\":{\"tools\":[{\"type\":\"object\",\"name\":\"BoxZoomTool\",\"id\":\"p1186\",\"attributes\":{\"dimensions\":\"both\",\"overlay\":{\"type\":\"object\",\"name\":\"BoxAnnotation\",\"id\":\"p1187\",\"attributes\":{\"syncable\":false,\"line_color\":\"black\",\"line_alpha\":1.0,\"line_width\":2,\"line_dash\":[4,4],\"fill_color\":\"lightgrey\",\"fill_alpha\":0.5,\"level\":\"overlay\",\"visible\":false,\"left\":{\"type\":\"number\",\"value\":\"nan\"},\"right\":{\"type\":\"number\",\"value\":\"nan\"},\"top\":{\"type\":\"number\",\"value\":\"nan\"},\"bottom\":{\"type\":\"number\",\"value\":\"nan\"},\"left_units\":\"canvas\",\"right_units\":\"canvas\",\"top_units\":\"canvas\",\"bottom_units\":\"canvas\",\"handles\":{\"type\":\"object\",\"name\":\"BoxInteractionHandles\",\"id\":\"p1193\",\"attributes\":{\"all\":{\"type\":\"object\",\"name\":\"AreaVisuals\",\"id\":\"p1192\",\"attributes\":{\"fill_color\":\"white\",\"hover_fill_color\":\"lightgray\"}}}}}}}},{\"type\":\"object\",\"name\":\"ResetTool\",\"id\":\"p1194\"},{\"type\":\"object\",\"name\":\"WheelZoomTool\",\"id\":\"p1195\",\"attributes\":{\"renderers\":\"auto\"}},{\"type\":\"object\",\"name\":\"PanTool\",\"id\":\"p1196\"},{\"type\":\"object\",\"name\":\"HoverTool\",\"id\":\"p1216\",\"attributes\":{\"renderers\":[{\"id\":\"p1209\"},{\"id\":\"p1202\"}],\"tooltips\":\"
\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n
start:@start
end:@end
index:@index
type:@type
\",\"line_policy\":\"interp\"}}],\"logo\":null}},\"left\":[{\"type\":\"object\",\"name\":\"LinearAxis\",\"id\":\"p1181\",\"attributes\":{\"visible\":false,\"ticker\":{\"type\":\"object\",\"name\":\"BasicTicker\",\"id\":\"p1182\",\"attributes\":{\"mantissas\":[1,2,5]}},\"formatter\":{\"type\":\"object\",\"name\":\"BasicTickFormatter\",\"id\":\"p1183\"},\"major_label_policy\":{\"type\":\"object\",\"name\":\"AllLabels\",\"id\":\"p1184\"}}}],\"below\":[{\"type\":\"object\",\"name\":\"LinearAxis\",\"id\":\"p1176\",\"attributes\":{\"visible\":false,\"ticker\":{\"type\":\"object\",\"name\":\"BasicTicker\",\"id\":\"p1177\",\"attributes\":{\"mantissas\":[1,2,5]}},\"formatter\":{\"type\":\"object\",\"name\":\"BasicTickFormatter\",\"id\":\"p1178\"},\"major_label_policy\":{\"type\":\"object\",\"name\":\"AllLabels\",\"id\":\"p1179\"}}}],\"center\":[{\"type\":\"object\",\"name\":\"Grid\",\"id\":\"p1180\",\"attributes\":{\"axis\":{\"id\":\"p1176\"},\"grid_line_color\":null}},{\"type\":\"object\",\"name\":\"Grid\",\"id\":\"p1185\",\"attributes\":{\"dimension\":1,\"axis\":{\"id\":\"p1181\"},\"grid_line_color\":null}}]}}]}};\n const render_items = [{\"docid\":\"56c6b0ca-6182-452e-b4c9-416632105c44\",\"roots\":{\"p1165\":\"d01dc9b1-1891-41ad-92d9-7b6b3e0dba56\"},\"root_ids\":[\"p1165\"],\"notebook_comms_target\":\"p1217\"}];\n void root.Bokeh.embed.embed_items_notebook(docs_json, render_items);\n }\n if (root.Bokeh !== undefined) {\n embed_document(root);\n } else {\n let attempts = 0;\n const timer = setInterval(function(root) {\n if (root.Bokeh !== undefined) {\n clearInterval(timer);\n embed_document(root);\n } else {\n attempts++;\n if (attempts > 100) {\n clearInterval(timer);\n console.log(\"Bokeh: ERROR: Unable to run BokehJS code because BokehJS library is missing\");\n }\n }\n }, 10, root)\n }\n})(window);", "application/vnd.bokehjs_exec.v0+json": "" }, "metadata": { "application/vnd.bokehjs_exec.v0+json": { "id": "p1165" } }, "output_type": "display_data" } ], "source": [ "inspector.plot_networks()" ] }, { "attachments": {}, "cell_type": "markdown", "id": "9f904b87", "metadata": {}, "source": [ "## Creating edges between agents and locations\n", "\n", "Our model has one agent and one location.\n", "Let's create an edge between those two entities by *adding* the agent to the location:" ] }, { "cell_type": "code", "execution_count": 17, "id": "9eea68ba", "metadata": {}, "outputs": [], "source": [ "location.add_agent(agent)" ] }, { "attachments": {}, "cell_type": "markdown", "id": "b76403e8", "metadata": {}, "source": [ "By the way: we could also let the `agent` do the same action by running `agent.add_location(location)`.\n", "And we could also let the model do the work using `model.add_agent_to_location(location=location, agent=agent)`.\n", "\n", "Anyway, let's have a look at the network graph:" ] }, { "cell_type": "code", "execution_count": 18, "id": "380d12cc", "metadata": {}, "outputs": [ { "data": { "application/javascript": "'use strict';\n(function(root) {\n function now() {\n return new Date();\n }\n\n const force = true;\n\n if (typeof root._bokeh_onload_callbacks === \"undefined\" || force === true) {\n root._bokeh_onload_callbacks = [];\n root._bokeh_is_loading = undefined;\n }\n\nconst JS_MIME_TYPE = 'application/javascript';\n const HTML_MIME_TYPE = 'text/html';\n const EXEC_MIME_TYPE = 'application/vnd.bokehjs_exec.v0+json';\n const CLASS_NAME = 'output_bokeh rendered_html';\n\n /**\n * Render data to the DOM node\n */\n function render(props, node) {\n const script = document.createElement(\"script\");\n node.appendChild(script);\n }\n\n /**\n * Handle when an output is cleared or removed\n */\n function handleClearOutput(event, handle) {\n function drop(id) {\n const view = Bokeh.index.get_by_id(id)\n if (view != null) {\n view.model.document.clear()\n Bokeh.index.delete(view)\n }\n }\n\n const cell = handle.cell;\n\n const id = cell.output_area._bokeh_element_id;\n const server_id = cell.output_area._bokeh_server_id;\n\n // Clean up Bokeh references\n if (id != null) {\n drop(id)\n }\n\n if (server_id !== undefined) {\n // Clean up Bokeh references\n const cmd_clean = \"from bokeh.io.state import curstate; print(curstate().uuid_to_server['\" + server_id + \"'].get_sessions()[0].document.roots[0]._id)\";\n cell.notebook.kernel.execute(cmd_clean, {\n iopub: {\n output: function(msg) {\n const id = msg.content.text.trim()\n drop(id)\n }\n }\n });\n // Destroy server and session\n const cmd_destroy = \"import bokeh.io.notebook as ion; ion.destroy_server('\" + server_id + \"')\";\n cell.notebook.kernel.execute(cmd_destroy);\n }\n }\n\n /**\n * Handle when a new output is added\n */\n function handleAddOutput(event, handle) {\n const output_area = handle.output_area;\n const output = handle.output;\n\n // limit handleAddOutput to display_data with EXEC_MIME_TYPE content only\n if ((output.output_type != \"display_data\") || (!Object.prototype.hasOwnProperty.call(output.data, EXEC_MIME_TYPE))) {\n return\n }\n\n const toinsert = output_area.element.find(\".\" + CLASS_NAME.split(' ')[0]);\n\n if (output.metadata[EXEC_MIME_TYPE][\"id\"] !== undefined) {\n toinsert[toinsert.length - 1].firstChild.textContent = output.data[JS_MIME_TYPE];\n // store reference to embed id on output_area\n output_area._bokeh_element_id = output.metadata[EXEC_MIME_TYPE][\"id\"];\n }\n if (output.metadata[EXEC_MIME_TYPE][\"server_id\"] !== undefined) {\n const bk_div = document.createElement(\"div\");\n bk_div.innerHTML = output.data[HTML_MIME_TYPE];\n const script_attrs = bk_div.children[0].attributes;\n for (let i = 0; i < script_attrs.length; i++) {\n toinsert[toinsert.length - 1].firstChild.setAttribute(script_attrs[i].name, script_attrs[i].value);\n toinsert[toinsert.length - 1].firstChild.textContent = bk_div.children[0].textContent\n }\n // store reference to server id on output_area\n output_area._bokeh_server_id = output.metadata[EXEC_MIME_TYPE][\"server_id\"];\n }\n }\n\n function register_renderer(events, OutputArea) {\n\n function append_mime(data, metadata, element) {\n // create a DOM node to render to\n const toinsert = this.create_output_subarea(\n metadata,\n CLASS_NAME,\n EXEC_MIME_TYPE\n );\n this.keyboard_manager.register_events(toinsert);\n // Render to node\n const props = {data: data, metadata: metadata[EXEC_MIME_TYPE]};\n render(props, toinsert[toinsert.length - 1]);\n element.append(toinsert);\n return toinsert\n }\n\n /* Handle when an output is cleared or removed */\n events.on('clear_output.CodeCell', handleClearOutput);\n events.on('delete.Cell', handleClearOutput);\n\n /* Handle when a new output is added */\n events.on('output_added.OutputArea', handleAddOutput);\n\n /**\n * Register the mime type and append_mime function with output_area\n */\n OutputArea.prototype.register_mime_type(EXEC_MIME_TYPE, append_mime, {\n /* Is output safe? */\n safe: true,\n /* Index of renderer in `output_area.display_order` */\n index: 0\n });\n }\n\n // register the mime type if in Jupyter Notebook environment and previously unregistered\n if (root.Jupyter !== undefined) {\n const events = require('base/js/events');\n const OutputArea = require('notebook/js/outputarea').OutputArea;\n\n if (OutputArea.prototype.mime_types().indexOf(EXEC_MIME_TYPE) == -1) {\n register_renderer(events, OutputArea);\n }\n }\n if (typeof (root._bokeh_timeout) === \"undefined\" || force === true) {\n root._bokeh_timeout = Date.now() + 5000;\n root._bokeh_failed_load = false;\n }\n\n const NB_LOAD_WARNING = {'data': {'text/html':\n \"
\\n\"+\n \"

\\n\"+\n \"BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this \\n\"+\n \"may be due to a slow or bad network connection. Possible fixes:\\n\"+\n \"

\\n\"+\n \"\\n\"+\n \"\\n\"+\n \"from bokeh.resources import INLINE\\n\"+\n \"output_notebook(resources=INLINE)\\n\"+\n \"\\n\"+\n \"
\"}};\n\n function display_loaded(error = null) {\n const el = document.getElementById(null);\n if (el != null) {\n const html = (() => {\n if (typeof root.Bokeh === \"undefined\") {\n if (error == null) {\n return \"BokehJS is loading ...\";\n } else {\n return \"BokehJS failed to load.\";\n }\n } else {\n const prefix = `BokehJS ${root.Bokeh.version}`;\n if (error == null) {\n return `${prefix} successfully loaded.`;\n } else {\n return `${prefix} encountered errors while loading and may not function as expected.`;\n }\n }\n })();\n el.innerHTML = html;\n\n if (error != null) {\n const wrapper = document.createElement(\"div\");\n wrapper.style.overflow = \"auto\";\n wrapper.style.height = \"5em\";\n wrapper.style.resize = \"vertical\";\n const content = document.createElement(\"div\");\n content.style.fontFamily = \"monospace\";\n content.style.whiteSpace = \"pre-wrap\";\n content.style.backgroundColor = \"rgb(255, 221, 221)\";\n content.textContent = error.stack ?? error.toString();\n wrapper.append(content);\n el.append(wrapper);\n }\n } else if (Date.now() < root._bokeh_timeout) {\n setTimeout(() => display_loaded(error), 100);\n }\n }\n\n function run_callbacks() {\n try {\n root._bokeh_onload_callbacks.forEach(function(callback) {\n if (callback != null)\n callback();\n });\n } finally {\n delete root._bokeh_onload_callbacks\n }\n console.debug(\"Bokeh: all callbacks have finished\");\n }\n\n function load_libs(css_urls, js_urls, callback) {\n if (css_urls == null) css_urls = [];\n if (js_urls == null) js_urls = [];\n\n root._bokeh_onload_callbacks.push(callback);\n if (root._bokeh_is_loading > 0) {\n console.debug(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n return null;\n }\n if (js_urls == null || js_urls.length === 0) {\n run_callbacks();\n return null;\n }\n console.debug(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n root._bokeh_is_loading = css_urls.length + js_urls.length;\n\n function on_load() {\n root._bokeh_is_loading--;\n if (root._bokeh_is_loading === 0) {\n console.debug(\"Bokeh: all BokehJS libraries/stylesheets loaded\");\n run_callbacks()\n }\n }\n\n function on_error(url) {\n console.error(\"failed to load \" + url);\n }\n\n for (let i = 0; i < css_urls.length; i++) {\n const url = css_urls[i];\n const element = document.createElement(\"link\");\n element.onload = on_load;\n element.onerror = on_error.bind(null, url);\n element.rel = \"stylesheet\";\n element.type = \"text/css\";\n element.href = url;\n console.debug(\"Bokeh: injecting link tag for BokehJS stylesheet: \", url);\n document.body.appendChild(element);\n }\n\n for (let i = 0; i < js_urls.length; i++) {\n const url = js_urls[i];\n const element = document.createElement('script');\n element.onload = on_load;\n element.onerror = on_error.bind(null, url);\n element.async = false;\n element.src = url;\n console.debug(\"Bokeh: injecting script tag for BokehJS library: \", url);\n document.head.appendChild(element);\n }\n };\n\n function inject_raw_css(css) {\n const element = document.createElement(\"style\");\n element.appendChild(document.createTextNode(css));\n document.body.appendChild(element);\n }\n\n const js_urls = [\"https://cdn.bokeh.org/bokeh/release/bokeh-3.7.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-gl-3.7.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-3.7.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-3.7.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-mathjax-3.7.1.min.js\"];\n const css_urls = [];\n\n const inline_js = [ function(Bokeh) {\n Bokeh.set_log_level(\"info\");\n },\nfunction(Bokeh) {\n }\n ];\n\n function run_inline_js() {\n if (root.Bokeh !== undefined || force === true) {\n try {\n for (let i = 0; i < inline_js.length; i++) {\n inline_js[i].call(root, root.Bokeh);\n }\n\n } catch (error) {throw error;\n }} else if (Date.now() < root._bokeh_timeout) {\n setTimeout(run_inline_js, 100);\n } else if (!root._bokeh_failed_load) {\n console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n root._bokeh_failed_load = true;\n } else if (force !== true) {\n const cell = $(document.getElementById(null)).parents('.cell').data().cell;\n cell.output_area.append_execute_result(NB_LOAD_WARNING)\n }\n }\n\n if (root._bokeh_is_loading === 0) {\n console.debug(\"Bokeh: BokehJS loaded, going straight to plotting\");\n run_inline_js();\n } else {\n load_libs(css_urls, js_urls, function() {\n console.debug(\"Bokeh: BokehJS plotting callback run at\", now());\n run_inline_js();\n });\n }\n}(window));", "application/vnd.bokehjs_load.v0+json": "" }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "\n", "
\n" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/javascript": "(function(root) {\n function embed_document(root) {\n const docs_json = {\"754c903c-cd4c-4c16-a41b-f4268764eb12\":{\"version\":\"3.7.1\",\"title\":\"Bokeh Application\",\"roots\":[{\"type\":\"object\",\"name\":\"Figure\",\"id\":\"p1219\",\"attributes\":{\"width\":400,\"height\":400,\"x_range\":{\"type\":\"object\",\"name\":\"DataRange1d\",\"id\":\"p1220\"},\"y_range\":{\"type\":\"object\",\"name\":\"DataRange1d\",\"id\":\"p1221\"},\"x_scale\":{\"type\":\"object\",\"name\":\"LinearScale\",\"id\":\"p1228\"},\"y_scale\":{\"type\":\"object\",\"name\":\"LinearScale\",\"id\":\"p1229\"},\"title\":{\"type\":\"object\",\"name\":\"Title\",\"id\":\"p1226\"},\"renderers\":[{\"type\":\"object\",\"name\":\"GraphRenderer\",\"id\":\"p1251\",\"attributes\":{\"layout_provider\":{\"type\":\"object\",\"name\":\"StaticLayoutProvider\",\"id\":\"p1268\",\"attributes\":{\"graph_layout\":{\"type\":\"map\",\"entries\":[[1,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"/P//////7z8r0r56JhLrvw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[2,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"AAAAAAAA8L8r0r56JhLrPw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}]]}}},\"node_renderer\":{\"type\":\"object\",\"name\":\"GlyphRenderer\",\"id\":\"p1256\",\"attributes\":{\"data_source\":{\"type\":\"object\",\"name\":\"ColumnDataSource\",\"id\":\"p1253\",\"attributes\":{\"selected\":{\"type\":\"object\",\"name\":\"Selection\",\"id\":\"p1254\",\"attributes\":{\"indices\":[],\"line_indices\":[]}},\"selection_policy\":{\"type\":\"object\",\"name\":\"UnionRenderers\",\"id\":\"p1255\"},\"data\":{\"type\":\"map\",\"entries\":[[\"type\",[\"Agent\",\"Location\"]],[\"label\",[null,\"Location\"]],[\"bipartite\",[0,1]],[\"index\",[1,2]],[\"_marker\",[\"circle\",\"square\"]],[\"_color\",[\"firebrick\",\"steelblue\"]],[\"_alpha\",[0.5,0.5]],[\"_size\",[10,10]],[\"start_display\",[\"none\",\"none\"]],[\"end_display\",[\"none\",\"none\"]],[\"weight_display\",[\"none\",\"none\"]],[\"index_display\",[1,1]],[\"type_display\",[1,1]],[\"label_display\",[\"none\",1]]]}}},\"view\":{\"type\":\"object\",\"name\":\"CDSView\",\"id\":\"p1257\",\"attributes\":{\"filter\":{\"type\":\"object\",\"name\":\"AllIndices\",\"id\":\"p1258\"}}},\"glyph\":{\"type\":\"object\",\"name\":\"Scatter\",\"id\":\"p1270\",\"attributes\":{\"size\":{\"type\":\"field\",\"field\":\"_size\"},\"line_color\":{\"type\":\"field\",\"field\":\"_color\"},\"line_alpha\":{\"type\":\"field\",\"field\":\"_alpha\"},\"fill_color\":{\"type\":\"field\",\"field\":\"_color\"},\"fill_alpha\":{\"type\":\"field\",\"field\":\"_alpha\"},\"marker\":{\"type\":\"field\",\"field\":\"_marker\"}}}}},\"edge_renderer\":{\"type\":\"object\",\"name\":\"GlyphRenderer\",\"id\":\"p1263\",\"attributes\":{\"data_source\":{\"type\":\"object\",\"name\":\"ColumnDataSource\",\"id\":\"p1260\",\"attributes\":{\"selected\":{\"type\":\"object\",\"name\":\"Selection\",\"id\":\"p1261\",\"attributes\":{\"indices\":[],\"line_indices\":[]}},\"selection_policy\":{\"type\":\"object\",\"name\":\"UnionRenderers\",\"id\":\"p1262\"},\"data\":{\"type\":\"map\",\"entries\":[[\"weight\",[1]],[\"start\",[1]],[\"end\",[2]],[\"_color\",[\"#440154\"]],[\"_alpha\",[1.0]],[\"_size\",[1.0]],[\"start_display\",[1]],[\"end_display\",[1]],[\"weight_display\",[1]],[\"index_display\",[\"none\"]],[\"type_display\",[\"none\"]],[\"label_display\",[\"none\"]]]}}},\"view\":{\"type\":\"object\",\"name\":\"CDSView\",\"id\":\"p1264\",\"attributes\":{\"filter\":{\"type\":\"object\",\"name\":\"AllIndices\",\"id\":\"p1265\"}}},\"glyph\":{\"type\":\"object\",\"name\":\"MultiLine\",\"id\":\"p1269\",\"attributes\":{\"line_color\":{\"type\":\"field\",\"field\":\"_color\"},\"line_alpha\":{\"type\":\"field\",\"field\":\"_alpha\"},\"line_width\":{\"type\":\"field\",\"field\":\"_size\"}}}}},\"selection_policy\":{\"type\":\"object\",\"name\":\"NodesOnly\",\"id\":\"p1266\"},\"inspection_policy\":{\"type\":\"object\",\"name\":\"NodesOnly\",\"id\":\"p1267\"}}}],\"toolbar\":{\"type\":\"object\",\"name\":\"Toolbar\",\"id\":\"p1227\",\"attributes\":{\"tools\":[{\"type\":\"object\",\"name\":\"BoxZoomTool\",\"id\":\"p1240\",\"attributes\":{\"dimensions\":\"both\",\"overlay\":{\"type\":\"object\",\"name\":\"BoxAnnotation\",\"id\":\"p1241\",\"attributes\":{\"syncable\":false,\"line_color\":\"black\",\"line_alpha\":1.0,\"line_width\":2,\"line_dash\":[4,4],\"fill_color\":\"lightgrey\",\"fill_alpha\":0.5,\"level\":\"overlay\",\"visible\":false,\"left\":{\"type\":\"number\",\"value\":\"nan\"},\"right\":{\"type\":\"number\",\"value\":\"nan\"},\"top\":{\"type\":\"number\",\"value\":\"nan\"},\"bottom\":{\"type\":\"number\",\"value\":\"nan\"},\"left_units\":\"canvas\",\"right_units\":\"canvas\",\"top_units\":\"canvas\",\"bottom_units\":\"canvas\",\"handles\":{\"type\":\"object\",\"name\":\"BoxInteractionHandles\",\"id\":\"p1247\",\"attributes\":{\"all\":{\"type\":\"object\",\"name\":\"AreaVisuals\",\"id\":\"p1246\",\"attributes\":{\"fill_color\":\"white\",\"hover_fill_color\":\"lightgray\"}}}}}}}},{\"type\":\"object\",\"name\":\"ResetTool\",\"id\":\"p1248\"},{\"type\":\"object\",\"name\":\"WheelZoomTool\",\"id\":\"p1249\",\"attributes\":{\"renderers\":\"auto\"}},{\"type\":\"object\",\"name\":\"PanTool\",\"id\":\"p1250\"},{\"type\":\"object\",\"name\":\"HoverTool\",\"id\":\"p1271\",\"attributes\":{\"renderers\":[{\"id\":\"p1263\"},{\"id\":\"p1256\"}],\"tooltips\":\"
\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n
start:@start
end:@end
weight:@weight
index:@index
type:@type
label:@label
\",\"line_policy\":\"interp\"}}],\"logo\":null}},\"left\":[{\"type\":\"object\",\"name\":\"LinearAxis\",\"id\":\"p1235\",\"attributes\":{\"visible\":false,\"ticker\":{\"type\":\"object\",\"name\":\"BasicTicker\",\"id\":\"p1236\",\"attributes\":{\"mantissas\":[1,2,5]}},\"formatter\":{\"type\":\"object\",\"name\":\"BasicTickFormatter\",\"id\":\"p1237\"},\"major_label_policy\":{\"type\":\"object\",\"name\":\"AllLabels\",\"id\":\"p1238\"}}}],\"below\":[{\"type\":\"object\",\"name\":\"LinearAxis\",\"id\":\"p1230\",\"attributes\":{\"visible\":false,\"ticker\":{\"type\":\"object\",\"name\":\"BasicTicker\",\"id\":\"p1231\",\"attributes\":{\"mantissas\":[1,2,5]}},\"formatter\":{\"type\":\"object\",\"name\":\"BasicTickFormatter\",\"id\":\"p1232\"},\"major_label_policy\":{\"type\":\"object\",\"name\":\"AllLabels\",\"id\":\"p1233\"}}}],\"center\":[{\"type\":\"object\",\"name\":\"Grid\",\"id\":\"p1234\",\"attributes\":{\"axis\":{\"id\":\"p1230\"},\"grid_line_color\":null}},{\"type\":\"object\",\"name\":\"Grid\",\"id\":\"p1239\",\"attributes\":{\"dimension\":1,\"axis\":{\"id\":\"p1235\"},\"grid_line_color\":null}}]}}]}};\n const render_items = [{\"docid\":\"754c903c-cd4c-4c16-a41b-f4268764eb12\",\"roots\":{\"p1219\":\"a5f7e2c4-d7cf-466f-a4f9-2a0efbc609e7\"},\"root_ids\":[\"p1219\"],\"notebook_comms_target\":\"p1272\"}];\n void root.Bokeh.embed.embed_items_notebook(docs_json, render_items);\n }\n if (root.Bokeh !== undefined) {\n embed_document(root);\n } else {\n let attempts = 0;\n const timer = setInterval(function(root) {\n if (root.Bokeh !== undefined) {\n clearInterval(timer);\n embed_document(root);\n } else {\n attempts++;\n if (attempts > 100) {\n clearInterval(timer);\n console.log(\"Bokeh: ERROR: Unable to run BokehJS code because BokehJS library is missing\");\n }\n }\n }, 10, root)\n }\n})(window);", "application/vnd.bokehjs_exec.v0+json": "" }, "metadata": { "application/vnd.bokehjs_exec.v0+json": { "id": "p1219" } }, "output_type": "display_data" } ], "source": [ "fig = inspector.plot_bipartite_network()" ] }, { "attachments": {}, "cell_type": "markdown", "id": "b95b65d2", "metadata": {}, "source": [ "The attribute `location.agents` shows all agents that are connected to this location:" ] }, { "cell_type": "code", "execution_count": 19, "id": "1cc37edd", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "AgentList (1 object)" ] }, "execution_count": 19, "metadata": {}, "output_type": "execute_result" } ], "source": [ "location.agents" ] }, { "attachments": {}, "cell_type": "markdown", "id": "7f754039", "metadata": {}, "source": [ "The attribute agent.locations shows all locations that are connected to the agent:" ] }, { "cell_type": "code", "execution_count": 20, "id": "069108b7", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "LocationList (1 object)" ] }, "execution_count": 20, "metadata": {}, "output_type": "execute_result" } ], "source": [ "agent.locations" ] }, { "attachments": {}, "cell_type": "markdown", "id": "6f1817a5", "metadata": {}, "source": [ "Let's add 3 more agents to the model using a For-Loop:" ] }, { "cell_type": "code", "execution_count": 21, "id": "0cfdb40b", "metadata": {}, "outputs": [], "source": [ "for _ in range(3):\n", " p2n.Agent(model)" ] }, { "attachments": {}, "cell_type": "markdown", "id": "1b5013b2", "metadata": {}, "source": [ "As you can see, we do not even have to assign the created instances of `Agent` to a variable because their are added to the model automatically during the initialization.\n", "Now we have 4 agents in our model:" ] }, { "cell_type": "code", "execution_count": 22, "id": "a3a572fb", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "AgentList (4 objects)" ] }, "execution_count": 22, "metadata": {}, "output_type": "execute_result" } ], "source": [ "model.agents" ] }, { "attachments": {}, "cell_type": "markdown", "id": "04cbd21d", "metadata": {}, "source": [ "Let's add an additional location.\n", "But now we create our own location class `School` which inherits from `p2n.Location`.\n", "You will understand the purpose of this later." ] }, { "cell_type": "code", "execution_count": 23, "id": "2f5faf56", "metadata": {}, "outputs": [], "source": [ "class School(p2n.Location):\n", " pass" ] }, { "attachments": {}, "cell_type": "markdown", "id": "d70e5da6", "metadata": {}, "source": [ "Again, we only have to initialize the instance of `School` to add it to the model:" ] }, { "cell_type": "code", "execution_count": 24, "id": "4687ea7e", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "School (Obj 6)" ] }, "execution_count": 24, "metadata": {}, "output_type": "execute_result" } ], "source": [ "School(model)" ] }, { "attachments": {}, "cell_type": "markdown", "id": "d4a62c85", "metadata": {}, "source": [ "Now, the model has two locations:" ] }, { "cell_type": "code", "execution_count": 25, "id": "35fae1f4", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "LocationList (2 objects)" ] }, "execution_count": 25, "metadata": {}, "output_type": "execute_result" } ], "source": [ "model.locations" ] }, { "attachments": {}, "cell_type": "markdown", "id": "8fd2458a", "metadata": {}, "source": [ "Let's have a look at the bipartite network graph:" ] }, { "cell_type": "code", "execution_count": 26, "id": "a75a1a2a", "metadata": {}, "outputs": [ { "data": { "application/javascript": "'use strict';\n(function(root) {\n function now() {\n return new Date();\n }\n\n const force = true;\n\n if (typeof root._bokeh_onload_callbacks === \"undefined\" || force === true) {\n root._bokeh_onload_callbacks = [];\n root._bokeh_is_loading = undefined;\n }\n\nconst JS_MIME_TYPE = 'application/javascript';\n const HTML_MIME_TYPE = 'text/html';\n const EXEC_MIME_TYPE = 'application/vnd.bokehjs_exec.v0+json';\n const CLASS_NAME = 'output_bokeh rendered_html';\n\n /**\n * Render data to the DOM node\n */\n function render(props, node) {\n const script = document.createElement(\"script\");\n node.appendChild(script);\n }\n\n /**\n * Handle when an output is cleared or removed\n */\n function handleClearOutput(event, handle) {\n function drop(id) {\n const view = Bokeh.index.get_by_id(id)\n if (view != null) {\n view.model.document.clear()\n Bokeh.index.delete(view)\n }\n }\n\n const cell = handle.cell;\n\n const id = cell.output_area._bokeh_element_id;\n const server_id = cell.output_area._bokeh_server_id;\n\n // Clean up Bokeh references\n if (id != null) {\n drop(id)\n }\n\n if (server_id !== undefined) {\n // Clean up Bokeh references\n const cmd_clean = \"from bokeh.io.state import curstate; print(curstate().uuid_to_server['\" + server_id + \"'].get_sessions()[0].document.roots[0]._id)\";\n cell.notebook.kernel.execute(cmd_clean, {\n iopub: {\n output: function(msg) {\n const id = msg.content.text.trim()\n drop(id)\n }\n }\n });\n // Destroy server and session\n const cmd_destroy = \"import bokeh.io.notebook as ion; ion.destroy_server('\" + server_id + \"')\";\n cell.notebook.kernel.execute(cmd_destroy);\n }\n }\n\n /**\n * Handle when a new output is added\n */\n function handleAddOutput(event, handle) {\n const output_area = handle.output_area;\n const output = handle.output;\n\n // limit handleAddOutput to display_data with EXEC_MIME_TYPE content only\n if ((output.output_type != \"display_data\") || (!Object.prototype.hasOwnProperty.call(output.data, EXEC_MIME_TYPE))) {\n return\n }\n\n const toinsert = output_area.element.find(\".\" + CLASS_NAME.split(' ')[0]);\n\n if (output.metadata[EXEC_MIME_TYPE][\"id\"] !== undefined) {\n toinsert[toinsert.length - 1].firstChild.textContent = output.data[JS_MIME_TYPE];\n // store reference to embed id on output_area\n output_area._bokeh_element_id = output.metadata[EXEC_MIME_TYPE][\"id\"];\n }\n if (output.metadata[EXEC_MIME_TYPE][\"server_id\"] !== undefined) {\n const bk_div = document.createElement(\"div\");\n bk_div.innerHTML = output.data[HTML_MIME_TYPE];\n const script_attrs = bk_div.children[0].attributes;\n for (let i = 0; i < script_attrs.length; i++) {\n toinsert[toinsert.length - 1].firstChild.setAttribute(script_attrs[i].name, script_attrs[i].value);\n toinsert[toinsert.length - 1].firstChild.textContent = bk_div.children[0].textContent\n }\n // store reference to server id on output_area\n output_area._bokeh_server_id = output.metadata[EXEC_MIME_TYPE][\"server_id\"];\n }\n }\n\n function register_renderer(events, OutputArea) {\n\n function append_mime(data, metadata, element) {\n // create a DOM node to render to\n const toinsert = this.create_output_subarea(\n metadata,\n CLASS_NAME,\n EXEC_MIME_TYPE\n );\n this.keyboard_manager.register_events(toinsert);\n // Render to node\n const props = {data: data, metadata: metadata[EXEC_MIME_TYPE]};\n render(props, toinsert[toinsert.length - 1]);\n element.append(toinsert);\n return toinsert\n }\n\n /* Handle when an output is cleared or removed */\n events.on('clear_output.CodeCell', handleClearOutput);\n events.on('delete.Cell', handleClearOutput);\n\n /* Handle when a new output is added */\n events.on('output_added.OutputArea', handleAddOutput);\n\n /**\n * Register the mime type and append_mime function with output_area\n */\n OutputArea.prototype.register_mime_type(EXEC_MIME_TYPE, append_mime, {\n /* Is output safe? */\n safe: true,\n /* Index of renderer in `output_area.display_order` */\n index: 0\n });\n }\n\n // register the mime type if in Jupyter Notebook environment and previously unregistered\n if (root.Jupyter !== undefined) {\n const events = require('base/js/events');\n const OutputArea = require('notebook/js/outputarea').OutputArea;\n\n if (OutputArea.prototype.mime_types().indexOf(EXEC_MIME_TYPE) == -1) {\n register_renderer(events, OutputArea);\n }\n }\n if (typeof (root._bokeh_timeout) === \"undefined\" || force === true) {\n root._bokeh_timeout = Date.now() + 5000;\n root._bokeh_failed_load = false;\n }\n\n const NB_LOAD_WARNING = {'data': {'text/html':\n \"
\\n\"+\n \"

\\n\"+\n \"BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this \\n\"+\n \"may be due to a slow or bad network connection. Possible fixes:\\n\"+\n \"

\\n\"+\n \"\\n\"+\n \"\\n\"+\n \"from bokeh.resources import INLINE\\n\"+\n \"output_notebook(resources=INLINE)\\n\"+\n \"\\n\"+\n \"
\"}};\n\n function display_loaded(error = null) {\n const el = document.getElementById(null);\n if (el != null) {\n const html = (() => {\n if (typeof root.Bokeh === \"undefined\") {\n if (error == null) {\n return \"BokehJS is loading ...\";\n } else {\n return \"BokehJS failed to load.\";\n }\n } else {\n const prefix = `BokehJS ${root.Bokeh.version}`;\n if (error == null) {\n return `${prefix} successfully loaded.`;\n } else {\n return `${prefix} encountered errors while loading and may not function as expected.`;\n }\n }\n })();\n el.innerHTML = html;\n\n if (error != null) {\n const wrapper = document.createElement(\"div\");\n wrapper.style.overflow = \"auto\";\n wrapper.style.height = \"5em\";\n wrapper.style.resize = \"vertical\";\n const content = document.createElement(\"div\");\n content.style.fontFamily = \"monospace\";\n content.style.whiteSpace = \"pre-wrap\";\n content.style.backgroundColor = \"rgb(255, 221, 221)\";\n content.textContent = error.stack ?? error.toString();\n wrapper.append(content);\n el.append(wrapper);\n }\n } else if (Date.now() < root._bokeh_timeout) {\n setTimeout(() => display_loaded(error), 100);\n }\n }\n\n function run_callbacks() {\n try {\n root._bokeh_onload_callbacks.forEach(function(callback) {\n if (callback != null)\n callback();\n });\n } finally {\n delete root._bokeh_onload_callbacks\n }\n console.debug(\"Bokeh: all callbacks have finished\");\n }\n\n function load_libs(css_urls, js_urls, callback) {\n if (css_urls == null) css_urls = [];\n if (js_urls == null) js_urls = [];\n\n root._bokeh_onload_callbacks.push(callback);\n if (root._bokeh_is_loading > 0) {\n console.debug(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n return null;\n }\n if (js_urls == null || js_urls.length === 0) {\n run_callbacks();\n return null;\n }\n console.debug(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n root._bokeh_is_loading = css_urls.length + js_urls.length;\n\n function on_load() {\n root._bokeh_is_loading--;\n if (root._bokeh_is_loading === 0) {\n console.debug(\"Bokeh: all BokehJS libraries/stylesheets loaded\");\n run_callbacks()\n }\n }\n\n function on_error(url) {\n console.error(\"failed to load \" + url);\n }\n\n for (let i = 0; i < css_urls.length; i++) {\n const url = css_urls[i];\n const element = document.createElement(\"link\");\n element.onload = on_load;\n element.onerror = on_error.bind(null, url);\n element.rel = \"stylesheet\";\n element.type = \"text/css\";\n element.href = url;\n console.debug(\"Bokeh: injecting link tag for BokehJS stylesheet: \", url);\n document.body.appendChild(element);\n }\n\n for (let i = 0; i < js_urls.length; i++) {\n const url = js_urls[i];\n const element = document.createElement('script');\n element.onload = on_load;\n element.onerror = on_error.bind(null, url);\n element.async = false;\n element.src = url;\n console.debug(\"Bokeh: injecting script tag for BokehJS library: \", url);\n document.head.appendChild(element);\n }\n };\n\n function inject_raw_css(css) {\n const element = document.createElement(\"style\");\n element.appendChild(document.createTextNode(css));\n document.body.appendChild(element);\n }\n\n const js_urls = [\"https://cdn.bokeh.org/bokeh/release/bokeh-3.7.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-gl-3.7.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-3.7.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-3.7.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-mathjax-3.7.1.min.js\"];\n const css_urls = [];\n\n const inline_js = [ function(Bokeh) {\n Bokeh.set_log_level(\"info\");\n },\nfunction(Bokeh) {\n }\n ];\n\n function run_inline_js() {\n if (root.Bokeh !== undefined || force === true) {\n try {\n for (let i = 0; i < inline_js.length; i++) {\n inline_js[i].call(root, root.Bokeh);\n }\n\n } catch (error) {throw error;\n }} else if (Date.now() < root._bokeh_timeout) {\n setTimeout(run_inline_js, 100);\n } else if (!root._bokeh_failed_load) {\n console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n root._bokeh_failed_load = true;\n } else if (force !== true) {\n const cell = $(document.getElementById(null)).parents('.cell').data().cell;\n cell.output_area.append_execute_result(NB_LOAD_WARNING)\n }\n }\n\n if (root._bokeh_is_loading === 0) {\n console.debug(\"Bokeh: BokehJS loaded, going straight to plotting\");\n run_inline_js();\n } else {\n load_libs(css_urls, js_urls, function() {\n console.debug(\"Bokeh: BokehJS plotting callback run at\", now());\n run_inline_js();\n });\n }\n}(window));", "application/vnd.bokehjs_load.v0+json": "" }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "\n", "
\n" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/javascript": "(function(root) {\n function embed_document(root) {\n const docs_json = {\"273f1039-4970-47b7-924b-a87912b082a7\":{\"version\":\"3.7.1\",\"title\":\"Bokeh Application\",\"roots\":[{\"type\":\"object\",\"name\":\"Figure\",\"id\":\"p1275\",\"attributes\":{\"width\":400,\"height\":400,\"x_range\":{\"type\":\"object\",\"name\":\"DataRange1d\",\"id\":\"p1276\"},\"y_range\":{\"type\":\"object\",\"name\":\"DataRange1d\",\"id\":\"p1277\"},\"x_scale\":{\"type\":\"object\",\"name\":\"LinearScale\",\"id\":\"p1284\"},\"y_scale\":{\"type\":\"object\",\"name\":\"LinearScale\",\"id\":\"p1285\"},\"title\":{\"type\":\"object\",\"name\":\"Title\",\"id\":\"p1282\"},\"renderers\":[{\"type\":\"object\",\"name\":\"GraphRenderer\",\"id\":\"p1307\",\"attributes\":{\"layout_provider\":{\"type\":\"object\",\"name\":\"StaticLayoutProvider\",\"id\":\"p1324\",\"attributes\":{\"graph_layout\":{\"type\":\"map\",\"entries\":[[1,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"8gCn1xf14b/0+DZ7GkPWvw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[2,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"lPfl9X9E5L8qAkHDO1vdvw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[3,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"6ZQM0oa85r+Vuu0lct7iPw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[4,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"vsvsqeY34D/8pCk68bnpPw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[5,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"AAAAAAAA8D+ErxVMhqWQvw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[6,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"YINZ62982T+FtHoODETivw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}]]}}},\"node_renderer\":{\"type\":\"object\",\"name\":\"GlyphRenderer\",\"id\":\"p1312\",\"attributes\":{\"data_source\":{\"type\":\"object\",\"name\":\"ColumnDataSource\",\"id\":\"p1309\",\"attributes\":{\"selected\":{\"type\":\"object\",\"name\":\"Selection\",\"id\":\"p1310\",\"attributes\":{\"indices\":[],\"line_indices\":[]}},\"selection_policy\":{\"type\":\"object\",\"name\":\"UnionRenderers\",\"id\":\"p1311\"},\"data\":{\"type\":\"map\",\"entries\":[[\"type\",[\"Agent\",\"Location\",\"Agent\",\"Agent\",\"Agent\",\"School\"]],[\"label\",[null,\"Location\",null,null,null,\"School\"]],[\"bipartite\",[0,1,0,0,0,1]],[\"index\",[1,2,3,4,5,6]],[\"_marker\",[\"circle\",\"square\",\"circle\",\"circle\",\"circle\",\"square\"]],[\"_color\",[\"firebrick\",\"steelblue\",\"firebrick\",\"firebrick\",\"firebrick\",\"steelblue\"]],[\"_alpha\",[0.5,0.5,0.5,0.5,0.5,0.5]],[\"_size\",[10,10,10,10,10,10]],[\"start_display\",[\"none\",\"none\",\"none\",\"none\",\"none\",\"none\"]],[\"end_display\",[\"none\",\"none\",\"none\",\"none\",\"none\",\"none\"]],[\"weight_display\",[\"none\",\"none\",\"none\",\"none\",\"none\",\"none\"]],[\"index_display\",[1,1,1,1,1,1]],[\"type_display\",[1,1,1,1,1,1]],[\"label_display\",[\"none\",1,\"none\",\"none\",\"none\",1]]]}}},\"view\":{\"type\":\"object\",\"name\":\"CDSView\",\"id\":\"p1313\",\"attributes\":{\"filter\":{\"type\":\"object\",\"name\":\"AllIndices\",\"id\":\"p1314\"}}},\"glyph\":{\"type\":\"object\",\"name\":\"Scatter\",\"id\":\"p1326\",\"attributes\":{\"size\":{\"type\":\"field\",\"field\":\"_size\"},\"line_color\":{\"type\":\"field\",\"field\":\"_color\"},\"line_alpha\":{\"type\":\"field\",\"field\":\"_alpha\"},\"fill_color\":{\"type\":\"field\",\"field\":\"_color\"},\"fill_alpha\":{\"type\":\"field\",\"field\":\"_alpha\"},\"marker\":{\"type\":\"field\",\"field\":\"_marker\"}}}}},\"edge_renderer\":{\"type\":\"object\",\"name\":\"GlyphRenderer\",\"id\":\"p1319\",\"attributes\":{\"data_source\":{\"type\":\"object\",\"name\":\"ColumnDataSource\",\"id\":\"p1316\",\"attributes\":{\"selected\":{\"type\":\"object\",\"name\":\"Selection\",\"id\":\"p1317\",\"attributes\":{\"indices\":[],\"line_indices\":[]}},\"selection_policy\":{\"type\":\"object\",\"name\":\"UnionRenderers\",\"id\":\"p1318\"},\"data\":{\"type\":\"map\",\"entries\":[[\"weight\",[1]],[\"start\",[1]],[\"end\",[2]],[\"_color\",[\"#440154\"]],[\"_alpha\",[1.0]],[\"_size\",[1.0]],[\"start_display\",[1]],[\"end_display\",[1]],[\"weight_display\",[1]],[\"index_display\",[\"none\"]],[\"type_display\",[\"none\"]],[\"label_display\",[\"none\"]]]}}},\"view\":{\"type\":\"object\",\"name\":\"CDSView\",\"id\":\"p1320\",\"attributes\":{\"filter\":{\"type\":\"object\",\"name\":\"AllIndices\",\"id\":\"p1321\"}}},\"glyph\":{\"type\":\"object\",\"name\":\"MultiLine\",\"id\":\"p1325\",\"attributes\":{\"line_color\":{\"type\":\"field\",\"field\":\"_color\"},\"line_alpha\":{\"type\":\"field\",\"field\":\"_alpha\"},\"line_width\":{\"type\":\"field\",\"field\":\"_size\"}}}}},\"selection_policy\":{\"type\":\"object\",\"name\":\"NodesOnly\",\"id\":\"p1322\"},\"inspection_policy\":{\"type\":\"object\",\"name\":\"NodesOnly\",\"id\":\"p1323\"}}}],\"toolbar\":{\"type\":\"object\",\"name\":\"Toolbar\",\"id\":\"p1283\",\"attributes\":{\"tools\":[{\"type\":\"object\",\"name\":\"BoxZoomTool\",\"id\":\"p1296\",\"attributes\":{\"dimensions\":\"both\",\"overlay\":{\"type\":\"object\",\"name\":\"BoxAnnotation\",\"id\":\"p1297\",\"attributes\":{\"syncable\":false,\"line_color\":\"black\",\"line_alpha\":1.0,\"line_width\":2,\"line_dash\":[4,4],\"fill_color\":\"lightgrey\",\"fill_alpha\":0.5,\"level\":\"overlay\",\"visible\":false,\"left\":{\"type\":\"number\",\"value\":\"nan\"},\"right\":{\"type\":\"number\",\"value\":\"nan\"},\"top\":{\"type\":\"number\",\"value\":\"nan\"},\"bottom\":{\"type\":\"number\",\"value\":\"nan\"},\"left_units\":\"canvas\",\"right_units\":\"canvas\",\"top_units\":\"canvas\",\"bottom_units\":\"canvas\",\"handles\":{\"type\":\"object\",\"name\":\"BoxInteractionHandles\",\"id\":\"p1303\",\"attributes\":{\"all\":{\"type\":\"object\",\"name\":\"AreaVisuals\",\"id\":\"p1302\",\"attributes\":{\"fill_color\":\"white\",\"hover_fill_color\":\"lightgray\"}}}}}}}},{\"type\":\"object\",\"name\":\"ResetTool\",\"id\":\"p1304\"},{\"type\":\"object\",\"name\":\"WheelZoomTool\",\"id\":\"p1305\",\"attributes\":{\"renderers\":\"auto\"}},{\"type\":\"object\",\"name\":\"PanTool\",\"id\":\"p1306\"},{\"type\":\"object\",\"name\":\"HoverTool\",\"id\":\"p1327\",\"attributes\":{\"renderers\":[{\"id\":\"p1319\"},{\"id\":\"p1312\"}],\"tooltips\":\"
\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n
start:@start
end:@end
weight:@weight
index:@index
type:@type
label:@label
\",\"line_policy\":\"interp\"}}],\"logo\":null}},\"left\":[{\"type\":\"object\",\"name\":\"LinearAxis\",\"id\":\"p1291\",\"attributes\":{\"visible\":false,\"ticker\":{\"type\":\"object\",\"name\":\"BasicTicker\",\"id\":\"p1292\",\"attributes\":{\"mantissas\":[1,2,5]}},\"formatter\":{\"type\":\"object\",\"name\":\"BasicTickFormatter\",\"id\":\"p1293\"},\"major_label_policy\":{\"type\":\"object\",\"name\":\"AllLabels\",\"id\":\"p1294\"}}}],\"below\":[{\"type\":\"object\",\"name\":\"LinearAxis\",\"id\":\"p1286\",\"attributes\":{\"visible\":false,\"ticker\":{\"type\":\"object\",\"name\":\"BasicTicker\",\"id\":\"p1287\",\"attributes\":{\"mantissas\":[1,2,5]}},\"formatter\":{\"type\":\"object\",\"name\":\"BasicTickFormatter\",\"id\":\"p1288\"},\"major_label_policy\":{\"type\":\"object\",\"name\":\"AllLabels\",\"id\":\"p1289\"}}}],\"center\":[{\"type\":\"object\",\"name\":\"Grid\",\"id\":\"p1290\",\"attributes\":{\"axis\":{\"id\":\"p1286\"},\"grid_line_color\":null}},{\"type\":\"object\",\"name\":\"Grid\",\"id\":\"p1295\",\"attributes\":{\"dimension\":1,\"axis\":{\"id\":\"p1291\"},\"grid_line_color\":null}}]}}]}};\n const render_items = [{\"docid\":\"273f1039-4970-47b7-924b-a87912b082a7\",\"roots\":{\"p1275\":\"f6c36f17-5fad-4a10-ac85-4466d078bce5\"},\"root_ids\":[\"p1275\"],\"notebook_comms_target\":\"p1328\"}];\n void root.Bokeh.embed.embed_items_notebook(docs_json, render_items);\n }\n if (root.Bokeh !== undefined) {\n embed_document(root);\n } else {\n let attempts = 0;\n const timer = setInterval(function(root) {\n if (root.Bokeh !== undefined) {\n clearInterval(timer);\n embed_document(root);\n } else {\n attempts++;\n if (attempts > 100) {\n clearInterval(timer);\n console.log(\"Bokeh: ERROR: Unable to run BokehJS code because BokehJS library is missing\");\n }\n }\n }, 10, root)\n }\n})(window);", "application/vnd.bokehjs_exec.v0+json": "" }, "metadata": { "application/vnd.bokehjs_exec.v0+json": { "id": "p1275" } }, "output_type": "display_data" } ], "source": [ "inspector.plot_bipartite_network()" ] }, { "attachments": {}, "cell_type": "markdown", "id": "4b35e772", "metadata": {}, "source": [ "Because there is still only one edge, in the next step, we assign each agent to one location and make sure that each location has not more than 2 agents:" ] }, { "cell_type": "code", "execution_count": 27, "id": "b64df7f5", "metadata": {}, "outputs": [], "source": [ "for location in model.locations:\n", " for agent in model.agents:\n", " if len(location.agents) < 2 and len(agent.locations) == 0:\n", " location.add_agent(agent)" ] }, { "attachments": {}, "cell_type": "markdown", "id": "89952359", "metadata": {}, "source": [ "Let's look at the graph again:" ] }, { "cell_type": "code", "execution_count": 28, "id": "a05284e1", "metadata": {}, "outputs": [ { "data": { "application/javascript": "'use strict';\n(function(root) {\n function now() {\n return new Date();\n }\n\n const force = true;\n\n if (typeof root._bokeh_onload_callbacks === \"undefined\" || force === true) {\n root._bokeh_onload_callbacks = [];\n root._bokeh_is_loading = undefined;\n }\n\nconst JS_MIME_TYPE = 'application/javascript';\n const HTML_MIME_TYPE = 'text/html';\n const EXEC_MIME_TYPE = 'application/vnd.bokehjs_exec.v0+json';\n const CLASS_NAME = 'output_bokeh rendered_html';\n\n /**\n * Render data to the DOM node\n */\n function render(props, node) {\n const script = document.createElement(\"script\");\n node.appendChild(script);\n }\n\n /**\n * Handle when an output is cleared or removed\n */\n function handleClearOutput(event, handle) {\n function drop(id) {\n const view = Bokeh.index.get_by_id(id)\n if (view != null) {\n view.model.document.clear()\n Bokeh.index.delete(view)\n }\n }\n\n const cell = handle.cell;\n\n const id = cell.output_area._bokeh_element_id;\n const server_id = cell.output_area._bokeh_server_id;\n\n // Clean up Bokeh references\n if (id != null) {\n drop(id)\n }\n\n if (server_id !== undefined) {\n // Clean up Bokeh references\n const cmd_clean = \"from bokeh.io.state import curstate; print(curstate().uuid_to_server['\" + server_id + \"'].get_sessions()[0].document.roots[0]._id)\";\n cell.notebook.kernel.execute(cmd_clean, {\n iopub: {\n output: function(msg) {\n const id = msg.content.text.trim()\n drop(id)\n }\n }\n });\n // Destroy server and session\n const cmd_destroy = \"import bokeh.io.notebook as ion; ion.destroy_server('\" + server_id + \"')\";\n cell.notebook.kernel.execute(cmd_destroy);\n }\n }\n\n /**\n * Handle when a new output is added\n */\n function handleAddOutput(event, handle) {\n const output_area = handle.output_area;\n const output = handle.output;\n\n // limit handleAddOutput to display_data with EXEC_MIME_TYPE content only\n if ((output.output_type != \"display_data\") || (!Object.prototype.hasOwnProperty.call(output.data, EXEC_MIME_TYPE))) {\n return\n }\n\n const toinsert = output_area.element.find(\".\" + CLASS_NAME.split(' ')[0]);\n\n if (output.metadata[EXEC_MIME_TYPE][\"id\"] !== undefined) {\n toinsert[toinsert.length - 1].firstChild.textContent = output.data[JS_MIME_TYPE];\n // store reference to embed id on output_area\n output_area._bokeh_element_id = output.metadata[EXEC_MIME_TYPE][\"id\"];\n }\n if (output.metadata[EXEC_MIME_TYPE][\"server_id\"] !== undefined) {\n const bk_div = document.createElement(\"div\");\n bk_div.innerHTML = output.data[HTML_MIME_TYPE];\n const script_attrs = bk_div.children[0].attributes;\n for (let i = 0; i < script_attrs.length; i++) {\n toinsert[toinsert.length - 1].firstChild.setAttribute(script_attrs[i].name, script_attrs[i].value);\n toinsert[toinsert.length - 1].firstChild.textContent = bk_div.children[0].textContent\n }\n // store reference to server id on output_area\n output_area._bokeh_server_id = output.metadata[EXEC_MIME_TYPE][\"server_id\"];\n }\n }\n\n function register_renderer(events, OutputArea) {\n\n function append_mime(data, metadata, element) {\n // create a DOM node to render to\n const toinsert = this.create_output_subarea(\n metadata,\n CLASS_NAME,\n EXEC_MIME_TYPE\n );\n this.keyboard_manager.register_events(toinsert);\n // Render to node\n const props = {data: data, metadata: metadata[EXEC_MIME_TYPE]};\n render(props, toinsert[toinsert.length - 1]);\n element.append(toinsert);\n return toinsert\n }\n\n /* Handle when an output is cleared or removed */\n events.on('clear_output.CodeCell', handleClearOutput);\n events.on('delete.Cell', handleClearOutput);\n\n /* Handle when a new output is added */\n events.on('output_added.OutputArea', handleAddOutput);\n\n /**\n * Register the mime type and append_mime function with output_area\n */\n OutputArea.prototype.register_mime_type(EXEC_MIME_TYPE, append_mime, {\n /* Is output safe? */\n safe: true,\n /* Index of renderer in `output_area.display_order` */\n index: 0\n });\n }\n\n // register the mime type if in Jupyter Notebook environment and previously unregistered\n if (root.Jupyter !== undefined) {\n const events = require('base/js/events');\n const OutputArea = require('notebook/js/outputarea').OutputArea;\n\n if (OutputArea.prototype.mime_types().indexOf(EXEC_MIME_TYPE) == -1) {\n register_renderer(events, OutputArea);\n }\n }\n if (typeof (root._bokeh_timeout) === \"undefined\" || force === true) {\n root._bokeh_timeout = Date.now() + 5000;\n root._bokeh_failed_load = false;\n }\n\n const NB_LOAD_WARNING = {'data': {'text/html':\n \"
\\n\"+\n \"

\\n\"+\n \"BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this \\n\"+\n \"may be due to a slow or bad network connection. Possible fixes:\\n\"+\n \"

\\n\"+\n \"\\n\"+\n \"\\n\"+\n \"from bokeh.resources import INLINE\\n\"+\n \"output_notebook(resources=INLINE)\\n\"+\n \"\\n\"+\n \"
\"}};\n\n function display_loaded(error = null) {\n const el = document.getElementById(null);\n if (el != null) {\n const html = (() => {\n if (typeof root.Bokeh === \"undefined\") {\n if (error == null) {\n return \"BokehJS is loading ...\";\n } else {\n return \"BokehJS failed to load.\";\n }\n } else {\n const prefix = `BokehJS ${root.Bokeh.version}`;\n if (error == null) {\n return `${prefix} successfully loaded.`;\n } else {\n return `${prefix} encountered errors while loading and may not function as expected.`;\n }\n }\n })();\n el.innerHTML = html;\n\n if (error != null) {\n const wrapper = document.createElement(\"div\");\n wrapper.style.overflow = \"auto\";\n wrapper.style.height = \"5em\";\n wrapper.style.resize = \"vertical\";\n const content = document.createElement(\"div\");\n content.style.fontFamily = \"monospace\";\n content.style.whiteSpace = \"pre-wrap\";\n content.style.backgroundColor = \"rgb(255, 221, 221)\";\n content.textContent = error.stack ?? error.toString();\n wrapper.append(content);\n el.append(wrapper);\n }\n } else if (Date.now() < root._bokeh_timeout) {\n setTimeout(() => display_loaded(error), 100);\n }\n }\n\n function run_callbacks() {\n try {\n root._bokeh_onload_callbacks.forEach(function(callback) {\n if (callback != null)\n callback();\n });\n } finally {\n delete root._bokeh_onload_callbacks\n }\n console.debug(\"Bokeh: all callbacks have finished\");\n }\n\n function load_libs(css_urls, js_urls, callback) {\n if (css_urls == null) css_urls = [];\n if (js_urls == null) js_urls = [];\n\n root._bokeh_onload_callbacks.push(callback);\n if (root._bokeh_is_loading > 0) {\n console.debug(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n return null;\n }\n if (js_urls == null || js_urls.length === 0) {\n run_callbacks();\n return null;\n }\n console.debug(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n root._bokeh_is_loading = css_urls.length + js_urls.length;\n\n function on_load() {\n root._bokeh_is_loading--;\n if (root._bokeh_is_loading === 0) {\n console.debug(\"Bokeh: all BokehJS libraries/stylesheets loaded\");\n run_callbacks()\n }\n }\n\n function on_error(url) {\n console.error(\"failed to load \" + url);\n }\n\n for (let i = 0; i < css_urls.length; i++) {\n const url = css_urls[i];\n const element = document.createElement(\"link\");\n element.onload = on_load;\n element.onerror = on_error.bind(null, url);\n element.rel = \"stylesheet\";\n element.type = \"text/css\";\n element.href = url;\n console.debug(\"Bokeh: injecting link tag for BokehJS stylesheet: \", url);\n document.body.appendChild(element);\n }\n\n for (let i = 0; i < js_urls.length; i++) {\n const url = js_urls[i];\n const element = document.createElement('script');\n element.onload = on_load;\n element.onerror = on_error.bind(null, url);\n element.async = false;\n element.src = url;\n console.debug(\"Bokeh: injecting script tag for BokehJS library: \", url);\n document.head.appendChild(element);\n }\n };\n\n function inject_raw_css(css) {\n const element = document.createElement(\"style\");\n element.appendChild(document.createTextNode(css));\n document.body.appendChild(element);\n }\n\n const js_urls = [\"https://cdn.bokeh.org/bokeh/release/bokeh-3.7.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-gl-3.7.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-3.7.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-3.7.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-mathjax-3.7.1.min.js\"];\n const css_urls = [];\n\n const inline_js = [ function(Bokeh) {\n Bokeh.set_log_level(\"info\");\n },\nfunction(Bokeh) {\n }\n ];\n\n function run_inline_js() {\n if (root.Bokeh !== undefined || force === true) {\n try {\n for (let i = 0; i < inline_js.length; i++) {\n inline_js[i].call(root, root.Bokeh);\n }\n\n } catch (error) {throw error;\n }} else if (Date.now() < root._bokeh_timeout) {\n setTimeout(run_inline_js, 100);\n } else if (!root._bokeh_failed_load) {\n console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n root._bokeh_failed_load = true;\n } else if (force !== true) {\n const cell = $(document.getElementById(null)).parents('.cell').data().cell;\n cell.output_area.append_execute_result(NB_LOAD_WARNING)\n }\n }\n\n if (root._bokeh_is_loading === 0) {\n console.debug(\"Bokeh: BokehJS loaded, going straight to plotting\");\n run_inline_js();\n } else {\n load_libs(css_urls, js_urls, function() {\n console.debug(\"Bokeh: BokehJS plotting callback run at\", now());\n run_inline_js();\n });\n }\n}(window));", "application/vnd.bokehjs_load.v0+json": "" }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "\n", "
\n" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/javascript": "(function(root) {\n function embed_document(root) {\n const docs_json = {\"e2bca0e0-6832-4880-bb7d-9c13c541cf3b\":{\"version\":\"3.7.1\",\"title\":\"Bokeh Application\",\"roots\":[{\"type\":\"object\",\"name\":\"Figure\",\"id\":\"p1335\",\"attributes\":{\"width\":400,\"height\":400,\"x_range\":{\"type\":\"object\",\"name\":\"DataRange1d\",\"id\":\"p1336\"},\"y_range\":{\"type\":\"object\",\"name\":\"DataRange1d\",\"id\":\"p1337\"},\"x_scale\":{\"type\":\"object\",\"name\":\"LinearScale\",\"id\":\"p1344\"},\"y_scale\":{\"type\":\"object\",\"name\":\"LinearScale\",\"id\":\"p1345\"},\"title\":{\"type\":\"object\",\"name\":\"Title\",\"id\":\"p1342\"},\"renderers\":[{\"type\":\"object\",\"name\":\"GraphRenderer\",\"id\":\"p1367\",\"attributes\":{\"layout_provider\":{\"type\":\"object\",\"name\":\"StaticLayoutProvider\",\"id\":\"p1384\",\"attributes\":{\"graph_layout\":{\"type\":\"map\",\"entries\":[[1,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"vqU7tl2r4L/xrEstFy3pvw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[2,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"9tZYfggvxr9Bf9gY+nfkvw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[3,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"P9bafRkmpz97vS/HRlPuvw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[4,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"AqwZPVT9o7/////////vPw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[5,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"PIukqVnE4D92pqiysQHmPw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[6,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"avaEYOcAxT84Q6tapvblPw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}]]}}},\"node_renderer\":{\"type\":\"object\",\"name\":\"GlyphRenderer\",\"id\":\"p1372\",\"attributes\":{\"data_source\":{\"type\":\"object\",\"name\":\"ColumnDataSource\",\"id\":\"p1369\",\"attributes\":{\"selected\":{\"type\":\"object\",\"name\":\"Selection\",\"id\":\"p1370\",\"attributes\":{\"indices\":[],\"line_indices\":[]}},\"selection_policy\":{\"type\":\"object\",\"name\":\"UnionRenderers\",\"id\":\"p1371\"},\"data\":{\"type\":\"map\",\"entries\":[[\"type\",[\"Agent\",\"Location\",\"Agent\",\"Agent\",\"Agent\",\"School\"]],[\"label\",[null,\"Location\",null,null,null,\"School\"]],[\"bipartite\",[0,1,0,0,0,1]],[\"index\",[1,2,3,4,5,6]],[\"_marker\",[\"circle\",\"square\",\"circle\",\"circle\",\"circle\",\"square\"]],[\"_color\",[\"firebrick\",\"steelblue\",\"firebrick\",\"firebrick\",\"firebrick\",\"steelblue\"]],[\"_alpha\",[0.5,0.5,0.5,0.5,0.5,0.5]],[\"_size\",[10,10,10,10,10,10]],[\"start_display\",[\"none\",\"none\",\"none\",\"none\",\"none\",\"none\"]],[\"end_display\",[\"none\",\"none\",\"none\",\"none\",\"none\",\"none\"]],[\"weight_display\",[\"none\",\"none\",\"none\",\"none\",\"none\",\"none\"]],[\"index_display\",[1,1,1,1,1,1]],[\"type_display\",[1,1,1,1,1,1]],[\"label_display\",[\"none\",1,\"none\",\"none\",\"none\",1]]]}}},\"view\":{\"type\":\"object\",\"name\":\"CDSView\",\"id\":\"p1373\",\"attributes\":{\"filter\":{\"type\":\"object\",\"name\":\"AllIndices\",\"id\":\"p1374\"}}},\"glyph\":{\"type\":\"object\",\"name\":\"Scatter\",\"id\":\"p1386\",\"attributes\":{\"size\":{\"type\":\"field\",\"field\":\"_size\"},\"line_color\":{\"type\":\"field\",\"field\":\"_color\"},\"line_alpha\":{\"type\":\"field\",\"field\":\"_alpha\"},\"fill_color\":{\"type\":\"field\",\"field\":\"_color\"},\"fill_alpha\":{\"type\":\"field\",\"field\":\"_alpha\"},\"marker\":{\"type\":\"field\",\"field\":\"_marker\"}}}}},\"edge_renderer\":{\"type\":\"object\",\"name\":\"GlyphRenderer\",\"id\":\"p1379\",\"attributes\":{\"data_source\":{\"type\":\"object\",\"name\":\"ColumnDataSource\",\"id\":\"p1376\",\"attributes\":{\"selected\":{\"type\":\"object\",\"name\":\"Selection\",\"id\":\"p1377\",\"attributes\":{\"indices\":[],\"line_indices\":[]}},\"selection_policy\":{\"type\":\"object\",\"name\":\"UnionRenderers\",\"id\":\"p1378\"},\"data\":{\"type\":\"map\",\"entries\":[[\"weight\",[1,1,1,1]],[\"start\",[1,2,4,5]],[\"end\",[2,3,6,6]],[\"_color\",[\"#440154\",\"#440154\",\"#440154\",\"#440154\"]],[\"_alpha\",[1.0,1.0,1.0,1.0]],[\"_size\",[1.0,1.0,1.0,1.0]],[\"start_display\",[1,1,1,1]],[\"end_display\",[1,1,1,1]],[\"weight_display\",[1,1,1,1]],[\"index_display\",[\"none\",\"none\",\"none\",\"none\"]],[\"type_display\",[\"none\",\"none\",\"none\",\"none\"]],[\"label_display\",[\"none\",\"none\",\"none\",\"none\"]]]}}},\"view\":{\"type\":\"object\",\"name\":\"CDSView\",\"id\":\"p1380\",\"attributes\":{\"filter\":{\"type\":\"object\",\"name\":\"AllIndices\",\"id\":\"p1381\"}}},\"glyph\":{\"type\":\"object\",\"name\":\"MultiLine\",\"id\":\"p1385\",\"attributes\":{\"line_color\":{\"type\":\"field\",\"field\":\"_color\"},\"line_alpha\":{\"type\":\"field\",\"field\":\"_alpha\"},\"line_width\":{\"type\":\"field\",\"field\":\"_size\"}}}}},\"selection_policy\":{\"type\":\"object\",\"name\":\"NodesOnly\",\"id\":\"p1382\"},\"inspection_policy\":{\"type\":\"object\",\"name\":\"NodesOnly\",\"id\":\"p1383\"}}}],\"toolbar\":{\"type\":\"object\",\"name\":\"Toolbar\",\"id\":\"p1343\",\"attributes\":{\"tools\":[{\"type\":\"object\",\"name\":\"BoxZoomTool\",\"id\":\"p1356\",\"attributes\":{\"dimensions\":\"both\",\"overlay\":{\"type\":\"object\",\"name\":\"BoxAnnotation\",\"id\":\"p1357\",\"attributes\":{\"syncable\":false,\"line_color\":\"black\",\"line_alpha\":1.0,\"line_width\":2,\"line_dash\":[4,4],\"fill_color\":\"lightgrey\",\"fill_alpha\":0.5,\"level\":\"overlay\",\"visible\":false,\"left\":{\"type\":\"number\",\"value\":\"nan\"},\"right\":{\"type\":\"number\",\"value\":\"nan\"},\"top\":{\"type\":\"number\",\"value\":\"nan\"},\"bottom\":{\"type\":\"number\",\"value\":\"nan\"},\"left_units\":\"canvas\",\"right_units\":\"canvas\",\"top_units\":\"canvas\",\"bottom_units\":\"canvas\",\"handles\":{\"type\":\"object\",\"name\":\"BoxInteractionHandles\",\"id\":\"p1363\",\"attributes\":{\"all\":{\"type\":\"object\",\"name\":\"AreaVisuals\",\"id\":\"p1362\",\"attributes\":{\"fill_color\":\"white\",\"hover_fill_color\":\"lightgray\"}}}}}}}},{\"type\":\"object\",\"name\":\"ResetTool\",\"id\":\"p1364\"},{\"type\":\"object\",\"name\":\"WheelZoomTool\",\"id\":\"p1365\",\"attributes\":{\"renderers\":\"auto\"}},{\"type\":\"object\",\"name\":\"PanTool\",\"id\":\"p1366\"},{\"type\":\"object\",\"name\":\"HoverTool\",\"id\":\"p1387\",\"attributes\":{\"renderers\":[{\"id\":\"p1379\"},{\"id\":\"p1372\"}],\"tooltips\":\"
\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n
start:@start
end:@end
weight:@weight
index:@index
type:@type
label:@label
\",\"line_policy\":\"interp\"}}],\"logo\":null}},\"left\":[{\"type\":\"object\",\"name\":\"LinearAxis\",\"id\":\"p1351\",\"attributes\":{\"visible\":false,\"ticker\":{\"type\":\"object\",\"name\":\"BasicTicker\",\"id\":\"p1352\",\"attributes\":{\"mantissas\":[1,2,5]}},\"formatter\":{\"type\":\"object\",\"name\":\"BasicTickFormatter\",\"id\":\"p1353\"},\"major_label_policy\":{\"type\":\"object\",\"name\":\"AllLabels\",\"id\":\"p1354\"}}}],\"below\":[{\"type\":\"object\",\"name\":\"LinearAxis\",\"id\":\"p1346\",\"attributes\":{\"visible\":false,\"ticker\":{\"type\":\"object\",\"name\":\"BasicTicker\",\"id\":\"p1347\",\"attributes\":{\"mantissas\":[1,2,5]}},\"formatter\":{\"type\":\"object\",\"name\":\"BasicTickFormatter\",\"id\":\"p1348\"},\"major_label_policy\":{\"type\":\"object\",\"name\":\"AllLabels\",\"id\":\"p1349\"}}}],\"center\":[{\"type\":\"object\",\"name\":\"Grid\",\"id\":\"p1350\",\"attributes\":{\"axis\":{\"id\":\"p1346\"},\"grid_line_color\":null}},{\"type\":\"object\",\"name\":\"Grid\",\"id\":\"p1355\",\"attributes\":{\"dimension\":1,\"axis\":{\"id\":\"p1351\"},\"grid_line_color\":null}}]}}]}};\n const render_items = [{\"docid\":\"e2bca0e0-6832-4880-bb7d-9c13c541cf3b\",\"roots\":{\"p1335\":\"e026cc33-214e-4baf-be43-0557c63fa5a8\"},\"root_ids\":[\"p1335\"],\"notebook_comms_target\":\"p1388\"}];\n void root.Bokeh.embed.embed_items_notebook(docs_json, render_items);\n }\n if (root.Bokeh !== undefined) {\n embed_document(root);\n } else {\n let attempts = 0;\n const timer = setInterval(function(root) {\n if (root.Bokeh !== undefined) {\n clearInterval(timer);\n embed_document(root);\n } else {\n attempts++;\n if (attempts > 100) {\n clearInterval(timer);\n console.log(\"Bokeh: ERROR: Unable to run BokehJS code because BokehJS library is missing\");\n }\n }\n }, 10, root)\n }\n})(window);", "application/vnd.bokehjs_exec.v0+json": "" }, "metadata": { "application/vnd.bokehjs_exec.v0+json": { "id": "p1335" } }, "output_type": "display_data" } ], "source": [ "inspector.plot_bipartite_network()" ] }, { "attachments": {}, "cell_type": "markdown", "id": "09d279cf", "metadata": {}, "source": [ "Just because we can, let's create some more edges by adding a single agent to all locations.\n", "This time, we'll use [`agent.add_locations()`](https://mariuzka.github.io/pop2net/api/location.html#pop2net.Location.add_agents) to assign one agent to multiple locations at once.\n", "(Alternatively, if you need to add multiple agents to a single location, you can use [`location.add_agents()`](https://mariuzka.github.io/pop2net/api/location.html#pop2net.Location.add_agents).)" ] }, { "cell_type": "code", "execution_count": 29, "id": "43f66dae", "metadata": {}, "outputs": [], "source": [ "agent = model.agents[0]\n", "\n", "agent.add_locations(model.locations)" ] }, { "cell_type": "code", "execution_count": 30, "id": "d16d40ce", "metadata": {}, "outputs": [ { "data": { "application/javascript": "'use strict';\n(function(root) {\n function now() {\n return new Date();\n }\n\n const force = true;\n\n if (typeof root._bokeh_onload_callbacks === \"undefined\" || force === true) {\n root._bokeh_onload_callbacks = [];\n root._bokeh_is_loading = undefined;\n }\n\nconst JS_MIME_TYPE = 'application/javascript';\n const HTML_MIME_TYPE = 'text/html';\n const EXEC_MIME_TYPE = 'application/vnd.bokehjs_exec.v0+json';\n const CLASS_NAME = 'output_bokeh rendered_html';\n\n /**\n * Render data to the DOM node\n */\n function render(props, node) {\n const script = document.createElement(\"script\");\n node.appendChild(script);\n }\n\n /**\n * Handle when an output is cleared or removed\n */\n function handleClearOutput(event, handle) {\n function drop(id) {\n const view = Bokeh.index.get_by_id(id)\n if (view != null) {\n view.model.document.clear()\n Bokeh.index.delete(view)\n }\n }\n\n const cell = handle.cell;\n\n const id = cell.output_area._bokeh_element_id;\n const server_id = cell.output_area._bokeh_server_id;\n\n // Clean up Bokeh references\n if (id != null) {\n drop(id)\n }\n\n if (server_id !== undefined) {\n // Clean up Bokeh references\n const cmd_clean = \"from bokeh.io.state import curstate; print(curstate().uuid_to_server['\" + server_id + \"'].get_sessions()[0].document.roots[0]._id)\";\n cell.notebook.kernel.execute(cmd_clean, {\n iopub: {\n output: function(msg) {\n const id = msg.content.text.trim()\n drop(id)\n }\n }\n });\n // Destroy server and session\n const cmd_destroy = \"import bokeh.io.notebook as ion; ion.destroy_server('\" + server_id + \"')\";\n cell.notebook.kernel.execute(cmd_destroy);\n }\n }\n\n /**\n * Handle when a new output is added\n */\n function handleAddOutput(event, handle) {\n const output_area = handle.output_area;\n const output = handle.output;\n\n // limit handleAddOutput to display_data with EXEC_MIME_TYPE content only\n if ((output.output_type != \"display_data\") || (!Object.prototype.hasOwnProperty.call(output.data, EXEC_MIME_TYPE))) {\n return\n }\n\n const toinsert = output_area.element.find(\".\" + CLASS_NAME.split(' ')[0]);\n\n if (output.metadata[EXEC_MIME_TYPE][\"id\"] !== undefined) {\n toinsert[toinsert.length - 1].firstChild.textContent = output.data[JS_MIME_TYPE];\n // store reference to embed id on output_area\n output_area._bokeh_element_id = output.metadata[EXEC_MIME_TYPE][\"id\"];\n }\n if (output.metadata[EXEC_MIME_TYPE][\"server_id\"] !== undefined) {\n const bk_div = document.createElement(\"div\");\n bk_div.innerHTML = output.data[HTML_MIME_TYPE];\n const script_attrs = bk_div.children[0].attributes;\n for (let i = 0; i < script_attrs.length; i++) {\n toinsert[toinsert.length - 1].firstChild.setAttribute(script_attrs[i].name, script_attrs[i].value);\n toinsert[toinsert.length - 1].firstChild.textContent = bk_div.children[0].textContent\n }\n // store reference to server id on output_area\n output_area._bokeh_server_id = output.metadata[EXEC_MIME_TYPE][\"server_id\"];\n }\n }\n\n function register_renderer(events, OutputArea) {\n\n function append_mime(data, metadata, element) {\n // create a DOM node to render to\n const toinsert = this.create_output_subarea(\n metadata,\n CLASS_NAME,\n EXEC_MIME_TYPE\n );\n this.keyboard_manager.register_events(toinsert);\n // Render to node\n const props = {data: data, metadata: metadata[EXEC_MIME_TYPE]};\n render(props, toinsert[toinsert.length - 1]);\n element.append(toinsert);\n return toinsert\n }\n\n /* Handle when an output is cleared or removed */\n events.on('clear_output.CodeCell', handleClearOutput);\n events.on('delete.Cell', handleClearOutput);\n\n /* Handle when a new output is added */\n events.on('output_added.OutputArea', handleAddOutput);\n\n /**\n * Register the mime type and append_mime function with output_area\n */\n OutputArea.prototype.register_mime_type(EXEC_MIME_TYPE, append_mime, {\n /* Is output safe? */\n safe: true,\n /* Index of renderer in `output_area.display_order` */\n index: 0\n });\n }\n\n // register the mime type if in Jupyter Notebook environment and previously unregistered\n if (root.Jupyter !== undefined) {\n const events = require('base/js/events');\n const OutputArea = require('notebook/js/outputarea').OutputArea;\n\n if (OutputArea.prototype.mime_types().indexOf(EXEC_MIME_TYPE) == -1) {\n register_renderer(events, OutputArea);\n }\n }\n if (typeof (root._bokeh_timeout) === \"undefined\" || force === true) {\n root._bokeh_timeout = Date.now() + 5000;\n root._bokeh_failed_load = false;\n }\n\n const NB_LOAD_WARNING = {'data': {'text/html':\n \"
\\n\"+\n \"

\\n\"+\n \"BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this \\n\"+\n \"may be due to a slow or bad network connection. Possible fixes:\\n\"+\n \"

\\n\"+\n \"\\n\"+\n \"\\n\"+\n \"from bokeh.resources import INLINE\\n\"+\n \"output_notebook(resources=INLINE)\\n\"+\n \"\\n\"+\n \"
\"}};\n\n function display_loaded(error = null) {\n const el = document.getElementById(null);\n if (el != null) {\n const html = (() => {\n if (typeof root.Bokeh === \"undefined\") {\n if (error == null) {\n return \"BokehJS is loading ...\";\n } else {\n return \"BokehJS failed to load.\";\n }\n } else {\n const prefix = `BokehJS ${root.Bokeh.version}`;\n if (error == null) {\n return `${prefix} successfully loaded.`;\n } else {\n return `${prefix} encountered errors while loading and may not function as expected.`;\n }\n }\n })();\n el.innerHTML = html;\n\n if (error != null) {\n const wrapper = document.createElement(\"div\");\n wrapper.style.overflow = \"auto\";\n wrapper.style.height = \"5em\";\n wrapper.style.resize = \"vertical\";\n const content = document.createElement(\"div\");\n content.style.fontFamily = \"monospace\";\n content.style.whiteSpace = \"pre-wrap\";\n content.style.backgroundColor = \"rgb(255, 221, 221)\";\n content.textContent = error.stack ?? error.toString();\n wrapper.append(content);\n el.append(wrapper);\n }\n } else if (Date.now() < root._bokeh_timeout) {\n setTimeout(() => display_loaded(error), 100);\n }\n }\n\n function run_callbacks() {\n try {\n root._bokeh_onload_callbacks.forEach(function(callback) {\n if (callback != null)\n callback();\n });\n } finally {\n delete root._bokeh_onload_callbacks\n }\n console.debug(\"Bokeh: all callbacks have finished\");\n }\n\n function load_libs(css_urls, js_urls, callback) {\n if (css_urls == null) css_urls = [];\n if (js_urls == null) js_urls = [];\n\n root._bokeh_onload_callbacks.push(callback);\n if (root._bokeh_is_loading > 0) {\n console.debug(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n return null;\n }\n if (js_urls == null || js_urls.length === 0) {\n run_callbacks();\n return null;\n }\n console.debug(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n root._bokeh_is_loading = css_urls.length + js_urls.length;\n\n function on_load() {\n root._bokeh_is_loading--;\n if (root._bokeh_is_loading === 0) {\n console.debug(\"Bokeh: all BokehJS libraries/stylesheets loaded\");\n run_callbacks()\n }\n }\n\n function on_error(url) {\n console.error(\"failed to load \" + url);\n }\n\n for (let i = 0; i < css_urls.length; i++) {\n const url = css_urls[i];\n const element = document.createElement(\"link\");\n element.onload = on_load;\n element.onerror = on_error.bind(null, url);\n element.rel = \"stylesheet\";\n element.type = \"text/css\";\n element.href = url;\n console.debug(\"Bokeh: injecting link tag for BokehJS stylesheet: \", url);\n document.body.appendChild(element);\n }\n\n for (let i = 0; i < js_urls.length; i++) {\n const url = js_urls[i];\n const element = document.createElement('script');\n element.onload = on_load;\n element.onerror = on_error.bind(null, url);\n element.async = false;\n element.src = url;\n console.debug(\"Bokeh: injecting script tag for BokehJS library: \", url);\n document.head.appendChild(element);\n }\n };\n\n function inject_raw_css(css) {\n const element = document.createElement(\"style\");\n element.appendChild(document.createTextNode(css));\n document.body.appendChild(element);\n }\n\n const js_urls = [\"https://cdn.bokeh.org/bokeh/release/bokeh-3.7.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-gl-3.7.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-3.7.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-3.7.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-mathjax-3.7.1.min.js\"];\n const css_urls = [];\n\n const inline_js = [ function(Bokeh) {\n Bokeh.set_log_level(\"info\");\n },\nfunction(Bokeh) {\n }\n ];\n\n function run_inline_js() {\n if (root.Bokeh !== undefined || force === true) {\n try {\n for (let i = 0; i < inline_js.length; i++) {\n inline_js[i].call(root, root.Bokeh);\n }\n\n } catch (error) {throw error;\n }} else if (Date.now() < root._bokeh_timeout) {\n setTimeout(run_inline_js, 100);\n } else if (!root._bokeh_failed_load) {\n console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n root._bokeh_failed_load = true;\n } else if (force !== true) {\n const cell = $(document.getElementById(null)).parents('.cell').data().cell;\n cell.output_area.append_execute_result(NB_LOAD_WARNING)\n }\n }\n\n if (root._bokeh_is_loading === 0) {\n console.debug(\"Bokeh: BokehJS loaded, going straight to plotting\");\n run_inline_js();\n } else {\n load_libs(css_urls, js_urls, function() {\n console.debug(\"Bokeh: BokehJS plotting callback run at\", now());\n run_inline_js();\n });\n }\n}(window));", "application/vnd.bokehjs_load.v0+json": "" }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "\n", "
\n" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/javascript": "(function(root) {\n function embed_document(root) {\n const docs_json = {\"ed08d134-5597-40c1-a649-882defdeaf2e\":{\"version\":\"3.7.1\",\"title\":\"Bokeh Application\",\"roots\":[{\"type\":\"object\",\"name\":\"Figure\",\"id\":\"p1395\",\"attributes\":{\"width\":400,\"height\":400,\"x_range\":{\"type\":\"object\",\"name\":\"DataRange1d\",\"id\":\"p1396\"},\"y_range\":{\"type\":\"object\",\"name\":\"DataRange1d\",\"id\":\"p1397\"},\"x_scale\":{\"type\":\"object\",\"name\":\"LinearScale\",\"id\":\"p1404\"},\"y_scale\":{\"type\":\"object\",\"name\":\"LinearScale\",\"id\":\"p1405\"},\"title\":{\"type\":\"object\",\"name\":\"Title\",\"id\":\"p1402\"},\"renderers\":[{\"type\":\"object\",\"name\":\"GraphRenderer\",\"id\":\"p1427\",\"attributes\":{\"layout_provider\":{\"type\":\"object\",\"name\":\"StaticLayoutProvider\",\"id\":\"p1444\",\"attributes\":{\"graph_layout\":{\"type\":\"map\",\"entries\":[[1,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"mL5bqdXXhz8szpYifaC/Pw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[2,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"EwrX2kHKoD/EdE9MHBbjPw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[3,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"33Hx34g4pz8AAAAAAADwPw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[4,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"KJ+09Rl00D9coM5fdhzmvw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[5,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"o/zjUvoc1b95iyHus8zkvw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[6,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"Yf9Id3pjkb9sRWRFA0LYvw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}]]}}},\"node_renderer\":{\"type\":\"object\",\"name\":\"GlyphRenderer\",\"id\":\"p1432\",\"attributes\":{\"data_source\":{\"type\":\"object\",\"name\":\"ColumnDataSource\",\"id\":\"p1429\",\"attributes\":{\"selected\":{\"type\":\"object\",\"name\":\"Selection\",\"id\":\"p1430\",\"attributes\":{\"indices\":[],\"line_indices\":[]}},\"selection_policy\":{\"type\":\"object\",\"name\":\"UnionRenderers\",\"id\":\"p1431\"},\"data\":{\"type\":\"map\",\"entries\":[[\"type\",[\"Agent\",\"Location\",\"Agent\",\"Agent\",\"Agent\",\"School\"]],[\"label\",[null,\"Location\",null,null,null,\"School\"]],[\"bipartite\",[0,1,0,0,0,1]],[\"index\",[1,2,3,4,5,6]],[\"_marker\",[\"circle\",\"square\",\"circle\",\"circle\",\"circle\",\"square\"]],[\"_color\",[\"firebrick\",\"steelblue\",\"firebrick\",\"firebrick\",\"firebrick\",\"steelblue\"]],[\"_alpha\",[0.5,0.5,0.5,0.5,0.5,0.5]],[\"_size\",[10,10,10,10,10,10]],[\"start_display\",[\"none\",\"none\",\"none\",\"none\",\"none\",\"none\"]],[\"end_display\",[\"none\",\"none\",\"none\",\"none\",\"none\",\"none\"]],[\"weight_display\",[\"none\",\"none\",\"none\",\"none\",\"none\",\"none\"]],[\"index_display\",[1,1,1,1,1,1]],[\"type_display\",[1,1,1,1,1,1]],[\"label_display\",[\"none\",1,\"none\",\"none\",\"none\",1]]]}}},\"view\":{\"type\":\"object\",\"name\":\"CDSView\",\"id\":\"p1433\",\"attributes\":{\"filter\":{\"type\":\"object\",\"name\":\"AllIndices\",\"id\":\"p1434\"}}},\"glyph\":{\"type\":\"object\",\"name\":\"Scatter\",\"id\":\"p1446\",\"attributes\":{\"size\":{\"type\":\"field\",\"field\":\"_size\"},\"line_color\":{\"type\":\"field\",\"field\":\"_color\"},\"line_alpha\":{\"type\":\"field\",\"field\":\"_alpha\"},\"fill_color\":{\"type\":\"field\",\"field\":\"_color\"},\"fill_alpha\":{\"type\":\"field\",\"field\":\"_alpha\"},\"marker\":{\"type\":\"field\",\"field\":\"_marker\"}}}}},\"edge_renderer\":{\"type\":\"object\",\"name\":\"GlyphRenderer\",\"id\":\"p1439\",\"attributes\":{\"data_source\":{\"type\":\"object\",\"name\":\"ColumnDataSource\",\"id\":\"p1436\",\"attributes\":{\"selected\":{\"type\":\"object\",\"name\":\"Selection\",\"id\":\"p1437\",\"attributes\":{\"indices\":[],\"line_indices\":[]}},\"selection_policy\":{\"type\":\"object\",\"name\":\"UnionRenderers\",\"id\":\"p1438\"},\"data\":{\"type\":\"map\",\"entries\":[[\"weight\",[1,1,1,1,1]],[\"start\",[1,1,2,4,5]],[\"end\",[2,6,3,6,6]],[\"_color\",[\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\"]],[\"_alpha\",[1.0,1.0,1.0,1.0,1.0]],[\"_size\",[1.0,1.0,1.0,1.0,1.0]],[\"start_display\",[1,1,1,1,1]],[\"end_display\",[1,1,1,1,1]],[\"weight_display\",[1,1,1,1,1]],[\"index_display\",[\"none\",\"none\",\"none\",\"none\",\"none\"]],[\"type_display\",[\"none\",\"none\",\"none\",\"none\",\"none\"]],[\"label_display\",[\"none\",\"none\",\"none\",\"none\",\"none\"]]]}}},\"view\":{\"type\":\"object\",\"name\":\"CDSView\",\"id\":\"p1440\",\"attributes\":{\"filter\":{\"type\":\"object\",\"name\":\"AllIndices\",\"id\":\"p1441\"}}},\"glyph\":{\"type\":\"object\",\"name\":\"MultiLine\",\"id\":\"p1445\",\"attributes\":{\"line_color\":{\"type\":\"field\",\"field\":\"_color\"},\"line_alpha\":{\"type\":\"field\",\"field\":\"_alpha\"},\"line_width\":{\"type\":\"field\",\"field\":\"_size\"}}}}},\"selection_policy\":{\"type\":\"object\",\"name\":\"NodesOnly\",\"id\":\"p1442\"},\"inspection_policy\":{\"type\":\"object\",\"name\":\"NodesOnly\",\"id\":\"p1443\"}}}],\"toolbar\":{\"type\":\"object\",\"name\":\"Toolbar\",\"id\":\"p1403\",\"attributes\":{\"tools\":[{\"type\":\"object\",\"name\":\"BoxZoomTool\",\"id\":\"p1416\",\"attributes\":{\"dimensions\":\"both\",\"overlay\":{\"type\":\"object\",\"name\":\"BoxAnnotation\",\"id\":\"p1417\",\"attributes\":{\"syncable\":false,\"line_color\":\"black\",\"line_alpha\":1.0,\"line_width\":2,\"line_dash\":[4,4],\"fill_color\":\"lightgrey\",\"fill_alpha\":0.5,\"level\":\"overlay\",\"visible\":false,\"left\":{\"type\":\"number\",\"value\":\"nan\"},\"right\":{\"type\":\"number\",\"value\":\"nan\"},\"top\":{\"type\":\"number\",\"value\":\"nan\"},\"bottom\":{\"type\":\"number\",\"value\":\"nan\"},\"left_units\":\"canvas\",\"right_units\":\"canvas\",\"top_units\":\"canvas\",\"bottom_units\":\"canvas\",\"handles\":{\"type\":\"object\",\"name\":\"BoxInteractionHandles\",\"id\":\"p1423\",\"attributes\":{\"all\":{\"type\":\"object\",\"name\":\"AreaVisuals\",\"id\":\"p1422\",\"attributes\":{\"fill_color\":\"white\",\"hover_fill_color\":\"lightgray\"}}}}}}}},{\"type\":\"object\",\"name\":\"ResetTool\",\"id\":\"p1424\"},{\"type\":\"object\",\"name\":\"WheelZoomTool\",\"id\":\"p1425\",\"attributes\":{\"renderers\":\"auto\"}},{\"type\":\"object\",\"name\":\"PanTool\",\"id\":\"p1426\"},{\"type\":\"object\",\"name\":\"HoverTool\",\"id\":\"p1447\",\"attributes\":{\"renderers\":[{\"id\":\"p1439\"},{\"id\":\"p1432\"}],\"tooltips\":\"
\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n
start:@start
end:@end
weight:@weight
index:@index
type:@type
label:@label
\",\"line_policy\":\"interp\"}}],\"logo\":null}},\"left\":[{\"type\":\"object\",\"name\":\"LinearAxis\",\"id\":\"p1411\",\"attributes\":{\"visible\":false,\"ticker\":{\"type\":\"object\",\"name\":\"BasicTicker\",\"id\":\"p1412\",\"attributes\":{\"mantissas\":[1,2,5]}},\"formatter\":{\"type\":\"object\",\"name\":\"BasicTickFormatter\",\"id\":\"p1413\"},\"major_label_policy\":{\"type\":\"object\",\"name\":\"AllLabels\",\"id\":\"p1414\"}}}],\"below\":[{\"type\":\"object\",\"name\":\"LinearAxis\",\"id\":\"p1406\",\"attributes\":{\"visible\":false,\"ticker\":{\"type\":\"object\",\"name\":\"BasicTicker\",\"id\":\"p1407\",\"attributes\":{\"mantissas\":[1,2,5]}},\"formatter\":{\"type\":\"object\",\"name\":\"BasicTickFormatter\",\"id\":\"p1408\"},\"major_label_policy\":{\"type\":\"object\",\"name\":\"AllLabels\",\"id\":\"p1409\"}}}],\"center\":[{\"type\":\"object\",\"name\":\"Grid\",\"id\":\"p1410\",\"attributes\":{\"axis\":{\"id\":\"p1406\"},\"grid_line_color\":null}},{\"type\":\"object\",\"name\":\"Grid\",\"id\":\"p1415\",\"attributes\":{\"dimension\":1,\"axis\":{\"id\":\"p1411\"},\"grid_line_color\":null}}]}}]}};\n const render_items = [{\"docid\":\"ed08d134-5597-40c1-a649-882defdeaf2e\",\"roots\":{\"p1395\":\"e05b88fe-6ef0-4d77-8df9-bf06c23a2fa6\"},\"root_ids\":[\"p1395\"],\"notebook_comms_target\":\"p1448\"}];\n void root.Bokeh.embed.embed_items_notebook(docs_json, render_items);\n }\n if (root.Bokeh !== undefined) {\n embed_document(root);\n } else {\n let attempts = 0;\n const timer = setInterval(function(root) {\n if (root.Bokeh !== undefined) {\n clearInterval(timer);\n embed_document(root);\n } else {\n attempts++;\n if (attempts > 100) {\n clearInterval(timer);\n console.log(\"Bokeh: ERROR: Unable to run BokehJS code because BokehJS library is missing\");\n }\n }\n }, 10, root)\n }\n})(window);", "application/vnd.bokehjs_exec.v0+json": "" }, "metadata": { "application/vnd.bokehjs_exec.v0+json": { "id": "p1395" } }, "output_type": "display_data" } ], "source": [ "inspector.plot_bipartite_network()" ] }, { "attachments": {}, "cell_type": "markdown", "id": "81f1ff41", "metadata": {}, "source": [ "Here is the corresponding agent-level network graph:" ] }, { "cell_type": "code", "execution_count": 31, "id": "bd7f576a", "metadata": {}, "outputs": [ { "data": { "application/javascript": "'use strict';\n(function(root) {\n function now() {\n return new Date();\n }\n\n const force = true;\n\n if (typeof root._bokeh_onload_callbacks === \"undefined\" || force === true) {\n root._bokeh_onload_callbacks = [];\n root._bokeh_is_loading = undefined;\n }\n\nconst JS_MIME_TYPE = 'application/javascript';\n const HTML_MIME_TYPE = 'text/html';\n const EXEC_MIME_TYPE = 'application/vnd.bokehjs_exec.v0+json';\n const CLASS_NAME = 'output_bokeh rendered_html';\n\n /**\n * Render data to the DOM node\n */\n function render(props, node) {\n const script = document.createElement(\"script\");\n node.appendChild(script);\n }\n\n /**\n * Handle when an output is cleared or removed\n */\n function handleClearOutput(event, handle) {\n function drop(id) {\n const view = Bokeh.index.get_by_id(id)\n if (view != null) {\n view.model.document.clear()\n Bokeh.index.delete(view)\n }\n }\n\n const cell = handle.cell;\n\n const id = cell.output_area._bokeh_element_id;\n const server_id = cell.output_area._bokeh_server_id;\n\n // Clean up Bokeh references\n if (id != null) {\n drop(id)\n }\n\n if (server_id !== undefined) {\n // Clean up Bokeh references\n const cmd_clean = \"from bokeh.io.state import curstate; print(curstate().uuid_to_server['\" + server_id + \"'].get_sessions()[0].document.roots[0]._id)\";\n cell.notebook.kernel.execute(cmd_clean, {\n iopub: {\n output: function(msg) {\n const id = msg.content.text.trim()\n drop(id)\n }\n }\n });\n // Destroy server and session\n const cmd_destroy = \"import bokeh.io.notebook as ion; ion.destroy_server('\" + server_id + \"')\";\n cell.notebook.kernel.execute(cmd_destroy);\n }\n }\n\n /**\n * Handle when a new output is added\n */\n function handleAddOutput(event, handle) {\n const output_area = handle.output_area;\n const output = handle.output;\n\n // limit handleAddOutput to display_data with EXEC_MIME_TYPE content only\n if ((output.output_type != \"display_data\") || (!Object.prototype.hasOwnProperty.call(output.data, EXEC_MIME_TYPE))) {\n return\n }\n\n const toinsert = output_area.element.find(\".\" + CLASS_NAME.split(' ')[0]);\n\n if (output.metadata[EXEC_MIME_TYPE][\"id\"] !== undefined) {\n toinsert[toinsert.length - 1].firstChild.textContent = output.data[JS_MIME_TYPE];\n // store reference to embed id on output_area\n output_area._bokeh_element_id = output.metadata[EXEC_MIME_TYPE][\"id\"];\n }\n if (output.metadata[EXEC_MIME_TYPE][\"server_id\"] !== undefined) {\n const bk_div = document.createElement(\"div\");\n bk_div.innerHTML = output.data[HTML_MIME_TYPE];\n const script_attrs = bk_div.children[0].attributes;\n for (let i = 0; i < script_attrs.length; i++) {\n toinsert[toinsert.length - 1].firstChild.setAttribute(script_attrs[i].name, script_attrs[i].value);\n toinsert[toinsert.length - 1].firstChild.textContent = bk_div.children[0].textContent\n }\n // store reference to server id on output_area\n output_area._bokeh_server_id = output.metadata[EXEC_MIME_TYPE][\"server_id\"];\n }\n }\n\n function register_renderer(events, OutputArea) {\n\n function append_mime(data, metadata, element) {\n // create a DOM node to render to\n const toinsert = this.create_output_subarea(\n metadata,\n CLASS_NAME,\n EXEC_MIME_TYPE\n );\n this.keyboard_manager.register_events(toinsert);\n // Render to node\n const props = {data: data, metadata: metadata[EXEC_MIME_TYPE]};\n render(props, toinsert[toinsert.length - 1]);\n element.append(toinsert);\n return toinsert\n }\n\n /* Handle when an output is cleared or removed */\n events.on('clear_output.CodeCell', handleClearOutput);\n events.on('delete.Cell', handleClearOutput);\n\n /* Handle when a new output is added */\n events.on('output_added.OutputArea', handleAddOutput);\n\n /**\n * Register the mime type and append_mime function with output_area\n */\n OutputArea.prototype.register_mime_type(EXEC_MIME_TYPE, append_mime, {\n /* Is output safe? */\n safe: true,\n /* Index of renderer in `output_area.display_order` */\n index: 0\n });\n }\n\n // register the mime type if in Jupyter Notebook environment and previously unregistered\n if (root.Jupyter !== undefined) {\n const events = require('base/js/events');\n const OutputArea = require('notebook/js/outputarea').OutputArea;\n\n if (OutputArea.prototype.mime_types().indexOf(EXEC_MIME_TYPE) == -1) {\n register_renderer(events, OutputArea);\n }\n }\n if (typeof (root._bokeh_timeout) === \"undefined\" || force === true) {\n root._bokeh_timeout = Date.now() + 5000;\n root._bokeh_failed_load = false;\n }\n\n const NB_LOAD_WARNING = {'data': {'text/html':\n \"
\\n\"+\n \"

\\n\"+\n \"BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this \\n\"+\n \"may be due to a slow or bad network connection. Possible fixes:\\n\"+\n \"

\\n\"+\n \"\\n\"+\n \"\\n\"+\n \"from bokeh.resources import INLINE\\n\"+\n \"output_notebook(resources=INLINE)\\n\"+\n \"\\n\"+\n \"
\"}};\n\n function display_loaded(error = null) {\n const el = document.getElementById(null);\n if (el != null) {\n const html = (() => {\n if (typeof root.Bokeh === \"undefined\") {\n if (error == null) {\n return \"BokehJS is loading ...\";\n } else {\n return \"BokehJS failed to load.\";\n }\n } else {\n const prefix = `BokehJS ${root.Bokeh.version}`;\n if (error == null) {\n return `${prefix} successfully loaded.`;\n } else {\n return `${prefix} encountered errors while loading and may not function as expected.`;\n }\n }\n })();\n el.innerHTML = html;\n\n if (error != null) {\n const wrapper = document.createElement(\"div\");\n wrapper.style.overflow = \"auto\";\n wrapper.style.height = \"5em\";\n wrapper.style.resize = \"vertical\";\n const content = document.createElement(\"div\");\n content.style.fontFamily = \"monospace\";\n content.style.whiteSpace = \"pre-wrap\";\n content.style.backgroundColor = \"rgb(255, 221, 221)\";\n content.textContent = error.stack ?? error.toString();\n wrapper.append(content);\n el.append(wrapper);\n }\n } else if (Date.now() < root._bokeh_timeout) {\n setTimeout(() => display_loaded(error), 100);\n }\n }\n\n function run_callbacks() {\n try {\n root._bokeh_onload_callbacks.forEach(function(callback) {\n if (callback != null)\n callback();\n });\n } finally {\n delete root._bokeh_onload_callbacks\n }\n console.debug(\"Bokeh: all callbacks have finished\");\n }\n\n function load_libs(css_urls, js_urls, callback) {\n if (css_urls == null) css_urls = [];\n if (js_urls == null) js_urls = [];\n\n root._bokeh_onload_callbacks.push(callback);\n if (root._bokeh_is_loading > 0) {\n console.debug(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n return null;\n }\n if (js_urls == null || js_urls.length === 0) {\n run_callbacks();\n return null;\n }\n console.debug(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n root._bokeh_is_loading = css_urls.length + js_urls.length;\n\n function on_load() {\n root._bokeh_is_loading--;\n if (root._bokeh_is_loading === 0) {\n console.debug(\"Bokeh: all BokehJS libraries/stylesheets loaded\");\n run_callbacks()\n }\n }\n\n function on_error(url) {\n console.error(\"failed to load \" + url);\n }\n\n for (let i = 0; i < css_urls.length; i++) {\n const url = css_urls[i];\n const element = document.createElement(\"link\");\n element.onload = on_load;\n element.onerror = on_error.bind(null, url);\n element.rel = \"stylesheet\";\n element.type = \"text/css\";\n element.href = url;\n console.debug(\"Bokeh: injecting link tag for BokehJS stylesheet: \", url);\n document.body.appendChild(element);\n }\n\n for (let i = 0; i < js_urls.length; i++) {\n const url = js_urls[i];\n const element = document.createElement('script');\n element.onload = on_load;\n element.onerror = on_error.bind(null, url);\n element.async = false;\n element.src = url;\n console.debug(\"Bokeh: injecting script tag for BokehJS library: \", url);\n document.head.appendChild(element);\n }\n };\n\n function inject_raw_css(css) {\n const element = document.createElement(\"style\");\n element.appendChild(document.createTextNode(css));\n document.body.appendChild(element);\n }\n\n const js_urls = [\"https://cdn.bokeh.org/bokeh/release/bokeh-3.7.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-gl-3.7.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-3.7.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-3.7.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-mathjax-3.7.1.min.js\"];\n const css_urls = [];\n\n const inline_js = [ function(Bokeh) {\n Bokeh.set_log_level(\"info\");\n },\nfunction(Bokeh) {\n }\n ];\n\n function run_inline_js() {\n if (root.Bokeh !== undefined || force === true) {\n try {\n for (let i = 0; i < inline_js.length; i++) {\n inline_js[i].call(root, root.Bokeh);\n }\n\n } catch (error) {throw error;\n }} else if (Date.now() < root._bokeh_timeout) {\n setTimeout(run_inline_js, 100);\n } else if (!root._bokeh_failed_load) {\n console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n root._bokeh_failed_load = true;\n } else if (force !== true) {\n const cell = $(document.getElementById(null)).parents('.cell').data().cell;\n cell.output_area.append_execute_result(NB_LOAD_WARNING)\n }\n }\n\n if (root._bokeh_is_loading === 0) {\n console.debug(\"Bokeh: BokehJS loaded, going straight to plotting\");\n run_inline_js();\n } else {\n load_libs(css_urls, js_urls, function() {\n console.debug(\"Bokeh: BokehJS plotting callback run at\", now());\n run_inline_js();\n });\n }\n}(window));", "application/vnd.bokehjs_load.v0+json": "" }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "\n", "
\n" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/javascript": "(function(root) {\n function embed_document(root) {\n const docs_json = {\"2f4e8585-2730-417d-b2e8-03fad7f56c4d\":{\"version\":\"3.7.1\",\"title\":\"Bokeh Application\",\"roots\":[{\"type\":\"object\",\"name\":\"Figure\",\"id\":\"p1455\",\"attributes\":{\"width\":400,\"height\":400,\"x_range\":{\"type\":\"object\",\"name\":\"DataRange1d\",\"id\":\"p1456\"},\"y_range\":{\"type\":\"object\",\"name\":\"DataRange1d\",\"id\":\"p1457\"},\"x_scale\":{\"type\":\"object\",\"name\":\"LinearScale\",\"id\":\"p1464\"},\"y_scale\":{\"type\":\"object\",\"name\":\"LinearScale\",\"id\":\"p1465\"},\"title\":{\"type\":\"object\",\"name\":\"Title\",\"id\":\"p1462\"},\"renderers\":[{\"type\":\"object\",\"name\":\"GraphRenderer\",\"id\":\"p1487\",\"attributes\":{\"layout_provider\":{\"type\":\"object\",\"name\":\"StaticLayoutProvider\",\"id\":\"p1504\",\"attributes\":{\"graph_layout\":{\"type\":\"map\",\"entries\":[[1,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"8xhq+hZanj8FYwxAh8LBPw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[3,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"lEGJwSNYyz8AAAAAAADwPw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[4,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"wPgDEz1Myj+yZSULunTkvw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[5,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"tT7t2dG33L8dZruJz/ffvw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}]]}}},\"node_renderer\":{\"type\":\"object\",\"name\":\"GlyphRenderer\",\"id\":\"p1492\",\"attributes\":{\"data_source\":{\"type\":\"object\",\"name\":\"ColumnDataSource\",\"id\":\"p1489\",\"attributes\":{\"selected\":{\"type\":\"object\",\"name\":\"Selection\",\"id\":\"p1490\",\"attributes\":{\"indices\":[],\"line_indices\":[]}},\"selection_policy\":{\"type\":\"object\",\"name\":\"UnionRenderers\",\"id\":\"p1491\"},\"data\":{\"type\":\"map\",\"entries\":[[\"type\",[\"Agent\",\"Agent\",\"Agent\",\"Agent\"]],[\"index\",[1,3,4,5]],[\"_marker\",[\"circle\",\"circle\",\"circle\",\"circle\"]],[\"_color\",[\"firebrick\",\"firebrick\",\"firebrick\",\"firebrick\"]],[\"_alpha\",[0.5,0.5,0.5,0.5]],[\"_size\",[10,10,10,10]],[\"start_display\",[\"none\",\"none\",\"none\",\"none\"]],[\"end_display\",[\"none\",\"none\",\"none\",\"none\"]],[\"weight_display\",[\"none\",\"none\",\"none\",\"none\"]],[\"index_display\",[1,1,1,1]],[\"type_display\",[1,1,1,1]]]}}},\"view\":{\"type\":\"object\",\"name\":\"CDSView\",\"id\":\"p1493\",\"attributes\":{\"filter\":{\"type\":\"object\",\"name\":\"AllIndices\",\"id\":\"p1494\"}}},\"glyph\":{\"type\":\"object\",\"name\":\"Scatter\",\"id\":\"p1506\",\"attributes\":{\"size\":{\"type\":\"field\",\"field\":\"_size\"},\"line_color\":{\"type\":\"field\",\"field\":\"_color\"},\"line_alpha\":{\"type\":\"field\",\"field\":\"_alpha\"},\"fill_color\":{\"type\":\"field\",\"field\":\"_color\"},\"fill_alpha\":{\"type\":\"field\",\"field\":\"_alpha\"},\"marker\":{\"type\":\"field\",\"field\":\"_marker\"}}}}},\"edge_renderer\":{\"type\":\"object\",\"name\":\"GlyphRenderer\",\"id\":\"p1499\",\"attributes\":{\"data_source\":{\"type\":\"object\",\"name\":\"ColumnDataSource\",\"id\":\"p1496\",\"attributes\":{\"selected\":{\"type\":\"object\",\"name\":\"Selection\",\"id\":\"p1497\",\"attributes\":{\"indices\":[],\"line_indices\":[]}},\"selection_policy\":{\"type\":\"object\",\"name\":\"UnionRenderers\",\"id\":\"p1498\"},\"data\":{\"type\":\"map\",\"entries\":[[\"weight\",[1,1,1,1]],[\"start\",[1,1,1,4]],[\"end\",[3,4,5,5]],[\"_color\",[\"#440154\",\"#440154\",\"#440154\",\"#440154\"]],[\"_alpha\",[1.0,1.0,1.0,1.0]],[\"_size\",[1.0,1.0,1.0,1.0]],[\"start_display\",[1,1,1,1]],[\"end_display\",[1,1,1,1]],[\"weight_display\",[1,1,1,1]],[\"index_display\",[\"none\",\"none\",\"none\",\"none\"]],[\"type_display\",[\"none\",\"none\",\"none\",\"none\"]]]}}},\"view\":{\"type\":\"object\",\"name\":\"CDSView\",\"id\":\"p1500\",\"attributes\":{\"filter\":{\"type\":\"object\",\"name\":\"AllIndices\",\"id\":\"p1501\"}}},\"glyph\":{\"type\":\"object\",\"name\":\"MultiLine\",\"id\":\"p1505\",\"attributes\":{\"line_color\":{\"type\":\"field\",\"field\":\"_color\"},\"line_alpha\":{\"type\":\"field\",\"field\":\"_alpha\"},\"line_width\":{\"type\":\"field\",\"field\":\"_size\"}}}}},\"selection_policy\":{\"type\":\"object\",\"name\":\"NodesOnly\",\"id\":\"p1502\"},\"inspection_policy\":{\"type\":\"object\",\"name\":\"NodesOnly\",\"id\":\"p1503\"}}}],\"toolbar\":{\"type\":\"object\",\"name\":\"Toolbar\",\"id\":\"p1463\",\"attributes\":{\"tools\":[{\"type\":\"object\",\"name\":\"BoxZoomTool\",\"id\":\"p1476\",\"attributes\":{\"dimensions\":\"both\",\"overlay\":{\"type\":\"object\",\"name\":\"BoxAnnotation\",\"id\":\"p1477\",\"attributes\":{\"syncable\":false,\"line_color\":\"black\",\"line_alpha\":1.0,\"line_width\":2,\"line_dash\":[4,4],\"fill_color\":\"lightgrey\",\"fill_alpha\":0.5,\"level\":\"overlay\",\"visible\":false,\"left\":{\"type\":\"number\",\"value\":\"nan\"},\"right\":{\"type\":\"number\",\"value\":\"nan\"},\"top\":{\"type\":\"number\",\"value\":\"nan\"},\"bottom\":{\"type\":\"number\",\"value\":\"nan\"},\"left_units\":\"canvas\",\"right_units\":\"canvas\",\"top_units\":\"canvas\",\"bottom_units\":\"canvas\",\"handles\":{\"type\":\"object\",\"name\":\"BoxInteractionHandles\",\"id\":\"p1483\",\"attributes\":{\"all\":{\"type\":\"object\",\"name\":\"AreaVisuals\",\"id\":\"p1482\",\"attributes\":{\"fill_color\":\"white\",\"hover_fill_color\":\"lightgray\"}}}}}}}},{\"type\":\"object\",\"name\":\"ResetTool\",\"id\":\"p1484\"},{\"type\":\"object\",\"name\":\"WheelZoomTool\",\"id\":\"p1485\",\"attributes\":{\"renderers\":\"auto\"}},{\"type\":\"object\",\"name\":\"PanTool\",\"id\":\"p1486\"},{\"type\":\"object\",\"name\":\"HoverTool\",\"id\":\"p1507\",\"attributes\":{\"renderers\":[{\"id\":\"p1499\"},{\"id\":\"p1492\"}],\"tooltips\":\"
\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n
start:@start
end:@end
weight:@weight
index:@index
type:@type
\",\"line_policy\":\"interp\"}}],\"logo\":null}},\"left\":[{\"type\":\"object\",\"name\":\"LinearAxis\",\"id\":\"p1471\",\"attributes\":{\"visible\":false,\"ticker\":{\"type\":\"object\",\"name\":\"BasicTicker\",\"id\":\"p1472\",\"attributes\":{\"mantissas\":[1,2,5]}},\"formatter\":{\"type\":\"object\",\"name\":\"BasicTickFormatter\",\"id\":\"p1473\"},\"major_label_policy\":{\"type\":\"object\",\"name\":\"AllLabels\",\"id\":\"p1474\"}}}],\"below\":[{\"type\":\"object\",\"name\":\"LinearAxis\",\"id\":\"p1466\",\"attributes\":{\"visible\":false,\"ticker\":{\"type\":\"object\",\"name\":\"BasicTicker\",\"id\":\"p1467\",\"attributes\":{\"mantissas\":[1,2,5]}},\"formatter\":{\"type\":\"object\",\"name\":\"BasicTickFormatter\",\"id\":\"p1468\"},\"major_label_policy\":{\"type\":\"object\",\"name\":\"AllLabels\",\"id\":\"p1469\"}}}],\"center\":[{\"type\":\"object\",\"name\":\"Grid\",\"id\":\"p1470\",\"attributes\":{\"axis\":{\"id\":\"p1466\"},\"grid_line_color\":null}},{\"type\":\"object\",\"name\":\"Grid\",\"id\":\"p1475\",\"attributes\":{\"dimension\":1,\"axis\":{\"id\":\"p1471\"},\"grid_line_color\":null}}]}}]}};\n const render_items = [{\"docid\":\"2f4e8585-2730-417d-b2e8-03fad7f56c4d\",\"roots\":{\"p1455\":\"ce15a2f5-4602-4974-ad3b-bcc93bf3c1cf\"},\"root_ids\":[\"p1455\"],\"notebook_comms_target\":\"p1508\"}];\n void root.Bokeh.embed.embed_items_notebook(docs_json, render_items);\n }\n if (root.Bokeh !== undefined) {\n embed_document(root);\n } else {\n let attempts = 0;\n const timer = setInterval(function(root) {\n if (root.Bokeh !== undefined) {\n clearInterval(timer);\n embed_document(root);\n } else {\n attempts++;\n if (attempts > 100) {\n clearInterval(timer);\n console.log(\"Bokeh: ERROR: Unable to run BokehJS code because BokehJS library is missing\");\n }\n }\n }, 10, root)\n }\n})(window);", "application/vnd.bokehjs_exec.v0+json": "" }, "metadata": { "application/vnd.bokehjs_exec.v0+json": { "id": "p1455" } }, "output_type": "display_data" } ], "source": [ "inspector.plot_agent_network()" ] }, { "cell_type": "markdown", "id": "6182fdfe", "metadata": {}, "source": [ "## Removing entities from the graph\n", "\n", "So far, we only added agents to the model, locations to the model, agents to locations and locations to agents.\n", "Of course we can also remove things." ] }, { "cell_type": "markdown", "id": "27d13f61", "metadata": {}, "source": [ "To remove the edge between an agent and a location, we can use `model.remove_agent_from_location()`, `agent.remove_location()`, `agent.remove_locations()`, `location.remove_agent()` or `location.remove_agents()`.\n", "In the following example, we remove the edge between `agent` and `location` using `location.remove_agent()`:" ] }, { "cell_type": "code", "execution_count": 32, "id": "0cc6df9b", "metadata": {}, "outputs": [], "source": [ "location.remove_agent(agent)" ] }, { "cell_type": "code", "execution_count": 33, "id": "279ccabd", "metadata": {}, "outputs": [ { "data": { "application/javascript": "'use strict';\n(function(root) {\n function now() {\n return new Date();\n }\n\n const force = true;\n\n if (typeof root._bokeh_onload_callbacks === \"undefined\" || force === true) {\n root._bokeh_onload_callbacks = [];\n root._bokeh_is_loading = undefined;\n }\n\nconst JS_MIME_TYPE = 'application/javascript';\n const HTML_MIME_TYPE = 'text/html';\n const EXEC_MIME_TYPE = 'application/vnd.bokehjs_exec.v0+json';\n const CLASS_NAME = 'output_bokeh rendered_html';\n\n /**\n * Render data to the DOM node\n */\n function render(props, node) {\n const script = document.createElement(\"script\");\n node.appendChild(script);\n }\n\n /**\n * Handle when an output is cleared or removed\n */\n function handleClearOutput(event, handle) {\n function drop(id) {\n const view = Bokeh.index.get_by_id(id)\n if (view != null) {\n view.model.document.clear()\n Bokeh.index.delete(view)\n }\n }\n\n const cell = handle.cell;\n\n const id = cell.output_area._bokeh_element_id;\n const server_id = cell.output_area._bokeh_server_id;\n\n // Clean up Bokeh references\n if (id != null) {\n drop(id)\n }\n\n if (server_id !== undefined) {\n // Clean up Bokeh references\n const cmd_clean = \"from bokeh.io.state import curstate; print(curstate().uuid_to_server['\" + server_id + \"'].get_sessions()[0].document.roots[0]._id)\";\n cell.notebook.kernel.execute(cmd_clean, {\n iopub: {\n output: function(msg) {\n const id = msg.content.text.trim()\n drop(id)\n }\n }\n });\n // Destroy server and session\n const cmd_destroy = \"import bokeh.io.notebook as ion; ion.destroy_server('\" + server_id + \"')\";\n cell.notebook.kernel.execute(cmd_destroy);\n }\n }\n\n /**\n * Handle when a new output is added\n */\n function handleAddOutput(event, handle) {\n const output_area = handle.output_area;\n const output = handle.output;\n\n // limit handleAddOutput to display_data with EXEC_MIME_TYPE content only\n if ((output.output_type != \"display_data\") || (!Object.prototype.hasOwnProperty.call(output.data, EXEC_MIME_TYPE))) {\n return\n }\n\n const toinsert = output_area.element.find(\".\" + CLASS_NAME.split(' ')[0]);\n\n if (output.metadata[EXEC_MIME_TYPE][\"id\"] !== undefined) {\n toinsert[toinsert.length - 1].firstChild.textContent = output.data[JS_MIME_TYPE];\n // store reference to embed id on output_area\n output_area._bokeh_element_id = output.metadata[EXEC_MIME_TYPE][\"id\"];\n }\n if (output.metadata[EXEC_MIME_TYPE][\"server_id\"] !== undefined) {\n const bk_div = document.createElement(\"div\");\n bk_div.innerHTML = output.data[HTML_MIME_TYPE];\n const script_attrs = bk_div.children[0].attributes;\n for (let i = 0; i < script_attrs.length; i++) {\n toinsert[toinsert.length - 1].firstChild.setAttribute(script_attrs[i].name, script_attrs[i].value);\n toinsert[toinsert.length - 1].firstChild.textContent = bk_div.children[0].textContent\n }\n // store reference to server id on output_area\n output_area._bokeh_server_id = output.metadata[EXEC_MIME_TYPE][\"server_id\"];\n }\n }\n\n function register_renderer(events, OutputArea) {\n\n function append_mime(data, metadata, element) {\n // create a DOM node to render to\n const toinsert = this.create_output_subarea(\n metadata,\n CLASS_NAME,\n EXEC_MIME_TYPE\n );\n this.keyboard_manager.register_events(toinsert);\n // Render to node\n const props = {data: data, metadata: metadata[EXEC_MIME_TYPE]};\n render(props, toinsert[toinsert.length - 1]);\n element.append(toinsert);\n return toinsert\n }\n\n /* Handle when an output is cleared or removed */\n events.on('clear_output.CodeCell', handleClearOutput);\n events.on('delete.Cell', handleClearOutput);\n\n /* Handle when a new output is added */\n events.on('output_added.OutputArea', handleAddOutput);\n\n /**\n * Register the mime type and append_mime function with output_area\n */\n OutputArea.prototype.register_mime_type(EXEC_MIME_TYPE, append_mime, {\n /* Is output safe? */\n safe: true,\n /* Index of renderer in `output_area.display_order` */\n index: 0\n });\n }\n\n // register the mime type if in Jupyter Notebook environment and previously unregistered\n if (root.Jupyter !== undefined) {\n const events = require('base/js/events');\n const OutputArea = require('notebook/js/outputarea').OutputArea;\n\n if (OutputArea.prototype.mime_types().indexOf(EXEC_MIME_TYPE) == -1) {\n register_renderer(events, OutputArea);\n }\n }\n if (typeof (root._bokeh_timeout) === \"undefined\" || force === true) {\n root._bokeh_timeout = Date.now() + 5000;\n root._bokeh_failed_load = false;\n }\n\n const NB_LOAD_WARNING = {'data': {'text/html':\n \"
\\n\"+\n \"

\\n\"+\n \"BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this \\n\"+\n \"may be due to a slow or bad network connection. Possible fixes:\\n\"+\n \"

\\n\"+\n \"\\n\"+\n \"\\n\"+\n \"from bokeh.resources import INLINE\\n\"+\n \"output_notebook(resources=INLINE)\\n\"+\n \"\\n\"+\n \"
\"}};\n\n function display_loaded(error = null) {\n const el = document.getElementById(null);\n if (el != null) {\n const html = (() => {\n if (typeof root.Bokeh === \"undefined\") {\n if (error == null) {\n return \"BokehJS is loading ...\";\n } else {\n return \"BokehJS failed to load.\";\n }\n } else {\n const prefix = `BokehJS ${root.Bokeh.version}`;\n if (error == null) {\n return `${prefix} successfully loaded.`;\n } else {\n return `${prefix} encountered errors while loading and may not function as expected.`;\n }\n }\n })();\n el.innerHTML = html;\n\n if (error != null) {\n const wrapper = document.createElement(\"div\");\n wrapper.style.overflow = \"auto\";\n wrapper.style.height = \"5em\";\n wrapper.style.resize = \"vertical\";\n const content = document.createElement(\"div\");\n content.style.fontFamily = \"monospace\";\n content.style.whiteSpace = \"pre-wrap\";\n content.style.backgroundColor = \"rgb(255, 221, 221)\";\n content.textContent = error.stack ?? error.toString();\n wrapper.append(content);\n el.append(wrapper);\n }\n } else if (Date.now() < root._bokeh_timeout) {\n setTimeout(() => display_loaded(error), 100);\n }\n }\n\n function run_callbacks() {\n try {\n root._bokeh_onload_callbacks.forEach(function(callback) {\n if (callback != null)\n callback();\n });\n } finally {\n delete root._bokeh_onload_callbacks\n }\n console.debug(\"Bokeh: all callbacks have finished\");\n }\n\n function load_libs(css_urls, js_urls, callback) {\n if (css_urls == null) css_urls = [];\n if (js_urls == null) js_urls = [];\n\n root._bokeh_onload_callbacks.push(callback);\n if (root._bokeh_is_loading > 0) {\n console.debug(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n return null;\n }\n if (js_urls == null || js_urls.length === 0) {\n run_callbacks();\n return null;\n }\n console.debug(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n root._bokeh_is_loading = css_urls.length + js_urls.length;\n\n function on_load() {\n root._bokeh_is_loading--;\n if (root._bokeh_is_loading === 0) {\n console.debug(\"Bokeh: all BokehJS libraries/stylesheets loaded\");\n run_callbacks()\n }\n }\n\n function on_error(url) {\n console.error(\"failed to load \" + url);\n }\n\n for (let i = 0; i < css_urls.length; i++) {\n const url = css_urls[i];\n const element = document.createElement(\"link\");\n element.onload = on_load;\n element.onerror = on_error.bind(null, url);\n element.rel = \"stylesheet\";\n element.type = \"text/css\";\n element.href = url;\n console.debug(\"Bokeh: injecting link tag for BokehJS stylesheet: \", url);\n document.body.appendChild(element);\n }\n\n for (let i = 0; i < js_urls.length; i++) {\n const url = js_urls[i];\n const element = document.createElement('script');\n element.onload = on_load;\n element.onerror = on_error.bind(null, url);\n element.async = false;\n element.src = url;\n console.debug(\"Bokeh: injecting script tag for BokehJS library: \", url);\n document.head.appendChild(element);\n }\n };\n\n function inject_raw_css(css) {\n const element = document.createElement(\"style\");\n element.appendChild(document.createTextNode(css));\n document.body.appendChild(element);\n }\n\n const js_urls = [\"https://cdn.bokeh.org/bokeh/release/bokeh-3.7.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-gl-3.7.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-3.7.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-3.7.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-mathjax-3.7.1.min.js\"];\n const css_urls = [];\n\n const inline_js = [ function(Bokeh) {\n Bokeh.set_log_level(\"info\");\n },\nfunction(Bokeh) {\n }\n ];\n\n function run_inline_js() {\n if (root.Bokeh !== undefined || force === true) {\n try {\n for (let i = 0; i < inline_js.length; i++) {\n inline_js[i].call(root, root.Bokeh);\n }\n\n } catch (error) {throw error;\n }} else if (Date.now() < root._bokeh_timeout) {\n setTimeout(run_inline_js, 100);\n } else if (!root._bokeh_failed_load) {\n console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n root._bokeh_failed_load = true;\n } else if (force !== true) {\n const cell = $(document.getElementById(null)).parents('.cell').data().cell;\n cell.output_area.append_execute_result(NB_LOAD_WARNING)\n }\n }\n\n if (root._bokeh_is_loading === 0) {\n console.debug(\"Bokeh: BokehJS loaded, going straight to plotting\");\n run_inline_js();\n } else {\n load_libs(css_urls, js_urls, function() {\n console.debug(\"Bokeh: BokehJS plotting callback run at\", now());\n run_inline_js();\n });\n }\n}(window));", "application/vnd.bokehjs_load.v0+json": "" }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "\n", "
\n" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/javascript": "(function(root) {\n function embed_document(root) {\n const docs_json = {\"ededeaf5-14ac-47bf-b491-2eeb5fc1a4c7\":{\"version\":\"3.7.1\",\"title\":\"Bokeh Application\",\"roots\":[{\"type\":\"object\",\"name\":\"Figure\",\"id\":\"p1513\",\"attributes\":{\"width\":400,\"height\":400,\"x_range\":{\"type\":\"object\",\"name\":\"DataRange1d\",\"id\":\"p1514\"},\"y_range\":{\"type\":\"object\",\"name\":\"DataRange1d\",\"id\":\"p1515\"},\"x_scale\":{\"type\":\"object\",\"name\":\"LinearScale\",\"id\":\"p1522\"},\"y_scale\":{\"type\":\"object\",\"name\":\"LinearScale\",\"id\":\"p1523\"},\"title\":{\"type\":\"object\",\"name\":\"Title\",\"id\":\"p1520\"},\"renderers\":[{\"type\":\"object\",\"name\":\"GraphRenderer\",\"id\":\"p1545\",\"attributes\":{\"layout_provider\":{\"type\":\"object\",\"name\":\"StaticLayoutProvider\",\"id\":\"p1562\",\"attributes\":{\"graph_layout\":{\"type\":\"map\",\"entries\":[[1,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"ttfOCh7f3L+jtYjbQQhQvw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[2,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"EophfzGq579kSx8lAaWpvw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[3,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"AAAAAAAA8L9umHlkjyK7vw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[4,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"6+RDT2RS6z+T2XX6ZyHGvw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[5,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"FVznhB5t4j/hKvNOPbzQPw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[6,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"8bSdsD1a6D+SaJa3C4exPw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}]]}}},\"node_renderer\":{\"type\":\"object\",\"name\":\"GlyphRenderer\",\"id\":\"p1550\",\"attributes\":{\"data_source\":{\"type\":\"object\",\"name\":\"ColumnDataSource\",\"id\":\"p1547\",\"attributes\":{\"selected\":{\"type\":\"object\",\"name\":\"Selection\",\"id\":\"p1548\",\"attributes\":{\"indices\":[],\"line_indices\":[]}},\"selection_policy\":{\"type\":\"object\",\"name\":\"UnionRenderers\",\"id\":\"p1549\"},\"data\":{\"type\":\"map\",\"entries\":[[\"type\",[\"Agent\",\"Location\",\"Agent\",\"Agent\",\"Agent\",\"School\"]],[\"label\",[null,\"Location\",null,null,null,\"School\"]],[\"bipartite\",[0,1,0,0,0,1]],[\"index\",[1,2,3,4,5,6]],[\"_marker\",[\"circle\",\"square\",\"circle\",\"circle\",\"circle\",\"square\"]],[\"_color\",[\"firebrick\",\"steelblue\",\"firebrick\",\"firebrick\",\"firebrick\",\"steelblue\"]],[\"_alpha\",[0.5,0.5,0.5,0.5,0.5,0.5]],[\"_size\",[10,10,10,10,10,10]],[\"start_display\",[\"none\",\"none\",\"none\",\"none\",\"none\",\"none\"]],[\"end_display\",[\"none\",\"none\",\"none\",\"none\",\"none\",\"none\"]],[\"weight_display\",[\"none\",\"none\",\"none\",\"none\",\"none\",\"none\"]],[\"index_display\",[1,1,1,1,1,1]],[\"type_display\",[1,1,1,1,1,1]],[\"label_display\",[\"none\",1,\"none\",\"none\",\"none\",1]]]}}},\"view\":{\"type\":\"object\",\"name\":\"CDSView\",\"id\":\"p1551\",\"attributes\":{\"filter\":{\"type\":\"object\",\"name\":\"AllIndices\",\"id\":\"p1552\"}}},\"glyph\":{\"type\":\"object\",\"name\":\"Scatter\",\"id\":\"p1564\",\"attributes\":{\"size\":{\"type\":\"field\",\"field\":\"_size\"},\"line_color\":{\"type\":\"field\",\"field\":\"_color\"},\"line_alpha\":{\"type\":\"field\",\"field\":\"_alpha\"},\"fill_color\":{\"type\":\"field\",\"field\":\"_color\"},\"fill_alpha\":{\"type\":\"field\",\"field\":\"_alpha\"},\"marker\":{\"type\":\"field\",\"field\":\"_marker\"}}}}},\"edge_renderer\":{\"type\":\"object\",\"name\":\"GlyphRenderer\",\"id\":\"p1557\",\"attributes\":{\"data_source\":{\"type\":\"object\",\"name\":\"ColumnDataSource\",\"id\":\"p1554\",\"attributes\":{\"selected\":{\"type\":\"object\",\"name\":\"Selection\",\"id\":\"p1555\",\"attributes\":{\"indices\":[],\"line_indices\":[]}},\"selection_policy\":{\"type\":\"object\",\"name\":\"UnionRenderers\",\"id\":\"p1556\"},\"data\":{\"type\":\"map\",\"entries\":[[\"weight\",[1,1,1,1]],[\"start\",[1,2,4,5]],[\"end\",[2,3,6,6]],[\"_color\",[\"#440154\",\"#440154\",\"#440154\",\"#440154\"]],[\"_alpha\",[1.0,1.0,1.0,1.0]],[\"_size\",[1.0,1.0,1.0,1.0]],[\"start_display\",[1,1,1,1]],[\"end_display\",[1,1,1,1]],[\"weight_display\",[1,1,1,1]],[\"index_display\",[\"none\",\"none\",\"none\",\"none\"]],[\"type_display\",[\"none\",\"none\",\"none\",\"none\"]],[\"label_display\",[\"none\",\"none\",\"none\",\"none\"]]]}}},\"view\":{\"type\":\"object\",\"name\":\"CDSView\",\"id\":\"p1558\",\"attributes\":{\"filter\":{\"type\":\"object\",\"name\":\"AllIndices\",\"id\":\"p1559\"}}},\"glyph\":{\"type\":\"object\",\"name\":\"MultiLine\",\"id\":\"p1563\",\"attributes\":{\"line_color\":{\"type\":\"field\",\"field\":\"_color\"},\"line_alpha\":{\"type\":\"field\",\"field\":\"_alpha\"},\"line_width\":{\"type\":\"field\",\"field\":\"_size\"}}}}},\"selection_policy\":{\"type\":\"object\",\"name\":\"NodesOnly\",\"id\":\"p1560\"},\"inspection_policy\":{\"type\":\"object\",\"name\":\"NodesOnly\",\"id\":\"p1561\"}}}],\"toolbar\":{\"type\":\"object\",\"name\":\"Toolbar\",\"id\":\"p1521\",\"attributes\":{\"tools\":[{\"type\":\"object\",\"name\":\"BoxZoomTool\",\"id\":\"p1534\",\"attributes\":{\"dimensions\":\"both\",\"overlay\":{\"type\":\"object\",\"name\":\"BoxAnnotation\",\"id\":\"p1535\",\"attributes\":{\"syncable\":false,\"line_color\":\"black\",\"line_alpha\":1.0,\"line_width\":2,\"line_dash\":[4,4],\"fill_color\":\"lightgrey\",\"fill_alpha\":0.5,\"level\":\"overlay\",\"visible\":false,\"left\":{\"type\":\"number\",\"value\":\"nan\"},\"right\":{\"type\":\"number\",\"value\":\"nan\"},\"top\":{\"type\":\"number\",\"value\":\"nan\"},\"bottom\":{\"type\":\"number\",\"value\":\"nan\"},\"left_units\":\"canvas\",\"right_units\":\"canvas\",\"top_units\":\"canvas\",\"bottom_units\":\"canvas\",\"handles\":{\"type\":\"object\",\"name\":\"BoxInteractionHandles\",\"id\":\"p1541\",\"attributes\":{\"all\":{\"type\":\"object\",\"name\":\"AreaVisuals\",\"id\":\"p1540\",\"attributes\":{\"fill_color\":\"white\",\"hover_fill_color\":\"lightgray\"}}}}}}}},{\"type\":\"object\",\"name\":\"ResetTool\",\"id\":\"p1542\"},{\"type\":\"object\",\"name\":\"WheelZoomTool\",\"id\":\"p1543\",\"attributes\":{\"renderers\":\"auto\"}},{\"type\":\"object\",\"name\":\"PanTool\",\"id\":\"p1544\"},{\"type\":\"object\",\"name\":\"HoverTool\",\"id\":\"p1565\",\"attributes\":{\"renderers\":[{\"id\":\"p1557\"},{\"id\":\"p1550\"}],\"tooltips\":\"
\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n
start:@start
end:@end
weight:@weight
index:@index
type:@type
label:@label
\",\"line_policy\":\"interp\"}}],\"logo\":null}},\"left\":[{\"type\":\"object\",\"name\":\"LinearAxis\",\"id\":\"p1529\",\"attributes\":{\"visible\":false,\"ticker\":{\"type\":\"object\",\"name\":\"BasicTicker\",\"id\":\"p1530\",\"attributes\":{\"mantissas\":[1,2,5]}},\"formatter\":{\"type\":\"object\",\"name\":\"BasicTickFormatter\",\"id\":\"p1531\"},\"major_label_policy\":{\"type\":\"object\",\"name\":\"AllLabels\",\"id\":\"p1532\"}}}],\"below\":[{\"type\":\"object\",\"name\":\"LinearAxis\",\"id\":\"p1524\",\"attributes\":{\"visible\":false,\"ticker\":{\"type\":\"object\",\"name\":\"BasicTicker\",\"id\":\"p1525\",\"attributes\":{\"mantissas\":[1,2,5]}},\"formatter\":{\"type\":\"object\",\"name\":\"BasicTickFormatter\",\"id\":\"p1526\"},\"major_label_policy\":{\"type\":\"object\",\"name\":\"AllLabels\",\"id\":\"p1527\"}}}],\"center\":[{\"type\":\"object\",\"name\":\"Grid\",\"id\":\"p1528\",\"attributes\":{\"axis\":{\"id\":\"p1524\"},\"grid_line_color\":null}},{\"type\":\"object\",\"name\":\"Grid\",\"id\":\"p1533\",\"attributes\":{\"dimension\":1,\"axis\":{\"id\":\"p1529\"},\"grid_line_color\":null}}]}}]}};\n const render_items = [{\"docid\":\"ededeaf5-14ac-47bf-b491-2eeb5fc1a4c7\",\"roots\":{\"p1513\":\"bc854d41-7b09-4c71-85b6-1441debcc74f\"},\"root_ids\":[\"p1513\"],\"notebook_comms_target\":\"p1566\"}];\n void root.Bokeh.embed.embed_items_notebook(docs_json, render_items);\n }\n if (root.Bokeh !== undefined) {\n embed_document(root);\n } else {\n let attempts = 0;\n const timer = setInterval(function(root) {\n if (root.Bokeh !== undefined) {\n clearInterval(timer);\n embed_document(root);\n } else {\n attempts++;\n if (attempts > 100) {\n clearInterval(timer);\n console.log(\"Bokeh: ERROR: Unable to run BokehJS code because BokehJS library is missing\");\n }\n }\n }, 10, root)\n }\n})(window);", "application/vnd.bokehjs_exec.v0+json": "" }, "metadata": { "application/vnd.bokehjs_exec.v0+json": { "id": "p1513" } }, "output_type": "display_data" }, { "data": { "application/javascript": "'use strict';\n(function(root) {\n function now() {\n return new Date();\n }\n\n const force = true;\n\n if (typeof root._bokeh_onload_callbacks === \"undefined\" || force === true) {\n root._bokeh_onload_callbacks = [];\n root._bokeh_is_loading = undefined;\n }\n\nconst JS_MIME_TYPE = 'application/javascript';\n const HTML_MIME_TYPE = 'text/html';\n const EXEC_MIME_TYPE = 'application/vnd.bokehjs_exec.v0+json';\n const CLASS_NAME = 'output_bokeh rendered_html';\n\n /**\n * Render data to the DOM node\n */\n function render(props, node) {\n const script = document.createElement(\"script\");\n node.appendChild(script);\n }\n\n /**\n * Handle when an output is cleared or removed\n */\n function handleClearOutput(event, handle) {\n function drop(id) {\n const view = Bokeh.index.get_by_id(id)\n if (view != null) {\n view.model.document.clear()\n Bokeh.index.delete(view)\n }\n }\n\n const cell = handle.cell;\n\n const id = cell.output_area._bokeh_element_id;\n const server_id = cell.output_area._bokeh_server_id;\n\n // Clean up Bokeh references\n if (id != null) {\n drop(id)\n }\n\n if (server_id !== undefined) {\n // Clean up Bokeh references\n const cmd_clean = \"from bokeh.io.state import curstate; print(curstate().uuid_to_server['\" + server_id + \"'].get_sessions()[0].document.roots[0]._id)\";\n cell.notebook.kernel.execute(cmd_clean, {\n iopub: {\n output: function(msg) {\n const id = msg.content.text.trim()\n drop(id)\n }\n }\n });\n // Destroy server and session\n const cmd_destroy = \"import bokeh.io.notebook as ion; ion.destroy_server('\" + server_id + \"')\";\n cell.notebook.kernel.execute(cmd_destroy);\n }\n }\n\n /**\n * Handle when a new output is added\n */\n function handleAddOutput(event, handle) {\n const output_area = handle.output_area;\n const output = handle.output;\n\n // limit handleAddOutput to display_data with EXEC_MIME_TYPE content only\n if ((output.output_type != \"display_data\") || (!Object.prototype.hasOwnProperty.call(output.data, EXEC_MIME_TYPE))) {\n return\n }\n\n const toinsert = output_area.element.find(\".\" + CLASS_NAME.split(' ')[0]);\n\n if (output.metadata[EXEC_MIME_TYPE][\"id\"] !== undefined) {\n toinsert[toinsert.length - 1].firstChild.textContent = output.data[JS_MIME_TYPE];\n // store reference to embed id on output_area\n output_area._bokeh_element_id = output.metadata[EXEC_MIME_TYPE][\"id\"];\n }\n if (output.metadata[EXEC_MIME_TYPE][\"server_id\"] !== undefined) {\n const bk_div = document.createElement(\"div\");\n bk_div.innerHTML = output.data[HTML_MIME_TYPE];\n const script_attrs = bk_div.children[0].attributes;\n for (let i = 0; i < script_attrs.length; i++) {\n toinsert[toinsert.length - 1].firstChild.setAttribute(script_attrs[i].name, script_attrs[i].value);\n toinsert[toinsert.length - 1].firstChild.textContent = bk_div.children[0].textContent\n }\n // store reference to server id on output_area\n output_area._bokeh_server_id = output.metadata[EXEC_MIME_TYPE][\"server_id\"];\n }\n }\n\n function register_renderer(events, OutputArea) {\n\n function append_mime(data, metadata, element) {\n // create a DOM node to render to\n const toinsert = this.create_output_subarea(\n metadata,\n CLASS_NAME,\n EXEC_MIME_TYPE\n );\n this.keyboard_manager.register_events(toinsert);\n // Render to node\n const props = {data: data, metadata: metadata[EXEC_MIME_TYPE]};\n render(props, toinsert[toinsert.length - 1]);\n element.append(toinsert);\n return toinsert\n }\n\n /* Handle when an output is cleared or removed */\n events.on('clear_output.CodeCell', handleClearOutput);\n events.on('delete.Cell', handleClearOutput);\n\n /* Handle when a new output is added */\n events.on('output_added.OutputArea', handleAddOutput);\n\n /**\n * Register the mime type and append_mime function with output_area\n */\n OutputArea.prototype.register_mime_type(EXEC_MIME_TYPE, append_mime, {\n /* Is output safe? */\n safe: true,\n /* Index of renderer in `output_area.display_order` */\n index: 0\n });\n }\n\n // register the mime type if in Jupyter Notebook environment and previously unregistered\n if (root.Jupyter !== undefined) {\n const events = require('base/js/events');\n const OutputArea = require('notebook/js/outputarea').OutputArea;\n\n if (OutputArea.prototype.mime_types().indexOf(EXEC_MIME_TYPE) == -1) {\n register_renderer(events, OutputArea);\n }\n }\n if (typeof (root._bokeh_timeout) === \"undefined\" || force === true) {\n root._bokeh_timeout = Date.now() + 5000;\n root._bokeh_failed_load = false;\n }\n\n const NB_LOAD_WARNING = {'data': {'text/html':\n \"
\\n\"+\n \"

\\n\"+\n \"BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this \\n\"+\n \"may be due to a slow or bad network connection. Possible fixes:\\n\"+\n \"

\\n\"+\n \"\\n\"+\n \"\\n\"+\n \"from bokeh.resources import INLINE\\n\"+\n \"output_notebook(resources=INLINE)\\n\"+\n \"\\n\"+\n \"
\"}};\n\n function display_loaded(error = null) {\n const el = document.getElementById(null);\n if (el != null) {\n const html = (() => {\n if (typeof root.Bokeh === \"undefined\") {\n if (error == null) {\n return \"BokehJS is loading ...\";\n } else {\n return \"BokehJS failed to load.\";\n }\n } else {\n const prefix = `BokehJS ${root.Bokeh.version}`;\n if (error == null) {\n return `${prefix} successfully loaded.`;\n } else {\n return `${prefix} encountered errors while loading and may not function as expected.`;\n }\n }\n })();\n el.innerHTML = html;\n\n if (error != null) {\n const wrapper = document.createElement(\"div\");\n wrapper.style.overflow = \"auto\";\n wrapper.style.height = \"5em\";\n wrapper.style.resize = \"vertical\";\n const content = document.createElement(\"div\");\n content.style.fontFamily = \"monospace\";\n content.style.whiteSpace = \"pre-wrap\";\n content.style.backgroundColor = \"rgb(255, 221, 221)\";\n content.textContent = error.stack ?? error.toString();\n wrapper.append(content);\n el.append(wrapper);\n }\n } else if (Date.now() < root._bokeh_timeout) {\n setTimeout(() => display_loaded(error), 100);\n }\n }\n\n function run_callbacks() {\n try {\n root._bokeh_onload_callbacks.forEach(function(callback) {\n if (callback != null)\n callback();\n });\n } finally {\n delete root._bokeh_onload_callbacks\n }\n console.debug(\"Bokeh: all callbacks have finished\");\n }\n\n function load_libs(css_urls, js_urls, callback) {\n if (css_urls == null) css_urls = [];\n if (js_urls == null) js_urls = [];\n\n root._bokeh_onload_callbacks.push(callback);\n if (root._bokeh_is_loading > 0) {\n console.debug(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n return null;\n }\n if (js_urls == null || js_urls.length === 0) {\n run_callbacks();\n return null;\n }\n console.debug(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n root._bokeh_is_loading = css_urls.length + js_urls.length;\n\n function on_load() {\n root._bokeh_is_loading--;\n if (root._bokeh_is_loading === 0) {\n console.debug(\"Bokeh: all BokehJS libraries/stylesheets loaded\");\n run_callbacks()\n }\n }\n\n function on_error(url) {\n console.error(\"failed to load \" + url);\n }\n\n for (let i = 0; i < css_urls.length; i++) {\n const url = css_urls[i];\n const element = document.createElement(\"link\");\n element.onload = on_load;\n element.onerror = on_error.bind(null, url);\n element.rel = \"stylesheet\";\n element.type = \"text/css\";\n element.href = url;\n console.debug(\"Bokeh: injecting link tag for BokehJS stylesheet: \", url);\n document.body.appendChild(element);\n }\n\n for (let i = 0; i < js_urls.length; i++) {\n const url = js_urls[i];\n const element = document.createElement('script');\n element.onload = on_load;\n element.onerror = on_error.bind(null, url);\n element.async = false;\n element.src = url;\n console.debug(\"Bokeh: injecting script tag for BokehJS library: \", url);\n document.head.appendChild(element);\n }\n };\n\n function inject_raw_css(css) {\n const element = document.createElement(\"style\");\n element.appendChild(document.createTextNode(css));\n document.body.appendChild(element);\n }\n\n const js_urls = [\"https://cdn.bokeh.org/bokeh/release/bokeh-3.7.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-gl-3.7.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-3.7.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-3.7.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-mathjax-3.7.1.min.js\"];\n const css_urls = [];\n\n const inline_js = [ function(Bokeh) {\n Bokeh.set_log_level(\"info\");\n },\nfunction(Bokeh) {\n }\n ];\n\n function run_inline_js() {\n if (root.Bokeh !== undefined || force === true) {\n try {\n for (let i = 0; i < inline_js.length; i++) {\n inline_js[i].call(root, root.Bokeh);\n }\n\n } catch (error) {throw error;\n }} else if (Date.now() < root._bokeh_timeout) {\n setTimeout(run_inline_js, 100);\n } else if (!root._bokeh_failed_load) {\n console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n root._bokeh_failed_load = true;\n } else if (force !== true) {\n const cell = $(document.getElementById(null)).parents('.cell').data().cell;\n cell.output_area.append_execute_result(NB_LOAD_WARNING)\n }\n }\n\n if (root._bokeh_is_loading === 0) {\n console.debug(\"Bokeh: BokehJS loaded, going straight to plotting\");\n run_inline_js();\n } else {\n load_libs(css_urls, js_urls, function() {\n console.debug(\"Bokeh: BokehJS plotting callback run at\", now());\n run_inline_js();\n });\n }\n}(window));", "application/vnd.bokehjs_load.v0+json": "" }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "\n", "
\n" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/javascript": "(function(root) {\n function embed_document(root) {\n const docs_json = {\"6500ed2b-1f44-4380-887b-023f60d69cf7\":{\"version\":\"3.7.1\",\"title\":\"Bokeh Application\",\"roots\":[{\"type\":\"object\",\"name\":\"Figure\",\"id\":\"p1573\",\"attributes\":{\"width\":400,\"height\":400,\"x_range\":{\"type\":\"object\",\"name\":\"DataRange1d\",\"id\":\"p1574\"},\"y_range\":{\"type\":\"object\",\"name\":\"DataRange1d\",\"id\":\"p1575\"},\"x_scale\":{\"type\":\"object\",\"name\":\"LinearScale\",\"id\":\"p1582\"},\"y_scale\":{\"type\":\"object\",\"name\":\"LinearScale\",\"id\":\"p1583\"},\"title\":{\"type\":\"object\",\"name\":\"Title\",\"id\":\"p1580\"},\"renderers\":[{\"type\":\"object\",\"name\":\"GraphRenderer\",\"id\":\"p1605\",\"attributes\":{\"layout_provider\":{\"type\":\"object\",\"name\":\"StaticLayoutProvider\",\"id\":\"p1622\",\"attributes\":{\"graph_layout\":{\"type\":\"map\",\"entries\":[[1,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"ZA5EMTG26z/EA6pANtTjvw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[3,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"+ej/cRiz7z/8vb+G6BTSvw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[4,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"YvdDo0lp678mnQT6S7XjPw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[5,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"////////7781iwoUvVLSPw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}]]}}},\"node_renderer\":{\"type\":\"object\",\"name\":\"GlyphRenderer\",\"id\":\"p1610\",\"attributes\":{\"data_source\":{\"type\":\"object\",\"name\":\"ColumnDataSource\",\"id\":\"p1607\",\"attributes\":{\"selected\":{\"type\":\"object\",\"name\":\"Selection\",\"id\":\"p1608\",\"attributes\":{\"indices\":[],\"line_indices\":[]}},\"selection_policy\":{\"type\":\"object\",\"name\":\"UnionRenderers\",\"id\":\"p1609\"},\"data\":{\"type\":\"map\",\"entries\":[[\"type\",[\"Agent\",\"Agent\",\"Agent\",\"Agent\"]],[\"index\",[1,3,4,5]],[\"_marker\",[\"circle\",\"circle\",\"circle\",\"circle\"]],[\"_color\",[\"firebrick\",\"firebrick\",\"firebrick\",\"firebrick\"]],[\"_alpha\",[0.5,0.5,0.5,0.5]],[\"_size\",[10,10,10,10]],[\"start_display\",[\"none\",\"none\",\"none\",\"none\"]],[\"end_display\",[\"none\",\"none\",\"none\",\"none\"]],[\"weight_display\",[\"none\",\"none\",\"none\",\"none\"]],[\"index_display\",[1,1,1,1]],[\"type_display\",[1,1,1,1]]]}}},\"view\":{\"type\":\"object\",\"name\":\"CDSView\",\"id\":\"p1611\",\"attributes\":{\"filter\":{\"type\":\"object\",\"name\":\"AllIndices\",\"id\":\"p1612\"}}},\"glyph\":{\"type\":\"object\",\"name\":\"Scatter\",\"id\":\"p1624\",\"attributes\":{\"size\":{\"type\":\"field\",\"field\":\"_size\"},\"line_color\":{\"type\":\"field\",\"field\":\"_color\"},\"line_alpha\":{\"type\":\"field\",\"field\":\"_alpha\"},\"fill_color\":{\"type\":\"field\",\"field\":\"_color\"},\"fill_alpha\":{\"type\":\"field\",\"field\":\"_alpha\"},\"marker\":{\"type\":\"field\",\"field\":\"_marker\"}}}}},\"edge_renderer\":{\"type\":\"object\",\"name\":\"GlyphRenderer\",\"id\":\"p1617\",\"attributes\":{\"data_source\":{\"type\":\"object\",\"name\":\"ColumnDataSource\",\"id\":\"p1614\",\"attributes\":{\"selected\":{\"type\":\"object\",\"name\":\"Selection\",\"id\":\"p1615\",\"attributes\":{\"indices\":[],\"line_indices\":[]}},\"selection_policy\":{\"type\":\"object\",\"name\":\"UnionRenderers\",\"id\":\"p1616\"},\"data\":{\"type\":\"map\",\"entries\":[[\"weight\",[1,1]],[\"start\",[1,4]],[\"end\",[3,5]],[\"_color\",[\"#440154\",\"#440154\"]],[\"_alpha\",[1.0,1.0]],[\"_size\",[1.0,1.0]],[\"start_display\",[1,1]],[\"end_display\",[1,1]],[\"weight_display\",[1,1]],[\"index_display\",[\"none\",\"none\"]],[\"type_display\",[\"none\",\"none\"]]]}}},\"view\":{\"type\":\"object\",\"name\":\"CDSView\",\"id\":\"p1618\",\"attributes\":{\"filter\":{\"type\":\"object\",\"name\":\"AllIndices\",\"id\":\"p1619\"}}},\"glyph\":{\"type\":\"object\",\"name\":\"MultiLine\",\"id\":\"p1623\",\"attributes\":{\"line_color\":{\"type\":\"field\",\"field\":\"_color\"},\"line_alpha\":{\"type\":\"field\",\"field\":\"_alpha\"},\"line_width\":{\"type\":\"field\",\"field\":\"_size\"}}}}},\"selection_policy\":{\"type\":\"object\",\"name\":\"NodesOnly\",\"id\":\"p1620\"},\"inspection_policy\":{\"type\":\"object\",\"name\":\"NodesOnly\",\"id\":\"p1621\"}}}],\"toolbar\":{\"type\":\"object\",\"name\":\"Toolbar\",\"id\":\"p1581\",\"attributes\":{\"tools\":[{\"type\":\"object\",\"name\":\"BoxZoomTool\",\"id\":\"p1594\",\"attributes\":{\"dimensions\":\"both\",\"overlay\":{\"type\":\"object\",\"name\":\"BoxAnnotation\",\"id\":\"p1595\",\"attributes\":{\"syncable\":false,\"line_color\":\"black\",\"line_alpha\":1.0,\"line_width\":2,\"line_dash\":[4,4],\"fill_color\":\"lightgrey\",\"fill_alpha\":0.5,\"level\":\"overlay\",\"visible\":false,\"left\":{\"type\":\"number\",\"value\":\"nan\"},\"right\":{\"type\":\"number\",\"value\":\"nan\"},\"top\":{\"type\":\"number\",\"value\":\"nan\"},\"bottom\":{\"type\":\"number\",\"value\":\"nan\"},\"left_units\":\"canvas\",\"right_units\":\"canvas\",\"top_units\":\"canvas\",\"bottom_units\":\"canvas\",\"handles\":{\"type\":\"object\",\"name\":\"BoxInteractionHandles\",\"id\":\"p1601\",\"attributes\":{\"all\":{\"type\":\"object\",\"name\":\"AreaVisuals\",\"id\":\"p1600\",\"attributes\":{\"fill_color\":\"white\",\"hover_fill_color\":\"lightgray\"}}}}}}}},{\"type\":\"object\",\"name\":\"ResetTool\",\"id\":\"p1602\"},{\"type\":\"object\",\"name\":\"WheelZoomTool\",\"id\":\"p1603\",\"attributes\":{\"renderers\":\"auto\"}},{\"type\":\"object\",\"name\":\"PanTool\",\"id\":\"p1604\"},{\"type\":\"object\",\"name\":\"HoverTool\",\"id\":\"p1625\",\"attributes\":{\"renderers\":[{\"id\":\"p1617\"},{\"id\":\"p1610\"}],\"tooltips\":\"
\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n
start:@start
end:@end
weight:@weight
index:@index
type:@type
\",\"line_policy\":\"interp\"}}],\"logo\":null}},\"left\":[{\"type\":\"object\",\"name\":\"LinearAxis\",\"id\":\"p1589\",\"attributes\":{\"visible\":false,\"ticker\":{\"type\":\"object\",\"name\":\"BasicTicker\",\"id\":\"p1590\",\"attributes\":{\"mantissas\":[1,2,5]}},\"formatter\":{\"type\":\"object\",\"name\":\"BasicTickFormatter\",\"id\":\"p1591\"},\"major_label_policy\":{\"type\":\"object\",\"name\":\"AllLabels\",\"id\":\"p1592\"}}}],\"below\":[{\"type\":\"object\",\"name\":\"LinearAxis\",\"id\":\"p1584\",\"attributes\":{\"visible\":false,\"ticker\":{\"type\":\"object\",\"name\":\"BasicTicker\",\"id\":\"p1585\",\"attributes\":{\"mantissas\":[1,2,5]}},\"formatter\":{\"type\":\"object\",\"name\":\"BasicTickFormatter\",\"id\":\"p1586\"},\"major_label_policy\":{\"type\":\"object\",\"name\":\"AllLabels\",\"id\":\"p1587\"}}}],\"center\":[{\"type\":\"object\",\"name\":\"Grid\",\"id\":\"p1588\",\"attributes\":{\"axis\":{\"id\":\"p1584\"},\"grid_line_color\":null}},{\"type\":\"object\",\"name\":\"Grid\",\"id\":\"p1593\",\"attributes\":{\"dimension\":1,\"axis\":{\"id\":\"p1589\"},\"grid_line_color\":null}}]}}]}};\n const render_items = [{\"docid\":\"6500ed2b-1f44-4380-887b-023f60d69cf7\",\"roots\":{\"p1573\":\"cc9264c7-afbc-4c13-9efb-c80e58cb8c6c\"},\"root_ids\":[\"p1573\"],\"notebook_comms_target\":\"p1626\"}];\n void root.Bokeh.embed.embed_items_notebook(docs_json, render_items);\n }\n if (root.Bokeh !== undefined) {\n embed_document(root);\n } else {\n let attempts = 0;\n const timer = setInterval(function(root) {\n if (root.Bokeh !== undefined) {\n clearInterval(timer);\n embed_document(root);\n } else {\n attempts++;\n if (attempts > 100) {\n clearInterval(timer);\n console.log(\"Bokeh: ERROR: Unable to run BokehJS code because BokehJS library is missing\");\n }\n }\n }, 10, root)\n }\n})(window);", "application/vnd.bokehjs_exec.v0+json": "" }, "metadata": { "application/vnd.bokehjs_exec.v0+json": { "id": "p1573" } }, "output_type": "display_data" } ], "source": [ "inspector.plot_networks()" ] }, { "cell_type": "markdown", "id": "55c0b0f5", "metadata": {}, "source": [ "To remove agents or locations from the graph, we can use `model.remove_agent()` and `model.remove_location()`.\n", "In the following example, we remove `agent` from the graph:" ] }, { "cell_type": "code", "execution_count": 34, "id": "118916e3", "metadata": {}, "outputs": [], "source": [ "model.remove_agent(agent)" ] }, { "cell_type": "code", "execution_count": 35, "id": "dec5b844", "metadata": {}, "outputs": [ { "data": { "application/javascript": "'use strict';\n(function(root) {\n function now() {\n return new Date();\n }\n\n const force = true;\n\n if (typeof root._bokeh_onload_callbacks === \"undefined\" || force === true) {\n root._bokeh_onload_callbacks = [];\n root._bokeh_is_loading = undefined;\n }\n\nconst JS_MIME_TYPE = 'application/javascript';\n const HTML_MIME_TYPE = 'text/html';\n const EXEC_MIME_TYPE = 'application/vnd.bokehjs_exec.v0+json';\n const CLASS_NAME = 'output_bokeh rendered_html';\n\n /**\n * Render data to the DOM node\n */\n function render(props, node) {\n const script = document.createElement(\"script\");\n node.appendChild(script);\n }\n\n /**\n * Handle when an output is cleared or removed\n */\n function handleClearOutput(event, handle) {\n function drop(id) {\n const view = Bokeh.index.get_by_id(id)\n if (view != null) {\n view.model.document.clear()\n Bokeh.index.delete(view)\n }\n }\n\n const cell = handle.cell;\n\n const id = cell.output_area._bokeh_element_id;\n const server_id = cell.output_area._bokeh_server_id;\n\n // Clean up Bokeh references\n if (id != null) {\n drop(id)\n }\n\n if (server_id !== undefined) {\n // Clean up Bokeh references\n const cmd_clean = \"from bokeh.io.state import curstate; print(curstate().uuid_to_server['\" + server_id + \"'].get_sessions()[0].document.roots[0]._id)\";\n cell.notebook.kernel.execute(cmd_clean, {\n iopub: {\n output: function(msg) {\n const id = msg.content.text.trim()\n drop(id)\n }\n }\n });\n // Destroy server and session\n const cmd_destroy = \"import bokeh.io.notebook as ion; ion.destroy_server('\" + server_id + \"')\";\n cell.notebook.kernel.execute(cmd_destroy);\n }\n }\n\n /**\n * Handle when a new output is added\n */\n function handleAddOutput(event, handle) {\n const output_area = handle.output_area;\n const output = handle.output;\n\n // limit handleAddOutput to display_data with EXEC_MIME_TYPE content only\n if ((output.output_type != \"display_data\") || (!Object.prototype.hasOwnProperty.call(output.data, EXEC_MIME_TYPE))) {\n return\n }\n\n const toinsert = output_area.element.find(\".\" + CLASS_NAME.split(' ')[0]);\n\n if (output.metadata[EXEC_MIME_TYPE][\"id\"] !== undefined) {\n toinsert[toinsert.length - 1].firstChild.textContent = output.data[JS_MIME_TYPE];\n // store reference to embed id on output_area\n output_area._bokeh_element_id = output.metadata[EXEC_MIME_TYPE][\"id\"];\n }\n if (output.metadata[EXEC_MIME_TYPE][\"server_id\"] !== undefined) {\n const bk_div = document.createElement(\"div\");\n bk_div.innerHTML = output.data[HTML_MIME_TYPE];\n const script_attrs = bk_div.children[0].attributes;\n for (let i = 0; i < script_attrs.length; i++) {\n toinsert[toinsert.length - 1].firstChild.setAttribute(script_attrs[i].name, script_attrs[i].value);\n toinsert[toinsert.length - 1].firstChild.textContent = bk_div.children[0].textContent\n }\n // store reference to server id on output_area\n output_area._bokeh_server_id = output.metadata[EXEC_MIME_TYPE][\"server_id\"];\n }\n }\n\n function register_renderer(events, OutputArea) {\n\n function append_mime(data, metadata, element) {\n // create a DOM node to render to\n const toinsert = this.create_output_subarea(\n metadata,\n CLASS_NAME,\n EXEC_MIME_TYPE\n );\n this.keyboard_manager.register_events(toinsert);\n // Render to node\n const props = {data: data, metadata: metadata[EXEC_MIME_TYPE]};\n render(props, toinsert[toinsert.length - 1]);\n element.append(toinsert);\n return toinsert\n }\n\n /* Handle when an output is cleared or removed */\n events.on('clear_output.CodeCell', handleClearOutput);\n events.on('delete.Cell', handleClearOutput);\n\n /* Handle when a new output is added */\n events.on('output_added.OutputArea', handleAddOutput);\n\n /**\n * Register the mime type and append_mime function with output_area\n */\n OutputArea.prototype.register_mime_type(EXEC_MIME_TYPE, append_mime, {\n /* Is output safe? */\n safe: true,\n /* Index of renderer in `output_area.display_order` */\n index: 0\n });\n }\n\n // register the mime type if in Jupyter Notebook environment and previously unregistered\n if (root.Jupyter !== undefined) {\n const events = require('base/js/events');\n const OutputArea = require('notebook/js/outputarea').OutputArea;\n\n if (OutputArea.prototype.mime_types().indexOf(EXEC_MIME_TYPE) == -1) {\n register_renderer(events, OutputArea);\n }\n }\n if (typeof (root._bokeh_timeout) === \"undefined\" || force === true) {\n root._bokeh_timeout = Date.now() + 5000;\n root._bokeh_failed_load = false;\n }\n\n const NB_LOAD_WARNING = {'data': {'text/html':\n \"
\\n\"+\n \"

\\n\"+\n \"BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this \\n\"+\n \"may be due to a slow or bad network connection. Possible fixes:\\n\"+\n \"

\\n\"+\n \"\\n\"+\n \"\\n\"+\n \"from bokeh.resources import INLINE\\n\"+\n \"output_notebook(resources=INLINE)\\n\"+\n \"\\n\"+\n \"
\"}};\n\n function display_loaded(error = null) {\n const el = document.getElementById(null);\n if (el != null) {\n const html = (() => {\n if (typeof root.Bokeh === \"undefined\") {\n if (error == null) {\n return \"BokehJS is loading ...\";\n } else {\n return \"BokehJS failed to load.\";\n }\n } else {\n const prefix = `BokehJS ${root.Bokeh.version}`;\n if (error == null) {\n return `${prefix} successfully loaded.`;\n } else {\n return `${prefix} encountered errors while loading and may not function as expected.`;\n }\n }\n })();\n el.innerHTML = html;\n\n if (error != null) {\n const wrapper = document.createElement(\"div\");\n wrapper.style.overflow = \"auto\";\n wrapper.style.height = \"5em\";\n wrapper.style.resize = \"vertical\";\n const content = document.createElement(\"div\");\n content.style.fontFamily = \"monospace\";\n content.style.whiteSpace = \"pre-wrap\";\n content.style.backgroundColor = \"rgb(255, 221, 221)\";\n content.textContent = error.stack ?? error.toString();\n wrapper.append(content);\n el.append(wrapper);\n }\n } else if (Date.now() < root._bokeh_timeout) {\n setTimeout(() => display_loaded(error), 100);\n }\n }\n\n function run_callbacks() {\n try {\n root._bokeh_onload_callbacks.forEach(function(callback) {\n if (callback != null)\n callback();\n });\n } finally {\n delete root._bokeh_onload_callbacks\n }\n console.debug(\"Bokeh: all callbacks have finished\");\n }\n\n function load_libs(css_urls, js_urls, callback) {\n if (css_urls == null) css_urls = [];\n if (js_urls == null) js_urls = [];\n\n root._bokeh_onload_callbacks.push(callback);\n if (root._bokeh_is_loading > 0) {\n console.debug(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n return null;\n }\n if (js_urls == null || js_urls.length === 0) {\n run_callbacks();\n return null;\n }\n console.debug(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n root._bokeh_is_loading = css_urls.length + js_urls.length;\n\n function on_load() {\n root._bokeh_is_loading--;\n if (root._bokeh_is_loading === 0) {\n console.debug(\"Bokeh: all BokehJS libraries/stylesheets loaded\");\n run_callbacks()\n }\n }\n\n function on_error(url) {\n console.error(\"failed to load \" + url);\n }\n\n for (let i = 0; i < css_urls.length; i++) {\n const url = css_urls[i];\n const element = document.createElement(\"link\");\n element.onload = on_load;\n element.onerror = on_error.bind(null, url);\n element.rel = \"stylesheet\";\n element.type = \"text/css\";\n element.href = url;\n console.debug(\"Bokeh: injecting link tag for BokehJS stylesheet: \", url);\n document.body.appendChild(element);\n }\n\n for (let i = 0; i < js_urls.length; i++) {\n const url = js_urls[i];\n const element = document.createElement('script');\n element.onload = on_load;\n element.onerror = on_error.bind(null, url);\n element.async = false;\n element.src = url;\n console.debug(\"Bokeh: injecting script tag for BokehJS library: \", url);\n document.head.appendChild(element);\n }\n };\n\n function inject_raw_css(css) {\n const element = document.createElement(\"style\");\n element.appendChild(document.createTextNode(css));\n document.body.appendChild(element);\n }\n\n const js_urls = [\"https://cdn.bokeh.org/bokeh/release/bokeh-3.7.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-gl-3.7.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-3.7.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-3.7.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-mathjax-3.7.1.min.js\"];\n const css_urls = [];\n\n const inline_js = [ function(Bokeh) {\n Bokeh.set_log_level(\"info\");\n },\nfunction(Bokeh) {\n }\n ];\n\n function run_inline_js() {\n if (root.Bokeh !== undefined || force === true) {\n try {\n for (let i = 0; i < inline_js.length; i++) {\n inline_js[i].call(root, root.Bokeh);\n }\n\n } catch (error) {throw error;\n }} else if (Date.now() < root._bokeh_timeout) {\n setTimeout(run_inline_js, 100);\n } else if (!root._bokeh_failed_load) {\n console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n root._bokeh_failed_load = true;\n } else if (force !== true) {\n const cell = $(document.getElementById(null)).parents('.cell').data().cell;\n cell.output_area.append_execute_result(NB_LOAD_WARNING)\n }\n }\n\n if (root._bokeh_is_loading === 0) {\n console.debug(\"Bokeh: BokehJS loaded, going straight to plotting\");\n run_inline_js();\n } else {\n load_libs(css_urls, js_urls, function() {\n console.debug(\"Bokeh: BokehJS plotting callback run at\", now());\n run_inline_js();\n });\n }\n}(window));", "application/vnd.bokehjs_load.v0+json": "" }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "\n", "
\n" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/javascript": "(function(root) {\n function embed_document(root) {\n const docs_json = {\"1bd2f504-e7b6-4780-b933-fd204e18606b\":{\"version\":\"3.7.1\",\"title\":\"Bokeh Application\",\"roots\":[{\"type\":\"object\",\"name\":\"Figure\",\"id\":\"p1631\",\"attributes\":{\"width\":400,\"height\":400,\"x_range\":{\"type\":\"object\",\"name\":\"DataRange1d\",\"id\":\"p1632\"},\"y_range\":{\"type\":\"object\",\"name\":\"DataRange1d\",\"id\":\"p1633\"},\"x_scale\":{\"type\":\"object\",\"name\":\"LinearScale\",\"id\":\"p1640\"},\"y_scale\":{\"type\":\"object\",\"name\":\"LinearScale\",\"id\":\"p1641\"},\"title\":{\"type\":\"object\",\"name\":\"Title\",\"id\":\"p1638\"},\"renderers\":[{\"type\":\"object\",\"name\":\"GraphRenderer\",\"id\":\"p1663\",\"attributes\":{\"layout_provider\":{\"type\":\"object\",\"name\":\"StaticLayoutProvider\",\"id\":\"p1680\",\"attributes\":{\"graph_layout\":{\"type\":\"map\",\"entries\":[[2,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"hk5oQHkx2L9URbpRfifuvw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[3,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"Zh5Z/INSwL8AAAAAAADwvw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[4,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"RWeIxOqAxj/VXLtaFN/YPw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[5,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"sfs6vf0Quj8S91Kq3HzsPw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[6,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"T9YD2gwszT/bnwl6FzvlPw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}]]}}},\"node_renderer\":{\"type\":\"object\",\"name\":\"GlyphRenderer\",\"id\":\"p1668\",\"attributes\":{\"data_source\":{\"type\":\"object\",\"name\":\"ColumnDataSource\",\"id\":\"p1665\",\"attributes\":{\"selected\":{\"type\":\"object\",\"name\":\"Selection\",\"id\":\"p1666\",\"attributes\":{\"indices\":[],\"line_indices\":[]}},\"selection_policy\":{\"type\":\"object\",\"name\":\"UnionRenderers\",\"id\":\"p1667\"},\"data\":{\"type\":\"map\",\"entries\":[[\"type\",[\"Location\",\"Agent\",\"Agent\",\"Agent\",\"School\"]],[\"label\",[\"Location\",null,null,null,\"School\"]],[\"bipartite\",[1,0,0,0,1]],[\"index\",[2,3,4,5,6]],[\"_marker\",[\"square\",\"circle\",\"circle\",\"circle\",\"square\"]],[\"_color\",[\"steelblue\",\"firebrick\",\"firebrick\",\"firebrick\",\"steelblue\"]],[\"_alpha\",[0.5,0.5,0.5,0.5,0.5]],[\"_size\",[10,10,10,10,10]],[\"start_display\",[\"none\",\"none\",\"none\",\"none\",\"none\"]],[\"end_display\",[\"none\",\"none\",\"none\",\"none\",\"none\"]],[\"weight_display\",[\"none\",\"none\",\"none\",\"none\",\"none\"]],[\"index_display\",[1,1,1,1,1]],[\"type_display\",[1,1,1,1,1]],[\"label_display\",[1,\"none\",\"none\",\"none\",1]]]}}},\"view\":{\"type\":\"object\",\"name\":\"CDSView\",\"id\":\"p1669\",\"attributes\":{\"filter\":{\"type\":\"object\",\"name\":\"AllIndices\",\"id\":\"p1670\"}}},\"glyph\":{\"type\":\"object\",\"name\":\"Scatter\",\"id\":\"p1682\",\"attributes\":{\"size\":{\"type\":\"field\",\"field\":\"_size\"},\"line_color\":{\"type\":\"field\",\"field\":\"_color\"},\"line_alpha\":{\"type\":\"field\",\"field\":\"_alpha\"},\"fill_color\":{\"type\":\"field\",\"field\":\"_color\"},\"fill_alpha\":{\"type\":\"field\",\"field\":\"_alpha\"},\"marker\":{\"type\":\"field\",\"field\":\"_marker\"}}}}},\"edge_renderer\":{\"type\":\"object\",\"name\":\"GlyphRenderer\",\"id\":\"p1675\",\"attributes\":{\"data_source\":{\"type\":\"object\",\"name\":\"ColumnDataSource\",\"id\":\"p1672\",\"attributes\":{\"selected\":{\"type\":\"object\",\"name\":\"Selection\",\"id\":\"p1673\",\"attributes\":{\"indices\":[],\"line_indices\":[]}},\"selection_policy\":{\"type\":\"object\",\"name\":\"UnionRenderers\",\"id\":\"p1674\"},\"data\":{\"type\":\"map\",\"entries\":[[\"weight\",[1,1,1]],[\"start\",[2,4,5]],[\"end\",[3,6,6]],[\"_color\",[\"#440154\",\"#440154\",\"#440154\"]],[\"_alpha\",[1.0,1.0,1.0]],[\"_size\",[1.0,1.0,1.0]],[\"start_display\",[1,1,1]],[\"end_display\",[1,1,1]],[\"weight_display\",[1,1,1]],[\"index_display\",[\"none\",\"none\",\"none\"]],[\"type_display\",[\"none\",\"none\",\"none\"]],[\"label_display\",[\"none\",\"none\",\"none\"]]]}}},\"view\":{\"type\":\"object\",\"name\":\"CDSView\",\"id\":\"p1676\",\"attributes\":{\"filter\":{\"type\":\"object\",\"name\":\"AllIndices\",\"id\":\"p1677\"}}},\"glyph\":{\"type\":\"object\",\"name\":\"MultiLine\",\"id\":\"p1681\",\"attributes\":{\"line_color\":{\"type\":\"field\",\"field\":\"_color\"},\"line_alpha\":{\"type\":\"field\",\"field\":\"_alpha\"},\"line_width\":{\"type\":\"field\",\"field\":\"_size\"}}}}},\"selection_policy\":{\"type\":\"object\",\"name\":\"NodesOnly\",\"id\":\"p1678\"},\"inspection_policy\":{\"type\":\"object\",\"name\":\"NodesOnly\",\"id\":\"p1679\"}}}],\"toolbar\":{\"type\":\"object\",\"name\":\"Toolbar\",\"id\":\"p1639\",\"attributes\":{\"tools\":[{\"type\":\"object\",\"name\":\"BoxZoomTool\",\"id\":\"p1652\",\"attributes\":{\"dimensions\":\"both\",\"overlay\":{\"type\":\"object\",\"name\":\"BoxAnnotation\",\"id\":\"p1653\",\"attributes\":{\"syncable\":false,\"line_color\":\"black\",\"line_alpha\":1.0,\"line_width\":2,\"line_dash\":[4,4],\"fill_color\":\"lightgrey\",\"fill_alpha\":0.5,\"level\":\"overlay\",\"visible\":false,\"left\":{\"type\":\"number\",\"value\":\"nan\"},\"right\":{\"type\":\"number\",\"value\":\"nan\"},\"top\":{\"type\":\"number\",\"value\":\"nan\"},\"bottom\":{\"type\":\"number\",\"value\":\"nan\"},\"left_units\":\"canvas\",\"right_units\":\"canvas\",\"top_units\":\"canvas\",\"bottom_units\":\"canvas\",\"handles\":{\"type\":\"object\",\"name\":\"BoxInteractionHandles\",\"id\":\"p1659\",\"attributes\":{\"all\":{\"type\":\"object\",\"name\":\"AreaVisuals\",\"id\":\"p1658\",\"attributes\":{\"fill_color\":\"white\",\"hover_fill_color\":\"lightgray\"}}}}}}}},{\"type\":\"object\",\"name\":\"ResetTool\",\"id\":\"p1660\"},{\"type\":\"object\",\"name\":\"WheelZoomTool\",\"id\":\"p1661\",\"attributes\":{\"renderers\":\"auto\"}},{\"type\":\"object\",\"name\":\"PanTool\",\"id\":\"p1662\"},{\"type\":\"object\",\"name\":\"HoverTool\",\"id\":\"p1683\",\"attributes\":{\"renderers\":[{\"id\":\"p1675\"},{\"id\":\"p1668\"}],\"tooltips\":\"
\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n
start:@start
end:@end
weight:@weight
index:@index
type:@type
label:@label
\",\"line_policy\":\"interp\"}}],\"logo\":null}},\"left\":[{\"type\":\"object\",\"name\":\"LinearAxis\",\"id\":\"p1647\",\"attributes\":{\"visible\":false,\"ticker\":{\"type\":\"object\",\"name\":\"BasicTicker\",\"id\":\"p1648\",\"attributes\":{\"mantissas\":[1,2,5]}},\"formatter\":{\"type\":\"object\",\"name\":\"BasicTickFormatter\",\"id\":\"p1649\"},\"major_label_policy\":{\"type\":\"object\",\"name\":\"AllLabels\",\"id\":\"p1650\"}}}],\"below\":[{\"type\":\"object\",\"name\":\"LinearAxis\",\"id\":\"p1642\",\"attributes\":{\"visible\":false,\"ticker\":{\"type\":\"object\",\"name\":\"BasicTicker\",\"id\":\"p1643\",\"attributes\":{\"mantissas\":[1,2,5]}},\"formatter\":{\"type\":\"object\",\"name\":\"BasicTickFormatter\",\"id\":\"p1644\"},\"major_label_policy\":{\"type\":\"object\",\"name\":\"AllLabels\",\"id\":\"p1645\"}}}],\"center\":[{\"type\":\"object\",\"name\":\"Grid\",\"id\":\"p1646\",\"attributes\":{\"axis\":{\"id\":\"p1642\"},\"grid_line_color\":null}},{\"type\":\"object\",\"name\":\"Grid\",\"id\":\"p1651\",\"attributes\":{\"dimension\":1,\"axis\":{\"id\":\"p1647\"},\"grid_line_color\":null}}]}}]}};\n const render_items = [{\"docid\":\"1bd2f504-e7b6-4780-b933-fd204e18606b\",\"roots\":{\"p1631\":\"d14ac140-f206-45a6-8b6d-febc5f00e1b7\"},\"root_ids\":[\"p1631\"],\"notebook_comms_target\":\"p1684\"}];\n void root.Bokeh.embed.embed_items_notebook(docs_json, render_items);\n }\n if (root.Bokeh !== undefined) {\n embed_document(root);\n } else {\n let attempts = 0;\n const timer = setInterval(function(root) {\n if (root.Bokeh !== undefined) {\n clearInterval(timer);\n embed_document(root);\n } else {\n attempts++;\n if (attempts > 100) {\n clearInterval(timer);\n console.log(\"Bokeh: ERROR: Unable to run BokehJS code because BokehJS library is missing\");\n }\n }\n }, 10, root)\n }\n})(window);", "application/vnd.bokehjs_exec.v0+json": "" }, "metadata": { "application/vnd.bokehjs_exec.v0+json": { "id": "p1631" } }, "output_type": "display_data" }, { "data": { "application/javascript": "'use strict';\n(function(root) {\n function now() {\n return new Date();\n }\n\n const force = true;\n\n if (typeof root._bokeh_onload_callbacks === \"undefined\" || force === true) {\n root._bokeh_onload_callbacks = [];\n root._bokeh_is_loading = undefined;\n }\n\nconst JS_MIME_TYPE = 'application/javascript';\n const HTML_MIME_TYPE = 'text/html';\n const EXEC_MIME_TYPE = 'application/vnd.bokehjs_exec.v0+json';\n const CLASS_NAME = 'output_bokeh rendered_html';\n\n /**\n * Render data to the DOM node\n */\n function render(props, node) {\n const script = document.createElement(\"script\");\n node.appendChild(script);\n }\n\n /**\n * Handle when an output is cleared or removed\n */\n function handleClearOutput(event, handle) {\n function drop(id) {\n const view = Bokeh.index.get_by_id(id)\n if (view != null) {\n view.model.document.clear()\n Bokeh.index.delete(view)\n }\n }\n\n const cell = handle.cell;\n\n const id = cell.output_area._bokeh_element_id;\n const server_id = cell.output_area._bokeh_server_id;\n\n // Clean up Bokeh references\n if (id != null) {\n drop(id)\n }\n\n if (server_id !== undefined) {\n // Clean up Bokeh references\n const cmd_clean = \"from bokeh.io.state import curstate; print(curstate().uuid_to_server['\" + server_id + \"'].get_sessions()[0].document.roots[0]._id)\";\n cell.notebook.kernel.execute(cmd_clean, {\n iopub: {\n output: function(msg) {\n const id = msg.content.text.trim()\n drop(id)\n }\n }\n });\n // Destroy server and session\n const cmd_destroy = \"import bokeh.io.notebook as ion; ion.destroy_server('\" + server_id + \"')\";\n cell.notebook.kernel.execute(cmd_destroy);\n }\n }\n\n /**\n * Handle when a new output is added\n */\n function handleAddOutput(event, handle) {\n const output_area = handle.output_area;\n const output = handle.output;\n\n // limit handleAddOutput to display_data with EXEC_MIME_TYPE content only\n if ((output.output_type != \"display_data\") || (!Object.prototype.hasOwnProperty.call(output.data, EXEC_MIME_TYPE))) {\n return\n }\n\n const toinsert = output_area.element.find(\".\" + CLASS_NAME.split(' ')[0]);\n\n if (output.metadata[EXEC_MIME_TYPE][\"id\"] !== undefined) {\n toinsert[toinsert.length - 1].firstChild.textContent = output.data[JS_MIME_TYPE];\n // store reference to embed id on output_area\n output_area._bokeh_element_id = output.metadata[EXEC_MIME_TYPE][\"id\"];\n }\n if (output.metadata[EXEC_MIME_TYPE][\"server_id\"] !== undefined) {\n const bk_div = document.createElement(\"div\");\n bk_div.innerHTML = output.data[HTML_MIME_TYPE];\n const script_attrs = bk_div.children[0].attributes;\n for (let i = 0; i < script_attrs.length; i++) {\n toinsert[toinsert.length - 1].firstChild.setAttribute(script_attrs[i].name, script_attrs[i].value);\n toinsert[toinsert.length - 1].firstChild.textContent = bk_div.children[0].textContent\n }\n // store reference to server id on output_area\n output_area._bokeh_server_id = output.metadata[EXEC_MIME_TYPE][\"server_id\"];\n }\n }\n\n function register_renderer(events, OutputArea) {\n\n function append_mime(data, metadata, element) {\n // create a DOM node to render to\n const toinsert = this.create_output_subarea(\n metadata,\n CLASS_NAME,\n EXEC_MIME_TYPE\n );\n this.keyboard_manager.register_events(toinsert);\n // Render to node\n const props = {data: data, metadata: metadata[EXEC_MIME_TYPE]};\n render(props, toinsert[toinsert.length - 1]);\n element.append(toinsert);\n return toinsert\n }\n\n /* Handle when an output is cleared or removed */\n events.on('clear_output.CodeCell', handleClearOutput);\n events.on('delete.Cell', handleClearOutput);\n\n /* Handle when a new output is added */\n events.on('output_added.OutputArea', handleAddOutput);\n\n /**\n * Register the mime type and append_mime function with output_area\n */\n OutputArea.prototype.register_mime_type(EXEC_MIME_TYPE, append_mime, {\n /* Is output safe? */\n safe: true,\n /* Index of renderer in `output_area.display_order` */\n index: 0\n });\n }\n\n // register the mime type if in Jupyter Notebook environment and previously unregistered\n if (root.Jupyter !== undefined) {\n const events = require('base/js/events');\n const OutputArea = require('notebook/js/outputarea').OutputArea;\n\n if (OutputArea.prototype.mime_types().indexOf(EXEC_MIME_TYPE) == -1) {\n register_renderer(events, OutputArea);\n }\n }\n if (typeof (root._bokeh_timeout) === \"undefined\" || force === true) {\n root._bokeh_timeout = Date.now() + 5000;\n root._bokeh_failed_load = false;\n }\n\n const NB_LOAD_WARNING = {'data': {'text/html':\n \"
\\n\"+\n \"

\\n\"+\n \"BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this \\n\"+\n \"may be due to a slow or bad network connection. Possible fixes:\\n\"+\n \"

\\n\"+\n \"\\n\"+\n \"\\n\"+\n \"from bokeh.resources import INLINE\\n\"+\n \"output_notebook(resources=INLINE)\\n\"+\n \"\\n\"+\n \"
\"}};\n\n function display_loaded(error = null) {\n const el = document.getElementById(null);\n if (el != null) {\n const html = (() => {\n if (typeof root.Bokeh === \"undefined\") {\n if (error == null) {\n return \"BokehJS is loading ...\";\n } else {\n return \"BokehJS failed to load.\";\n }\n } else {\n const prefix = `BokehJS ${root.Bokeh.version}`;\n if (error == null) {\n return `${prefix} successfully loaded.`;\n } else {\n return `${prefix} encountered errors while loading and may not function as expected.`;\n }\n }\n })();\n el.innerHTML = html;\n\n if (error != null) {\n const wrapper = document.createElement(\"div\");\n wrapper.style.overflow = \"auto\";\n wrapper.style.height = \"5em\";\n wrapper.style.resize = \"vertical\";\n const content = document.createElement(\"div\");\n content.style.fontFamily = \"monospace\";\n content.style.whiteSpace = \"pre-wrap\";\n content.style.backgroundColor = \"rgb(255, 221, 221)\";\n content.textContent = error.stack ?? error.toString();\n wrapper.append(content);\n el.append(wrapper);\n }\n } else if (Date.now() < root._bokeh_timeout) {\n setTimeout(() => display_loaded(error), 100);\n }\n }\n\n function run_callbacks() {\n try {\n root._bokeh_onload_callbacks.forEach(function(callback) {\n if (callback != null)\n callback();\n });\n } finally {\n delete root._bokeh_onload_callbacks\n }\n console.debug(\"Bokeh: all callbacks have finished\");\n }\n\n function load_libs(css_urls, js_urls, callback) {\n if (css_urls == null) css_urls = [];\n if (js_urls == null) js_urls = [];\n\n root._bokeh_onload_callbacks.push(callback);\n if (root._bokeh_is_loading > 0) {\n console.debug(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n return null;\n }\n if (js_urls == null || js_urls.length === 0) {\n run_callbacks();\n return null;\n }\n console.debug(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n root._bokeh_is_loading = css_urls.length + js_urls.length;\n\n function on_load() {\n root._bokeh_is_loading--;\n if (root._bokeh_is_loading === 0) {\n console.debug(\"Bokeh: all BokehJS libraries/stylesheets loaded\");\n run_callbacks()\n }\n }\n\n function on_error(url) {\n console.error(\"failed to load \" + url);\n }\n\n for (let i = 0; i < css_urls.length; i++) {\n const url = css_urls[i];\n const element = document.createElement(\"link\");\n element.onload = on_load;\n element.onerror = on_error.bind(null, url);\n element.rel = \"stylesheet\";\n element.type = \"text/css\";\n element.href = url;\n console.debug(\"Bokeh: injecting link tag for BokehJS stylesheet: \", url);\n document.body.appendChild(element);\n }\n\n for (let i = 0; i < js_urls.length; i++) {\n const url = js_urls[i];\n const element = document.createElement('script');\n element.onload = on_load;\n element.onerror = on_error.bind(null, url);\n element.async = false;\n element.src = url;\n console.debug(\"Bokeh: injecting script tag for BokehJS library: \", url);\n document.head.appendChild(element);\n }\n };\n\n function inject_raw_css(css) {\n const element = document.createElement(\"style\");\n element.appendChild(document.createTextNode(css));\n document.body.appendChild(element);\n }\n\n const js_urls = [\"https://cdn.bokeh.org/bokeh/release/bokeh-3.7.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-gl-3.7.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-3.7.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-3.7.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-mathjax-3.7.1.min.js\"];\n const css_urls = [];\n\n const inline_js = [ function(Bokeh) {\n Bokeh.set_log_level(\"info\");\n },\nfunction(Bokeh) {\n }\n ];\n\n function run_inline_js() {\n if (root.Bokeh !== undefined || force === true) {\n try {\n for (let i = 0; i < inline_js.length; i++) {\n inline_js[i].call(root, root.Bokeh);\n }\n\n } catch (error) {throw error;\n }} else if (Date.now() < root._bokeh_timeout) {\n setTimeout(run_inline_js, 100);\n } else if (!root._bokeh_failed_load) {\n console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n root._bokeh_failed_load = true;\n } else if (force !== true) {\n const cell = $(document.getElementById(null)).parents('.cell').data().cell;\n cell.output_area.append_execute_result(NB_LOAD_WARNING)\n }\n }\n\n if (root._bokeh_is_loading === 0) {\n console.debug(\"Bokeh: BokehJS loaded, going straight to plotting\");\n run_inline_js();\n } else {\n load_libs(css_urls, js_urls, function() {\n console.debug(\"Bokeh: BokehJS plotting callback run at\", now());\n run_inline_js();\n });\n }\n}(window));", "application/vnd.bokehjs_load.v0+json": "" }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "\n", "
\n" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/javascript": "(function(root) {\n function embed_document(root) {\n const docs_json = {\"339c17ef-accd-4436-8df8-6048e60bfb0a\":{\"version\":\"3.7.1\",\"title\":\"Bokeh Application\",\"roots\":[{\"type\":\"object\",\"name\":\"Figure\",\"id\":\"p1690\",\"attributes\":{\"width\":400,\"height\":400,\"x_range\":{\"type\":\"object\",\"name\":\"DataRange1d\",\"id\":\"p1691\"},\"y_range\":{\"type\":\"object\",\"name\":\"DataRange1d\",\"id\":\"p1692\"},\"x_scale\":{\"type\":\"object\",\"name\":\"LinearScale\",\"id\":\"p1699\"},\"y_scale\":{\"type\":\"object\",\"name\":\"LinearScale\",\"id\":\"p1700\"},\"title\":{\"type\":\"object\",\"name\":\"Title\",\"id\":\"p1697\"},\"renderers\":[{\"type\":\"object\",\"name\":\"GraphRenderer\",\"id\":\"p1722\",\"attributes\":{\"layout_provider\":{\"type\":\"object\",\"name\":\"StaticLayoutProvider\",\"id\":\"p1739\",\"attributes\":{\"graph_layout\":{\"type\":\"map\",\"entries\":[[3,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"OrMXHYJSyz8AAAAAAADwvw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[4,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"Vk01NHxBoL/RgJKDErXhPw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[5,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"5l8KECNCx79h/tr42pXcPw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}]]}}},\"node_renderer\":{\"type\":\"object\",\"name\":\"GlyphRenderer\",\"id\":\"p1727\",\"attributes\":{\"data_source\":{\"type\":\"object\",\"name\":\"ColumnDataSource\",\"id\":\"p1724\",\"attributes\":{\"selected\":{\"type\":\"object\",\"name\":\"Selection\",\"id\":\"p1725\",\"attributes\":{\"indices\":[],\"line_indices\":[]}},\"selection_policy\":{\"type\":\"object\",\"name\":\"UnionRenderers\",\"id\":\"p1726\"},\"data\":{\"type\":\"map\",\"entries\":[[\"type\",[\"Agent\",\"Agent\",\"Agent\"]],[\"index\",[3,4,5]],[\"_marker\",[\"circle\",\"circle\",\"circle\"]],[\"_color\",[\"firebrick\",\"firebrick\",\"firebrick\"]],[\"_alpha\",[0.5,0.5,0.5]],[\"_size\",[10,10,10]],[\"start_display\",[\"none\",\"none\",\"none\"]],[\"end_display\",[\"none\",\"none\",\"none\"]],[\"weight_display\",[\"none\",\"none\",\"none\"]],[\"index_display\",[1,1,1]],[\"type_display\",[1,1,1]]]}}},\"view\":{\"type\":\"object\",\"name\":\"CDSView\",\"id\":\"p1728\",\"attributes\":{\"filter\":{\"type\":\"object\",\"name\":\"AllIndices\",\"id\":\"p1729\"}}},\"glyph\":{\"type\":\"object\",\"name\":\"Scatter\",\"id\":\"p1741\",\"attributes\":{\"size\":{\"type\":\"field\",\"field\":\"_size\"},\"line_color\":{\"type\":\"field\",\"field\":\"_color\"},\"line_alpha\":{\"type\":\"field\",\"field\":\"_alpha\"},\"fill_color\":{\"type\":\"field\",\"field\":\"_color\"},\"fill_alpha\":{\"type\":\"field\",\"field\":\"_alpha\"},\"marker\":{\"type\":\"field\",\"field\":\"_marker\"}}}}},\"edge_renderer\":{\"type\":\"object\",\"name\":\"GlyphRenderer\",\"id\":\"p1734\",\"attributes\":{\"data_source\":{\"type\":\"object\",\"name\":\"ColumnDataSource\",\"id\":\"p1731\",\"attributes\":{\"selected\":{\"type\":\"object\",\"name\":\"Selection\",\"id\":\"p1732\",\"attributes\":{\"indices\":[],\"line_indices\":[]}},\"selection_policy\":{\"type\":\"object\",\"name\":\"UnionRenderers\",\"id\":\"p1733\"},\"data\":{\"type\":\"map\",\"entries\":[[\"weight\",[1]],[\"start\",[4]],[\"end\",[5]],[\"_color\",[\"#440154\"]],[\"_alpha\",[1.0]],[\"_size\",[1.0]],[\"start_display\",[1]],[\"end_display\",[1]],[\"weight_display\",[1]],[\"index_display\",[\"none\"]],[\"type_display\",[\"none\"]]]}}},\"view\":{\"type\":\"object\",\"name\":\"CDSView\",\"id\":\"p1735\",\"attributes\":{\"filter\":{\"type\":\"object\",\"name\":\"AllIndices\",\"id\":\"p1736\"}}},\"glyph\":{\"type\":\"object\",\"name\":\"MultiLine\",\"id\":\"p1740\",\"attributes\":{\"line_color\":{\"type\":\"field\",\"field\":\"_color\"},\"line_alpha\":{\"type\":\"field\",\"field\":\"_alpha\"},\"line_width\":{\"type\":\"field\",\"field\":\"_size\"}}}}},\"selection_policy\":{\"type\":\"object\",\"name\":\"NodesOnly\",\"id\":\"p1737\"},\"inspection_policy\":{\"type\":\"object\",\"name\":\"NodesOnly\",\"id\":\"p1738\"}}}],\"toolbar\":{\"type\":\"object\",\"name\":\"Toolbar\",\"id\":\"p1698\",\"attributes\":{\"tools\":[{\"type\":\"object\",\"name\":\"BoxZoomTool\",\"id\":\"p1711\",\"attributes\":{\"dimensions\":\"both\",\"overlay\":{\"type\":\"object\",\"name\":\"BoxAnnotation\",\"id\":\"p1712\",\"attributes\":{\"syncable\":false,\"line_color\":\"black\",\"line_alpha\":1.0,\"line_width\":2,\"line_dash\":[4,4],\"fill_color\":\"lightgrey\",\"fill_alpha\":0.5,\"level\":\"overlay\",\"visible\":false,\"left\":{\"type\":\"number\",\"value\":\"nan\"},\"right\":{\"type\":\"number\",\"value\":\"nan\"},\"top\":{\"type\":\"number\",\"value\":\"nan\"},\"bottom\":{\"type\":\"number\",\"value\":\"nan\"},\"left_units\":\"canvas\",\"right_units\":\"canvas\",\"top_units\":\"canvas\",\"bottom_units\":\"canvas\",\"handles\":{\"type\":\"object\",\"name\":\"BoxInteractionHandles\",\"id\":\"p1718\",\"attributes\":{\"all\":{\"type\":\"object\",\"name\":\"AreaVisuals\",\"id\":\"p1717\",\"attributes\":{\"fill_color\":\"white\",\"hover_fill_color\":\"lightgray\"}}}}}}}},{\"type\":\"object\",\"name\":\"ResetTool\",\"id\":\"p1719\"},{\"type\":\"object\",\"name\":\"WheelZoomTool\",\"id\":\"p1720\",\"attributes\":{\"renderers\":\"auto\"}},{\"type\":\"object\",\"name\":\"PanTool\",\"id\":\"p1721\"},{\"type\":\"object\",\"name\":\"HoverTool\",\"id\":\"p1742\",\"attributes\":{\"renderers\":[{\"id\":\"p1734\"},{\"id\":\"p1727\"}],\"tooltips\":\"
\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n
start:@start
end:@end
weight:@weight
index:@index
type:@type
\",\"line_policy\":\"interp\"}}],\"logo\":null}},\"left\":[{\"type\":\"object\",\"name\":\"LinearAxis\",\"id\":\"p1706\",\"attributes\":{\"visible\":false,\"ticker\":{\"type\":\"object\",\"name\":\"BasicTicker\",\"id\":\"p1707\",\"attributes\":{\"mantissas\":[1,2,5]}},\"formatter\":{\"type\":\"object\",\"name\":\"BasicTickFormatter\",\"id\":\"p1708\"},\"major_label_policy\":{\"type\":\"object\",\"name\":\"AllLabels\",\"id\":\"p1709\"}}}],\"below\":[{\"type\":\"object\",\"name\":\"LinearAxis\",\"id\":\"p1701\",\"attributes\":{\"visible\":false,\"ticker\":{\"type\":\"object\",\"name\":\"BasicTicker\",\"id\":\"p1702\",\"attributes\":{\"mantissas\":[1,2,5]}},\"formatter\":{\"type\":\"object\",\"name\":\"BasicTickFormatter\",\"id\":\"p1703\"},\"major_label_policy\":{\"type\":\"object\",\"name\":\"AllLabels\",\"id\":\"p1704\"}}}],\"center\":[{\"type\":\"object\",\"name\":\"Grid\",\"id\":\"p1705\",\"attributes\":{\"axis\":{\"id\":\"p1701\"},\"grid_line_color\":null}},{\"type\":\"object\",\"name\":\"Grid\",\"id\":\"p1710\",\"attributes\":{\"dimension\":1,\"axis\":{\"id\":\"p1706\"},\"grid_line_color\":null}}]}}]}};\n const render_items = [{\"docid\":\"339c17ef-accd-4436-8df8-6048e60bfb0a\",\"roots\":{\"p1690\":\"dc172b4a-4f32-45cd-8f52-eb61428c5ced\"},\"root_ids\":[\"p1690\"],\"notebook_comms_target\":\"p1743\"}];\n void root.Bokeh.embed.embed_items_notebook(docs_json, render_items);\n }\n if (root.Bokeh !== undefined) {\n embed_document(root);\n } else {\n let attempts = 0;\n const timer = setInterval(function(root) {\n if (root.Bokeh !== undefined) {\n clearInterval(timer);\n embed_document(root);\n } else {\n attempts++;\n if (attempts > 100) {\n clearInterval(timer);\n console.log(\"Bokeh: ERROR: Unable to run BokehJS code because BokehJS library is missing\");\n }\n }\n }, 10, root)\n }\n})(window);", "application/vnd.bokehjs_exec.v0+json": "" }, "metadata": { "application/vnd.bokehjs_exec.v0+json": { "id": "p1690" } }, "output_type": "display_data" } ], "source": [ "inspector.plot_networks()" ] }, { "cell_type": "markdown", "id": "4e48dc73", "metadata": {}, "source": [ "Let's put `agent` back in the graph:" ] }, { "cell_type": "code", "execution_count": 36, "id": "d1bd0d4f", "metadata": {}, "outputs": [], "source": [ "model.add_agent(agent)" ] }, { "cell_type": "code", "execution_count": 37, "id": "16e66f4d", "metadata": {}, "outputs": [ { "data": { "application/javascript": "'use strict';\n(function(root) {\n function now() {\n return new Date();\n }\n\n const force = true;\n\n if (typeof root._bokeh_onload_callbacks === \"undefined\" || force === true) {\n root._bokeh_onload_callbacks = [];\n root._bokeh_is_loading = undefined;\n }\n\nconst JS_MIME_TYPE = 'application/javascript';\n const HTML_MIME_TYPE = 'text/html';\n const EXEC_MIME_TYPE = 'application/vnd.bokehjs_exec.v0+json';\n const CLASS_NAME = 'output_bokeh rendered_html';\n\n /**\n * Render data to the DOM node\n */\n function render(props, node) {\n const script = document.createElement(\"script\");\n node.appendChild(script);\n }\n\n /**\n * Handle when an output is cleared or removed\n */\n function handleClearOutput(event, handle) {\n function drop(id) {\n const view = Bokeh.index.get_by_id(id)\n if (view != null) {\n view.model.document.clear()\n Bokeh.index.delete(view)\n }\n }\n\n const cell = handle.cell;\n\n const id = cell.output_area._bokeh_element_id;\n const server_id = cell.output_area._bokeh_server_id;\n\n // Clean up Bokeh references\n if (id != null) {\n drop(id)\n }\n\n if (server_id !== undefined) {\n // Clean up Bokeh references\n const cmd_clean = \"from bokeh.io.state import curstate; print(curstate().uuid_to_server['\" + server_id + \"'].get_sessions()[0].document.roots[0]._id)\";\n cell.notebook.kernel.execute(cmd_clean, {\n iopub: {\n output: function(msg) {\n const id = msg.content.text.trim()\n drop(id)\n }\n }\n });\n // Destroy server and session\n const cmd_destroy = \"import bokeh.io.notebook as ion; ion.destroy_server('\" + server_id + \"')\";\n cell.notebook.kernel.execute(cmd_destroy);\n }\n }\n\n /**\n * Handle when a new output is added\n */\n function handleAddOutput(event, handle) {\n const output_area = handle.output_area;\n const output = handle.output;\n\n // limit handleAddOutput to display_data with EXEC_MIME_TYPE content only\n if ((output.output_type != \"display_data\") || (!Object.prototype.hasOwnProperty.call(output.data, EXEC_MIME_TYPE))) {\n return\n }\n\n const toinsert = output_area.element.find(\".\" + CLASS_NAME.split(' ')[0]);\n\n if (output.metadata[EXEC_MIME_TYPE][\"id\"] !== undefined) {\n toinsert[toinsert.length - 1].firstChild.textContent = output.data[JS_MIME_TYPE];\n // store reference to embed id on output_area\n output_area._bokeh_element_id = output.metadata[EXEC_MIME_TYPE][\"id\"];\n }\n if (output.metadata[EXEC_MIME_TYPE][\"server_id\"] !== undefined) {\n const bk_div = document.createElement(\"div\");\n bk_div.innerHTML = output.data[HTML_MIME_TYPE];\n const script_attrs = bk_div.children[0].attributes;\n for (let i = 0; i < script_attrs.length; i++) {\n toinsert[toinsert.length - 1].firstChild.setAttribute(script_attrs[i].name, script_attrs[i].value);\n toinsert[toinsert.length - 1].firstChild.textContent = bk_div.children[0].textContent\n }\n // store reference to server id on output_area\n output_area._bokeh_server_id = output.metadata[EXEC_MIME_TYPE][\"server_id\"];\n }\n }\n\n function register_renderer(events, OutputArea) {\n\n function append_mime(data, metadata, element) {\n // create a DOM node to render to\n const toinsert = this.create_output_subarea(\n metadata,\n CLASS_NAME,\n EXEC_MIME_TYPE\n );\n this.keyboard_manager.register_events(toinsert);\n // Render to node\n const props = {data: data, metadata: metadata[EXEC_MIME_TYPE]};\n render(props, toinsert[toinsert.length - 1]);\n element.append(toinsert);\n return toinsert\n }\n\n /* Handle when an output is cleared or removed */\n events.on('clear_output.CodeCell', handleClearOutput);\n events.on('delete.Cell', handleClearOutput);\n\n /* Handle when a new output is added */\n events.on('output_added.OutputArea', handleAddOutput);\n\n /**\n * Register the mime type and append_mime function with output_area\n */\n OutputArea.prototype.register_mime_type(EXEC_MIME_TYPE, append_mime, {\n /* Is output safe? */\n safe: true,\n /* Index of renderer in `output_area.display_order` */\n index: 0\n });\n }\n\n // register the mime type if in Jupyter Notebook environment and previously unregistered\n if (root.Jupyter !== undefined) {\n const events = require('base/js/events');\n const OutputArea = require('notebook/js/outputarea').OutputArea;\n\n if (OutputArea.prototype.mime_types().indexOf(EXEC_MIME_TYPE) == -1) {\n register_renderer(events, OutputArea);\n }\n }\n if (typeof (root._bokeh_timeout) === \"undefined\" || force === true) {\n root._bokeh_timeout = Date.now() + 5000;\n root._bokeh_failed_load = false;\n }\n\n const NB_LOAD_WARNING = {'data': {'text/html':\n \"
\\n\"+\n \"

\\n\"+\n \"BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this \\n\"+\n \"may be due to a slow or bad network connection. Possible fixes:\\n\"+\n \"

\\n\"+\n \"\\n\"+\n \"\\n\"+\n \"from bokeh.resources import INLINE\\n\"+\n \"output_notebook(resources=INLINE)\\n\"+\n \"\\n\"+\n \"
\"}};\n\n function display_loaded(error = null) {\n const el = document.getElementById(null);\n if (el != null) {\n const html = (() => {\n if (typeof root.Bokeh === \"undefined\") {\n if (error == null) {\n return \"BokehJS is loading ...\";\n } else {\n return \"BokehJS failed to load.\";\n }\n } else {\n const prefix = `BokehJS ${root.Bokeh.version}`;\n if (error == null) {\n return `${prefix} successfully loaded.`;\n } else {\n return `${prefix} encountered errors while loading and may not function as expected.`;\n }\n }\n })();\n el.innerHTML = html;\n\n if (error != null) {\n const wrapper = document.createElement(\"div\");\n wrapper.style.overflow = \"auto\";\n wrapper.style.height = \"5em\";\n wrapper.style.resize = \"vertical\";\n const content = document.createElement(\"div\");\n content.style.fontFamily = \"monospace\";\n content.style.whiteSpace = \"pre-wrap\";\n content.style.backgroundColor = \"rgb(255, 221, 221)\";\n content.textContent = error.stack ?? error.toString();\n wrapper.append(content);\n el.append(wrapper);\n }\n } else if (Date.now() < root._bokeh_timeout) {\n setTimeout(() => display_loaded(error), 100);\n }\n }\n\n function run_callbacks() {\n try {\n root._bokeh_onload_callbacks.forEach(function(callback) {\n if (callback != null)\n callback();\n });\n } finally {\n delete root._bokeh_onload_callbacks\n }\n console.debug(\"Bokeh: all callbacks have finished\");\n }\n\n function load_libs(css_urls, js_urls, callback) {\n if (css_urls == null) css_urls = [];\n if (js_urls == null) js_urls = [];\n\n root._bokeh_onload_callbacks.push(callback);\n if (root._bokeh_is_loading > 0) {\n console.debug(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n return null;\n }\n if (js_urls == null || js_urls.length === 0) {\n run_callbacks();\n return null;\n }\n console.debug(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n root._bokeh_is_loading = css_urls.length + js_urls.length;\n\n function on_load() {\n root._bokeh_is_loading--;\n if (root._bokeh_is_loading === 0) {\n console.debug(\"Bokeh: all BokehJS libraries/stylesheets loaded\");\n run_callbacks()\n }\n }\n\n function on_error(url) {\n console.error(\"failed to load \" + url);\n }\n\n for (let i = 0; i < css_urls.length; i++) {\n const url = css_urls[i];\n const element = document.createElement(\"link\");\n element.onload = on_load;\n element.onerror = on_error.bind(null, url);\n element.rel = \"stylesheet\";\n element.type = \"text/css\";\n element.href = url;\n console.debug(\"Bokeh: injecting link tag for BokehJS stylesheet: \", url);\n document.body.appendChild(element);\n }\n\n for (let i = 0; i < js_urls.length; i++) {\n const url = js_urls[i];\n const element = document.createElement('script');\n element.onload = on_load;\n element.onerror = on_error.bind(null, url);\n element.async = false;\n element.src = url;\n console.debug(\"Bokeh: injecting script tag for BokehJS library: \", url);\n document.head.appendChild(element);\n }\n };\n\n function inject_raw_css(css) {\n const element = document.createElement(\"style\");\n element.appendChild(document.createTextNode(css));\n document.body.appendChild(element);\n }\n\n const js_urls = [\"https://cdn.bokeh.org/bokeh/release/bokeh-3.7.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-gl-3.7.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-3.7.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-3.7.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-mathjax-3.7.1.min.js\"];\n const css_urls = [];\n\n const inline_js = [ function(Bokeh) {\n Bokeh.set_log_level(\"info\");\n },\nfunction(Bokeh) {\n }\n ];\n\n function run_inline_js() {\n if (root.Bokeh !== undefined || force === true) {\n try {\n for (let i = 0; i < inline_js.length; i++) {\n inline_js[i].call(root, root.Bokeh);\n }\n\n } catch (error) {throw error;\n }} else if (Date.now() < root._bokeh_timeout) {\n setTimeout(run_inline_js, 100);\n } else if (!root._bokeh_failed_load) {\n console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n root._bokeh_failed_load = true;\n } else if (force !== true) {\n const cell = $(document.getElementById(null)).parents('.cell').data().cell;\n cell.output_area.append_execute_result(NB_LOAD_WARNING)\n }\n }\n\n if (root._bokeh_is_loading === 0) {\n console.debug(\"Bokeh: BokehJS loaded, going straight to plotting\");\n run_inline_js();\n } else {\n load_libs(css_urls, js_urls, function() {\n console.debug(\"Bokeh: BokehJS plotting callback run at\", now());\n run_inline_js();\n });\n }\n}(window));", "application/vnd.bokehjs_load.v0+json": "" }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "\n", "
\n" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/javascript": "(function(root) {\n function embed_document(root) {\n const docs_json = {\"e4c613aa-6bbb-4cd0-b6eb-83f2cca53de2\":{\"version\":\"3.7.1\",\"title\":\"Bokeh Application\",\"roots\":[{\"type\":\"object\",\"name\":\"Figure\",\"id\":\"p1747\",\"attributes\":{\"width\":400,\"height\":400,\"x_range\":{\"type\":\"object\",\"name\":\"DataRange1d\",\"id\":\"p1748\"},\"y_range\":{\"type\":\"object\",\"name\":\"DataRange1d\",\"id\":\"p1749\"},\"x_scale\":{\"type\":\"object\",\"name\":\"LinearScale\",\"id\":\"p1756\"},\"y_scale\":{\"type\":\"object\",\"name\":\"LinearScale\",\"id\":\"p1757\"},\"title\":{\"type\":\"object\",\"name\":\"Title\",\"id\":\"p1754\"},\"renderers\":[{\"type\":\"object\",\"name\":\"GraphRenderer\",\"id\":\"p1779\",\"attributes\":{\"layout_provider\":{\"type\":\"object\",\"name\":\"StaticLayoutProvider\",\"id\":\"p1796\",\"attributes\":{\"graph_layout\":{\"type\":\"map\",\"entries\":[[2,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"FbQzJm/+7L+8ANiXfDHXPw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[3,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"pLJI8JED67+Gmm1vRS7PPw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[4,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"3QKvClUR1T8GZFvdwMbjvw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[5,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"Z99gDnb54j+B8mk7+f7dvw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[6,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"pdwIZ3GW3D+5CbcsEp7gvw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[1,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"Ji9/nk9p2D8AAAAAAADwPw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}]]}}},\"node_renderer\":{\"type\":\"object\",\"name\":\"GlyphRenderer\",\"id\":\"p1784\",\"attributes\":{\"data_source\":{\"type\":\"object\",\"name\":\"ColumnDataSource\",\"id\":\"p1781\",\"attributes\":{\"selected\":{\"type\":\"object\",\"name\":\"Selection\",\"id\":\"p1782\",\"attributes\":{\"indices\":[],\"line_indices\":[]}},\"selection_policy\":{\"type\":\"object\",\"name\":\"UnionRenderers\",\"id\":\"p1783\"},\"data\":{\"type\":\"map\",\"entries\":[[\"type\",[\"Location\",\"Agent\",\"Agent\",\"Agent\",\"School\",\"Agent\"]],[\"label\",[\"Location\",null,null,null,\"School\",null]],[\"bipartite\",[1,0,0,0,1,0]],[\"index\",[2,3,4,5,6,1]],[\"_marker\",[\"square\",\"circle\",\"circle\",\"circle\",\"square\",\"circle\"]],[\"_color\",[\"steelblue\",\"firebrick\",\"firebrick\",\"firebrick\",\"steelblue\",\"firebrick\"]],[\"_alpha\",[0.5,0.5,0.5,0.5,0.5,0.5]],[\"_size\",[10,10,10,10,10,10]],[\"start_display\",[\"none\",\"none\",\"none\",\"none\",\"none\",\"none\"]],[\"end_display\",[\"none\",\"none\",\"none\",\"none\",\"none\",\"none\"]],[\"weight_display\",[\"none\",\"none\",\"none\",\"none\",\"none\",\"none\"]],[\"index_display\",[1,1,1,1,1,1]],[\"type_display\",[1,1,1,1,1,1]],[\"label_display\",[1,\"none\",\"none\",\"none\",1,\"none\"]]]}}},\"view\":{\"type\":\"object\",\"name\":\"CDSView\",\"id\":\"p1785\",\"attributes\":{\"filter\":{\"type\":\"object\",\"name\":\"AllIndices\",\"id\":\"p1786\"}}},\"glyph\":{\"type\":\"object\",\"name\":\"Scatter\",\"id\":\"p1798\",\"attributes\":{\"size\":{\"type\":\"field\",\"field\":\"_size\"},\"line_color\":{\"type\":\"field\",\"field\":\"_color\"},\"line_alpha\":{\"type\":\"field\",\"field\":\"_alpha\"},\"fill_color\":{\"type\":\"field\",\"field\":\"_color\"},\"fill_alpha\":{\"type\":\"field\",\"field\":\"_alpha\"},\"marker\":{\"type\":\"field\",\"field\":\"_marker\"}}}}},\"edge_renderer\":{\"type\":\"object\",\"name\":\"GlyphRenderer\",\"id\":\"p1791\",\"attributes\":{\"data_source\":{\"type\":\"object\",\"name\":\"ColumnDataSource\",\"id\":\"p1788\",\"attributes\":{\"selected\":{\"type\":\"object\",\"name\":\"Selection\",\"id\":\"p1789\",\"attributes\":{\"indices\":[],\"line_indices\":[]}},\"selection_policy\":{\"type\":\"object\",\"name\":\"UnionRenderers\",\"id\":\"p1790\"},\"data\":{\"type\":\"map\",\"entries\":[[\"weight\",[1,1,1]],[\"start\",[2,4,5]],[\"end\",[3,6,6]],[\"_color\",[\"#440154\",\"#440154\",\"#440154\"]],[\"_alpha\",[1.0,1.0,1.0]],[\"_size\",[1.0,1.0,1.0]],[\"start_display\",[1,1,1]],[\"end_display\",[1,1,1]],[\"weight_display\",[1,1,1]],[\"index_display\",[\"none\",\"none\",\"none\"]],[\"type_display\",[\"none\",\"none\",\"none\"]],[\"label_display\",[\"none\",\"none\",\"none\"]]]}}},\"view\":{\"type\":\"object\",\"name\":\"CDSView\",\"id\":\"p1792\",\"attributes\":{\"filter\":{\"type\":\"object\",\"name\":\"AllIndices\",\"id\":\"p1793\"}}},\"glyph\":{\"type\":\"object\",\"name\":\"MultiLine\",\"id\":\"p1797\",\"attributes\":{\"line_color\":{\"type\":\"field\",\"field\":\"_color\"},\"line_alpha\":{\"type\":\"field\",\"field\":\"_alpha\"},\"line_width\":{\"type\":\"field\",\"field\":\"_size\"}}}}},\"selection_policy\":{\"type\":\"object\",\"name\":\"NodesOnly\",\"id\":\"p1794\"},\"inspection_policy\":{\"type\":\"object\",\"name\":\"NodesOnly\",\"id\":\"p1795\"}}}],\"toolbar\":{\"type\":\"object\",\"name\":\"Toolbar\",\"id\":\"p1755\",\"attributes\":{\"tools\":[{\"type\":\"object\",\"name\":\"BoxZoomTool\",\"id\":\"p1768\",\"attributes\":{\"dimensions\":\"both\",\"overlay\":{\"type\":\"object\",\"name\":\"BoxAnnotation\",\"id\":\"p1769\",\"attributes\":{\"syncable\":false,\"line_color\":\"black\",\"line_alpha\":1.0,\"line_width\":2,\"line_dash\":[4,4],\"fill_color\":\"lightgrey\",\"fill_alpha\":0.5,\"level\":\"overlay\",\"visible\":false,\"left\":{\"type\":\"number\",\"value\":\"nan\"},\"right\":{\"type\":\"number\",\"value\":\"nan\"},\"top\":{\"type\":\"number\",\"value\":\"nan\"},\"bottom\":{\"type\":\"number\",\"value\":\"nan\"},\"left_units\":\"canvas\",\"right_units\":\"canvas\",\"top_units\":\"canvas\",\"bottom_units\":\"canvas\",\"handles\":{\"type\":\"object\",\"name\":\"BoxInteractionHandles\",\"id\":\"p1775\",\"attributes\":{\"all\":{\"type\":\"object\",\"name\":\"AreaVisuals\",\"id\":\"p1774\",\"attributes\":{\"fill_color\":\"white\",\"hover_fill_color\":\"lightgray\"}}}}}}}},{\"type\":\"object\",\"name\":\"ResetTool\",\"id\":\"p1776\"},{\"type\":\"object\",\"name\":\"WheelZoomTool\",\"id\":\"p1777\",\"attributes\":{\"renderers\":\"auto\"}},{\"type\":\"object\",\"name\":\"PanTool\",\"id\":\"p1778\"},{\"type\":\"object\",\"name\":\"HoverTool\",\"id\":\"p1799\",\"attributes\":{\"renderers\":[{\"id\":\"p1791\"},{\"id\":\"p1784\"}],\"tooltips\":\"
\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n
start:@start
end:@end
weight:@weight
index:@index
type:@type
label:@label
\",\"line_policy\":\"interp\"}}],\"logo\":null}},\"left\":[{\"type\":\"object\",\"name\":\"LinearAxis\",\"id\":\"p1763\",\"attributes\":{\"visible\":false,\"ticker\":{\"type\":\"object\",\"name\":\"BasicTicker\",\"id\":\"p1764\",\"attributes\":{\"mantissas\":[1,2,5]}},\"formatter\":{\"type\":\"object\",\"name\":\"BasicTickFormatter\",\"id\":\"p1765\"},\"major_label_policy\":{\"type\":\"object\",\"name\":\"AllLabels\",\"id\":\"p1766\"}}}],\"below\":[{\"type\":\"object\",\"name\":\"LinearAxis\",\"id\":\"p1758\",\"attributes\":{\"visible\":false,\"ticker\":{\"type\":\"object\",\"name\":\"BasicTicker\",\"id\":\"p1759\",\"attributes\":{\"mantissas\":[1,2,5]}},\"formatter\":{\"type\":\"object\",\"name\":\"BasicTickFormatter\",\"id\":\"p1760\"},\"major_label_policy\":{\"type\":\"object\",\"name\":\"AllLabels\",\"id\":\"p1761\"}}}],\"center\":[{\"type\":\"object\",\"name\":\"Grid\",\"id\":\"p1762\",\"attributes\":{\"axis\":{\"id\":\"p1758\"},\"grid_line_color\":null}},{\"type\":\"object\",\"name\":\"Grid\",\"id\":\"p1767\",\"attributes\":{\"dimension\":1,\"axis\":{\"id\":\"p1763\"},\"grid_line_color\":null}}]}}]}};\n const render_items = [{\"docid\":\"e4c613aa-6bbb-4cd0-b6eb-83f2cca53de2\",\"roots\":{\"p1747\":\"d8e6983a-1fba-4da9-88b0-62ae2869eef5\"},\"root_ids\":[\"p1747\"],\"notebook_comms_target\":\"p1800\"}];\n void root.Bokeh.embed.embed_items_notebook(docs_json, render_items);\n }\n if (root.Bokeh !== undefined) {\n embed_document(root);\n } else {\n let attempts = 0;\n const timer = setInterval(function(root) {\n if (root.Bokeh !== undefined) {\n clearInterval(timer);\n embed_document(root);\n } else {\n attempts++;\n if (attempts > 100) {\n clearInterval(timer);\n console.log(\"Bokeh: ERROR: Unable to run BokehJS code because BokehJS library is missing\");\n }\n }\n }, 10, root)\n }\n})(window);", "application/vnd.bokehjs_exec.v0+json": "" }, "metadata": { "application/vnd.bokehjs_exec.v0+json": { "id": "p1747" } }, "output_type": "display_data" }, { "data": { "application/javascript": "'use strict';\n(function(root) {\n function now() {\n return new Date();\n }\n\n const force = true;\n\n if (typeof root._bokeh_onload_callbacks === \"undefined\" || force === true) {\n root._bokeh_onload_callbacks = [];\n root._bokeh_is_loading = undefined;\n }\n\nconst JS_MIME_TYPE = 'application/javascript';\n const HTML_MIME_TYPE = 'text/html';\n const EXEC_MIME_TYPE = 'application/vnd.bokehjs_exec.v0+json';\n const CLASS_NAME = 'output_bokeh rendered_html';\n\n /**\n * Render data to the DOM node\n */\n function render(props, node) {\n const script = document.createElement(\"script\");\n node.appendChild(script);\n }\n\n /**\n * Handle when an output is cleared or removed\n */\n function handleClearOutput(event, handle) {\n function drop(id) {\n const view = Bokeh.index.get_by_id(id)\n if (view != null) {\n view.model.document.clear()\n Bokeh.index.delete(view)\n }\n }\n\n const cell = handle.cell;\n\n const id = cell.output_area._bokeh_element_id;\n const server_id = cell.output_area._bokeh_server_id;\n\n // Clean up Bokeh references\n if (id != null) {\n drop(id)\n }\n\n if (server_id !== undefined) {\n // Clean up Bokeh references\n const cmd_clean = \"from bokeh.io.state import curstate; print(curstate().uuid_to_server['\" + server_id + \"'].get_sessions()[0].document.roots[0]._id)\";\n cell.notebook.kernel.execute(cmd_clean, {\n iopub: {\n output: function(msg) {\n const id = msg.content.text.trim()\n drop(id)\n }\n }\n });\n // Destroy server and session\n const cmd_destroy = \"import bokeh.io.notebook as ion; ion.destroy_server('\" + server_id + \"')\";\n cell.notebook.kernel.execute(cmd_destroy);\n }\n }\n\n /**\n * Handle when a new output is added\n */\n function handleAddOutput(event, handle) {\n const output_area = handle.output_area;\n const output = handle.output;\n\n // limit handleAddOutput to display_data with EXEC_MIME_TYPE content only\n if ((output.output_type != \"display_data\") || (!Object.prototype.hasOwnProperty.call(output.data, EXEC_MIME_TYPE))) {\n return\n }\n\n const toinsert = output_area.element.find(\".\" + CLASS_NAME.split(' ')[0]);\n\n if (output.metadata[EXEC_MIME_TYPE][\"id\"] !== undefined) {\n toinsert[toinsert.length - 1].firstChild.textContent = output.data[JS_MIME_TYPE];\n // store reference to embed id on output_area\n output_area._bokeh_element_id = output.metadata[EXEC_MIME_TYPE][\"id\"];\n }\n if (output.metadata[EXEC_MIME_TYPE][\"server_id\"] !== undefined) {\n const bk_div = document.createElement(\"div\");\n bk_div.innerHTML = output.data[HTML_MIME_TYPE];\n const script_attrs = bk_div.children[0].attributes;\n for (let i = 0; i < script_attrs.length; i++) {\n toinsert[toinsert.length - 1].firstChild.setAttribute(script_attrs[i].name, script_attrs[i].value);\n toinsert[toinsert.length - 1].firstChild.textContent = bk_div.children[0].textContent\n }\n // store reference to server id on output_area\n output_area._bokeh_server_id = output.metadata[EXEC_MIME_TYPE][\"server_id\"];\n }\n }\n\n function register_renderer(events, OutputArea) {\n\n function append_mime(data, metadata, element) {\n // create a DOM node to render to\n const toinsert = this.create_output_subarea(\n metadata,\n CLASS_NAME,\n EXEC_MIME_TYPE\n );\n this.keyboard_manager.register_events(toinsert);\n // Render to node\n const props = {data: data, metadata: metadata[EXEC_MIME_TYPE]};\n render(props, toinsert[toinsert.length - 1]);\n element.append(toinsert);\n return toinsert\n }\n\n /* Handle when an output is cleared or removed */\n events.on('clear_output.CodeCell', handleClearOutput);\n events.on('delete.Cell', handleClearOutput);\n\n /* Handle when a new output is added */\n events.on('output_added.OutputArea', handleAddOutput);\n\n /**\n * Register the mime type and append_mime function with output_area\n */\n OutputArea.prototype.register_mime_type(EXEC_MIME_TYPE, append_mime, {\n /* Is output safe? */\n safe: true,\n /* Index of renderer in `output_area.display_order` */\n index: 0\n });\n }\n\n // register the mime type if in Jupyter Notebook environment and previously unregistered\n if (root.Jupyter !== undefined) {\n const events = require('base/js/events');\n const OutputArea = require('notebook/js/outputarea').OutputArea;\n\n if (OutputArea.prototype.mime_types().indexOf(EXEC_MIME_TYPE) == -1) {\n register_renderer(events, OutputArea);\n }\n }\n if (typeof (root._bokeh_timeout) === \"undefined\" || force === true) {\n root._bokeh_timeout = Date.now() + 5000;\n root._bokeh_failed_load = false;\n }\n\n const NB_LOAD_WARNING = {'data': {'text/html':\n \"
\\n\"+\n \"

\\n\"+\n \"BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this \\n\"+\n \"may be due to a slow or bad network connection. Possible fixes:\\n\"+\n \"

\\n\"+\n \"\\n\"+\n \"\\n\"+\n \"from bokeh.resources import INLINE\\n\"+\n \"output_notebook(resources=INLINE)\\n\"+\n \"\\n\"+\n \"
\"}};\n\n function display_loaded(error = null) {\n const el = document.getElementById(null);\n if (el != null) {\n const html = (() => {\n if (typeof root.Bokeh === \"undefined\") {\n if (error == null) {\n return \"BokehJS is loading ...\";\n } else {\n return \"BokehJS failed to load.\";\n }\n } else {\n const prefix = `BokehJS ${root.Bokeh.version}`;\n if (error == null) {\n return `${prefix} successfully loaded.`;\n } else {\n return `${prefix} encountered errors while loading and may not function as expected.`;\n }\n }\n })();\n el.innerHTML = html;\n\n if (error != null) {\n const wrapper = document.createElement(\"div\");\n wrapper.style.overflow = \"auto\";\n wrapper.style.height = \"5em\";\n wrapper.style.resize = \"vertical\";\n const content = document.createElement(\"div\");\n content.style.fontFamily = \"monospace\";\n content.style.whiteSpace = \"pre-wrap\";\n content.style.backgroundColor = \"rgb(255, 221, 221)\";\n content.textContent = error.stack ?? error.toString();\n wrapper.append(content);\n el.append(wrapper);\n }\n } else if (Date.now() < root._bokeh_timeout) {\n setTimeout(() => display_loaded(error), 100);\n }\n }\n\n function run_callbacks() {\n try {\n root._bokeh_onload_callbacks.forEach(function(callback) {\n if (callback != null)\n callback();\n });\n } finally {\n delete root._bokeh_onload_callbacks\n }\n console.debug(\"Bokeh: all callbacks have finished\");\n }\n\n function load_libs(css_urls, js_urls, callback) {\n if (css_urls == null) css_urls = [];\n if (js_urls == null) js_urls = [];\n\n root._bokeh_onload_callbacks.push(callback);\n if (root._bokeh_is_loading > 0) {\n console.debug(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n return null;\n }\n if (js_urls == null || js_urls.length === 0) {\n run_callbacks();\n return null;\n }\n console.debug(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n root._bokeh_is_loading = css_urls.length + js_urls.length;\n\n function on_load() {\n root._bokeh_is_loading--;\n if (root._bokeh_is_loading === 0) {\n console.debug(\"Bokeh: all BokehJS libraries/stylesheets loaded\");\n run_callbacks()\n }\n }\n\n function on_error(url) {\n console.error(\"failed to load \" + url);\n }\n\n for (let i = 0; i < css_urls.length; i++) {\n const url = css_urls[i];\n const element = document.createElement(\"link\");\n element.onload = on_load;\n element.onerror = on_error.bind(null, url);\n element.rel = \"stylesheet\";\n element.type = \"text/css\";\n element.href = url;\n console.debug(\"Bokeh: injecting link tag for BokehJS stylesheet: \", url);\n document.body.appendChild(element);\n }\n\n for (let i = 0; i < js_urls.length; i++) {\n const url = js_urls[i];\n const element = document.createElement('script');\n element.onload = on_load;\n element.onerror = on_error.bind(null, url);\n element.async = false;\n element.src = url;\n console.debug(\"Bokeh: injecting script tag for BokehJS library: \", url);\n document.head.appendChild(element);\n }\n };\n\n function inject_raw_css(css) {\n const element = document.createElement(\"style\");\n element.appendChild(document.createTextNode(css));\n document.body.appendChild(element);\n }\n\n const js_urls = [\"https://cdn.bokeh.org/bokeh/release/bokeh-3.7.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-gl-3.7.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-3.7.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-3.7.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-mathjax-3.7.1.min.js\"];\n const css_urls = [];\n\n const inline_js = [ function(Bokeh) {\n Bokeh.set_log_level(\"info\");\n },\nfunction(Bokeh) {\n }\n ];\n\n function run_inline_js() {\n if (root.Bokeh !== undefined || force === true) {\n try {\n for (let i = 0; i < inline_js.length; i++) {\n inline_js[i].call(root, root.Bokeh);\n }\n\n } catch (error) {throw error;\n }} else if (Date.now() < root._bokeh_timeout) {\n setTimeout(run_inline_js, 100);\n } else if (!root._bokeh_failed_load) {\n console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n root._bokeh_failed_load = true;\n } else if (force !== true) {\n const cell = $(document.getElementById(null)).parents('.cell').data().cell;\n cell.output_area.append_execute_result(NB_LOAD_WARNING)\n }\n }\n\n if (root._bokeh_is_loading === 0) {\n console.debug(\"Bokeh: BokehJS loaded, going straight to plotting\");\n run_inline_js();\n } else {\n load_libs(css_urls, js_urls, function() {\n console.debug(\"Bokeh: BokehJS plotting callback run at\", now());\n run_inline_js();\n });\n }\n}(window));", "application/vnd.bokehjs_load.v0+json": "" }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "\n", "
\n" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/javascript": "(function(root) {\n function embed_document(root) {\n const docs_json = {\"ac95acab-a89e-49ec-89e7-05c2f6b0487e\":{\"version\":\"3.7.1\",\"title\":\"Bokeh Application\",\"roots\":[{\"type\":\"object\",\"name\":\"Figure\",\"id\":\"p1807\",\"attributes\":{\"width\":400,\"height\":400,\"x_range\":{\"type\":\"object\",\"name\":\"DataRange1d\",\"id\":\"p1808\"},\"y_range\":{\"type\":\"object\",\"name\":\"DataRange1d\",\"id\":\"p1809\"},\"x_scale\":{\"type\":\"object\",\"name\":\"LinearScale\",\"id\":\"p1816\"},\"y_scale\":{\"type\":\"object\",\"name\":\"LinearScale\",\"id\":\"p1817\"},\"title\":{\"type\":\"object\",\"name\":\"Title\",\"id\":\"p1814\"},\"renderers\":[{\"type\":\"object\",\"name\":\"GraphRenderer\",\"id\":\"p1839\",\"attributes\":{\"layout_provider\":{\"type\":\"object\",\"name\":\"StaticLayoutProvider\",\"id\":\"p1856\",\"attributes\":{\"graph_layout\":{\"type\":\"map\",\"entries\":[[3,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"uoEzCRnT4b8AAAAAAADwvw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[4,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"5jzICzNAoz85exKzoh6gvw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[5,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"bd46UVP/17/GvcOCCVjUPw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[1,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"Im0Ugb+e7D/RSM9p5dXmPw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}]]}}},\"node_renderer\":{\"type\":\"object\",\"name\":\"GlyphRenderer\",\"id\":\"p1844\",\"attributes\":{\"data_source\":{\"type\":\"object\",\"name\":\"ColumnDataSource\",\"id\":\"p1841\",\"attributes\":{\"selected\":{\"type\":\"object\",\"name\":\"Selection\",\"id\":\"p1842\",\"attributes\":{\"indices\":[],\"line_indices\":[]}},\"selection_policy\":{\"type\":\"object\",\"name\":\"UnionRenderers\",\"id\":\"p1843\"},\"data\":{\"type\":\"map\",\"entries\":[[\"type\",[\"Agent\",\"Agent\",\"Agent\",\"Agent\"]],[\"index\",[3,4,5,1]],[\"_marker\",[\"circle\",\"circle\",\"circle\",\"circle\"]],[\"_color\",[\"firebrick\",\"firebrick\",\"firebrick\",\"firebrick\"]],[\"_alpha\",[0.5,0.5,0.5,0.5]],[\"_size\",[10,10,10,10]],[\"start_display\",[\"none\",\"none\",\"none\",\"none\"]],[\"end_display\",[\"none\",\"none\",\"none\",\"none\"]],[\"weight_display\",[\"none\",\"none\",\"none\",\"none\"]],[\"index_display\",[1,1,1,1]],[\"type_display\",[1,1,1,1]]]}}},\"view\":{\"type\":\"object\",\"name\":\"CDSView\",\"id\":\"p1845\",\"attributes\":{\"filter\":{\"type\":\"object\",\"name\":\"AllIndices\",\"id\":\"p1846\"}}},\"glyph\":{\"type\":\"object\",\"name\":\"Scatter\",\"id\":\"p1858\",\"attributes\":{\"size\":{\"type\":\"field\",\"field\":\"_size\"},\"line_color\":{\"type\":\"field\",\"field\":\"_color\"},\"line_alpha\":{\"type\":\"field\",\"field\":\"_alpha\"},\"fill_color\":{\"type\":\"field\",\"field\":\"_color\"},\"fill_alpha\":{\"type\":\"field\",\"field\":\"_alpha\"},\"marker\":{\"type\":\"field\",\"field\":\"_marker\"}}}}},\"edge_renderer\":{\"type\":\"object\",\"name\":\"GlyphRenderer\",\"id\":\"p1851\",\"attributes\":{\"data_source\":{\"type\":\"object\",\"name\":\"ColumnDataSource\",\"id\":\"p1848\",\"attributes\":{\"selected\":{\"type\":\"object\",\"name\":\"Selection\",\"id\":\"p1849\",\"attributes\":{\"indices\":[],\"line_indices\":[]}},\"selection_policy\":{\"type\":\"object\",\"name\":\"UnionRenderers\",\"id\":\"p1850\"},\"data\":{\"type\":\"map\",\"entries\":[[\"weight\",[1]],[\"start\",[4]],[\"end\",[5]],[\"_color\",[\"#440154\"]],[\"_alpha\",[1.0]],[\"_size\",[1.0]],[\"start_display\",[1]],[\"end_display\",[1]],[\"weight_display\",[1]],[\"index_display\",[\"none\"]],[\"type_display\",[\"none\"]]]}}},\"view\":{\"type\":\"object\",\"name\":\"CDSView\",\"id\":\"p1852\",\"attributes\":{\"filter\":{\"type\":\"object\",\"name\":\"AllIndices\",\"id\":\"p1853\"}}},\"glyph\":{\"type\":\"object\",\"name\":\"MultiLine\",\"id\":\"p1857\",\"attributes\":{\"line_color\":{\"type\":\"field\",\"field\":\"_color\"},\"line_alpha\":{\"type\":\"field\",\"field\":\"_alpha\"},\"line_width\":{\"type\":\"field\",\"field\":\"_size\"}}}}},\"selection_policy\":{\"type\":\"object\",\"name\":\"NodesOnly\",\"id\":\"p1854\"},\"inspection_policy\":{\"type\":\"object\",\"name\":\"NodesOnly\",\"id\":\"p1855\"}}}],\"toolbar\":{\"type\":\"object\",\"name\":\"Toolbar\",\"id\":\"p1815\",\"attributes\":{\"tools\":[{\"type\":\"object\",\"name\":\"BoxZoomTool\",\"id\":\"p1828\",\"attributes\":{\"dimensions\":\"both\",\"overlay\":{\"type\":\"object\",\"name\":\"BoxAnnotation\",\"id\":\"p1829\",\"attributes\":{\"syncable\":false,\"line_color\":\"black\",\"line_alpha\":1.0,\"line_width\":2,\"line_dash\":[4,4],\"fill_color\":\"lightgrey\",\"fill_alpha\":0.5,\"level\":\"overlay\",\"visible\":false,\"left\":{\"type\":\"number\",\"value\":\"nan\"},\"right\":{\"type\":\"number\",\"value\":\"nan\"},\"top\":{\"type\":\"number\",\"value\":\"nan\"},\"bottom\":{\"type\":\"number\",\"value\":\"nan\"},\"left_units\":\"canvas\",\"right_units\":\"canvas\",\"top_units\":\"canvas\",\"bottom_units\":\"canvas\",\"handles\":{\"type\":\"object\",\"name\":\"BoxInteractionHandles\",\"id\":\"p1835\",\"attributes\":{\"all\":{\"type\":\"object\",\"name\":\"AreaVisuals\",\"id\":\"p1834\",\"attributes\":{\"fill_color\":\"white\",\"hover_fill_color\":\"lightgray\"}}}}}}}},{\"type\":\"object\",\"name\":\"ResetTool\",\"id\":\"p1836\"},{\"type\":\"object\",\"name\":\"WheelZoomTool\",\"id\":\"p1837\",\"attributes\":{\"renderers\":\"auto\"}},{\"type\":\"object\",\"name\":\"PanTool\",\"id\":\"p1838\"},{\"type\":\"object\",\"name\":\"HoverTool\",\"id\":\"p1859\",\"attributes\":{\"renderers\":[{\"id\":\"p1851\"},{\"id\":\"p1844\"}],\"tooltips\":\"
\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n
start:@start
end:@end
weight:@weight
index:@index
type:@type
\",\"line_policy\":\"interp\"}}],\"logo\":null}},\"left\":[{\"type\":\"object\",\"name\":\"LinearAxis\",\"id\":\"p1823\",\"attributes\":{\"visible\":false,\"ticker\":{\"type\":\"object\",\"name\":\"BasicTicker\",\"id\":\"p1824\",\"attributes\":{\"mantissas\":[1,2,5]}},\"formatter\":{\"type\":\"object\",\"name\":\"BasicTickFormatter\",\"id\":\"p1825\"},\"major_label_policy\":{\"type\":\"object\",\"name\":\"AllLabels\",\"id\":\"p1826\"}}}],\"below\":[{\"type\":\"object\",\"name\":\"LinearAxis\",\"id\":\"p1818\",\"attributes\":{\"visible\":false,\"ticker\":{\"type\":\"object\",\"name\":\"BasicTicker\",\"id\":\"p1819\",\"attributes\":{\"mantissas\":[1,2,5]}},\"formatter\":{\"type\":\"object\",\"name\":\"BasicTickFormatter\",\"id\":\"p1820\"},\"major_label_policy\":{\"type\":\"object\",\"name\":\"AllLabels\",\"id\":\"p1821\"}}}],\"center\":[{\"type\":\"object\",\"name\":\"Grid\",\"id\":\"p1822\",\"attributes\":{\"axis\":{\"id\":\"p1818\"},\"grid_line_color\":null}},{\"type\":\"object\",\"name\":\"Grid\",\"id\":\"p1827\",\"attributes\":{\"dimension\":1,\"axis\":{\"id\":\"p1823\"},\"grid_line_color\":null}}]}}]}};\n const render_items = [{\"docid\":\"ac95acab-a89e-49ec-89e7-05c2f6b0487e\",\"roots\":{\"p1807\":\"fcf2e335-8848-42a8-b4c6-8f15ed1e13e4\"},\"root_ids\":[\"p1807\"],\"notebook_comms_target\":\"p1860\"}];\n void root.Bokeh.embed.embed_items_notebook(docs_json, render_items);\n }\n if (root.Bokeh !== undefined) {\n embed_document(root);\n } else {\n let attempts = 0;\n const timer = setInterval(function(root) {\n if (root.Bokeh !== undefined) {\n clearInterval(timer);\n embed_document(root);\n } else {\n attempts++;\n if (attempts > 100) {\n clearInterval(timer);\n console.log(\"Bokeh: ERROR: Unable to run BokehJS code because BokehJS library is missing\");\n }\n }\n }, 10, root)\n }\n})(window);", "application/vnd.bokehjs_exec.v0+json": "" }, "metadata": { "application/vnd.bokehjs_exec.v0+json": { "id": "p1807" } }, "output_type": "display_data" } ], "source": [ "inspector.plot_networks()" ] }, { "cell_type": "markdown", "id": "661cf9a8", "metadata": {}, "source": [ "## Connecting agents quickly\n", "\n", "In Pop2net, agents are considered connected if they share a location.\n", "Thus, in order to connect agents, we first have to create a location first and then assign the agents to this location.\n", "\n", "The methods `agent.connect()` and `model.connect_agents()` simplify that process by creating an instance from a given location class and directly assigning the given agents to this location instance.\n", "If no location class is set as the argument `location_cls`, `p2n.Location` is used as a default location class.\n", "In the following, we connect `agent` with the second agent of the model `model.agents[1]` using `agent.connect()`.\n", "Under the hood, Pop2net creates one new location instance and assigns both agents to this location." ] }, { "cell_type": "code", "execution_count": 38, "id": "540be934", "metadata": {}, "outputs": [], "source": [ "agent.connect(agent=model.agents[1])" ] }, { "cell_type": "code", "execution_count": 39, "id": "79d9e37e", "metadata": {}, "outputs": [ { "data": { "application/javascript": "'use strict';\n(function(root) {\n function now() {\n return new Date();\n }\n\n const force = true;\n\n if (typeof root._bokeh_onload_callbacks === \"undefined\" || force === true) {\n root._bokeh_onload_callbacks = [];\n root._bokeh_is_loading = undefined;\n }\n\nconst JS_MIME_TYPE = 'application/javascript';\n const HTML_MIME_TYPE = 'text/html';\n const EXEC_MIME_TYPE = 'application/vnd.bokehjs_exec.v0+json';\n const CLASS_NAME = 'output_bokeh rendered_html';\n\n /**\n * Render data to the DOM node\n */\n function render(props, node) {\n const script = document.createElement(\"script\");\n node.appendChild(script);\n }\n\n /**\n * Handle when an output is cleared or removed\n */\n function handleClearOutput(event, handle) {\n function drop(id) {\n const view = Bokeh.index.get_by_id(id)\n if (view != null) {\n view.model.document.clear()\n Bokeh.index.delete(view)\n }\n }\n\n const cell = handle.cell;\n\n const id = cell.output_area._bokeh_element_id;\n const server_id = cell.output_area._bokeh_server_id;\n\n // Clean up Bokeh references\n if (id != null) {\n drop(id)\n }\n\n if (server_id !== undefined) {\n // Clean up Bokeh references\n const cmd_clean = \"from bokeh.io.state import curstate; print(curstate().uuid_to_server['\" + server_id + \"'].get_sessions()[0].document.roots[0]._id)\";\n cell.notebook.kernel.execute(cmd_clean, {\n iopub: {\n output: function(msg) {\n const id = msg.content.text.trim()\n drop(id)\n }\n }\n });\n // Destroy server and session\n const cmd_destroy = \"import bokeh.io.notebook as ion; ion.destroy_server('\" + server_id + \"')\";\n cell.notebook.kernel.execute(cmd_destroy);\n }\n }\n\n /**\n * Handle when a new output is added\n */\n function handleAddOutput(event, handle) {\n const output_area = handle.output_area;\n const output = handle.output;\n\n // limit handleAddOutput to display_data with EXEC_MIME_TYPE content only\n if ((output.output_type != \"display_data\") || (!Object.prototype.hasOwnProperty.call(output.data, EXEC_MIME_TYPE))) {\n return\n }\n\n const toinsert = output_area.element.find(\".\" + CLASS_NAME.split(' ')[0]);\n\n if (output.metadata[EXEC_MIME_TYPE][\"id\"] !== undefined) {\n toinsert[toinsert.length - 1].firstChild.textContent = output.data[JS_MIME_TYPE];\n // store reference to embed id on output_area\n output_area._bokeh_element_id = output.metadata[EXEC_MIME_TYPE][\"id\"];\n }\n if (output.metadata[EXEC_MIME_TYPE][\"server_id\"] !== undefined) {\n const bk_div = document.createElement(\"div\");\n bk_div.innerHTML = output.data[HTML_MIME_TYPE];\n const script_attrs = bk_div.children[0].attributes;\n for (let i = 0; i < script_attrs.length; i++) {\n toinsert[toinsert.length - 1].firstChild.setAttribute(script_attrs[i].name, script_attrs[i].value);\n toinsert[toinsert.length - 1].firstChild.textContent = bk_div.children[0].textContent\n }\n // store reference to server id on output_area\n output_area._bokeh_server_id = output.metadata[EXEC_MIME_TYPE][\"server_id\"];\n }\n }\n\n function register_renderer(events, OutputArea) {\n\n function append_mime(data, metadata, element) {\n // create a DOM node to render to\n const toinsert = this.create_output_subarea(\n metadata,\n CLASS_NAME,\n EXEC_MIME_TYPE\n );\n this.keyboard_manager.register_events(toinsert);\n // Render to node\n const props = {data: data, metadata: metadata[EXEC_MIME_TYPE]};\n render(props, toinsert[toinsert.length - 1]);\n element.append(toinsert);\n return toinsert\n }\n\n /* Handle when an output is cleared or removed */\n events.on('clear_output.CodeCell', handleClearOutput);\n events.on('delete.Cell', handleClearOutput);\n\n /* Handle when a new output is added */\n events.on('output_added.OutputArea', handleAddOutput);\n\n /**\n * Register the mime type and append_mime function with output_area\n */\n OutputArea.prototype.register_mime_type(EXEC_MIME_TYPE, append_mime, {\n /* Is output safe? */\n safe: true,\n /* Index of renderer in `output_area.display_order` */\n index: 0\n });\n }\n\n // register the mime type if in Jupyter Notebook environment and previously unregistered\n if (root.Jupyter !== undefined) {\n const events = require('base/js/events');\n const OutputArea = require('notebook/js/outputarea').OutputArea;\n\n if (OutputArea.prototype.mime_types().indexOf(EXEC_MIME_TYPE) == -1) {\n register_renderer(events, OutputArea);\n }\n }\n if (typeof (root._bokeh_timeout) === \"undefined\" || force === true) {\n root._bokeh_timeout = Date.now() + 5000;\n root._bokeh_failed_load = false;\n }\n\n const NB_LOAD_WARNING = {'data': {'text/html':\n \"
\\n\"+\n \"

\\n\"+\n \"BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this \\n\"+\n \"may be due to a slow or bad network connection. Possible fixes:\\n\"+\n \"

\\n\"+\n \"\\n\"+\n \"\\n\"+\n \"from bokeh.resources import INLINE\\n\"+\n \"output_notebook(resources=INLINE)\\n\"+\n \"\\n\"+\n \"
\"}};\n\n function display_loaded(error = null) {\n const el = document.getElementById(null);\n if (el != null) {\n const html = (() => {\n if (typeof root.Bokeh === \"undefined\") {\n if (error == null) {\n return \"BokehJS is loading ...\";\n } else {\n return \"BokehJS failed to load.\";\n }\n } else {\n const prefix = `BokehJS ${root.Bokeh.version}`;\n if (error == null) {\n return `${prefix} successfully loaded.`;\n } else {\n return `${prefix} encountered errors while loading and may not function as expected.`;\n }\n }\n })();\n el.innerHTML = html;\n\n if (error != null) {\n const wrapper = document.createElement(\"div\");\n wrapper.style.overflow = \"auto\";\n wrapper.style.height = \"5em\";\n wrapper.style.resize = \"vertical\";\n const content = document.createElement(\"div\");\n content.style.fontFamily = \"monospace\";\n content.style.whiteSpace = \"pre-wrap\";\n content.style.backgroundColor = \"rgb(255, 221, 221)\";\n content.textContent = error.stack ?? error.toString();\n wrapper.append(content);\n el.append(wrapper);\n }\n } else if (Date.now() < root._bokeh_timeout) {\n setTimeout(() => display_loaded(error), 100);\n }\n }\n\n function run_callbacks() {\n try {\n root._bokeh_onload_callbacks.forEach(function(callback) {\n if (callback != null)\n callback();\n });\n } finally {\n delete root._bokeh_onload_callbacks\n }\n console.debug(\"Bokeh: all callbacks have finished\");\n }\n\n function load_libs(css_urls, js_urls, callback) {\n if (css_urls == null) css_urls = [];\n if (js_urls == null) js_urls = [];\n\n root._bokeh_onload_callbacks.push(callback);\n if (root._bokeh_is_loading > 0) {\n console.debug(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n return null;\n }\n if (js_urls == null || js_urls.length === 0) {\n run_callbacks();\n return null;\n }\n console.debug(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n root._bokeh_is_loading = css_urls.length + js_urls.length;\n\n function on_load() {\n root._bokeh_is_loading--;\n if (root._bokeh_is_loading === 0) {\n console.debug(\"Bokeh: all BokehJS libraries/stylesheets loaded\");\n run_callbacks()\n }\n }\n\n function on_error(url) {\n console.error(\"failed to load \" + url);\n }\n\n for (let i = 0; i < css_urls.length; i++) {\n const url = css_urls[i];\n const element = document.createElement(\"link\");\n element.onload = on_load;\n element.onerror = on_error.bind(null, url);\n element.rel = \"stylesheet\";\n element.type = \"text/css\";\n element.href = url;\n console.debug(\"Bokeh: injecting link tag for BokehJS stylesheet: \", url);\n document.body.appendChild(element);\n }\n\n for (let i = 0; i < js_urls.length; i++) {\n const url = js_urls[i];\n const element = document.createElement('script');\n element.onload = on_load;\n element.onerror = on_error.bind(null, url);\n element.async = false;\n element.src = url;\n console.debug(\"Bokeh: injecting script tag for BokehJS library: \", url);\n document.head.appendChild(element);\n }\n };\n\n function inject_raw_css(css) {\n const element = document.createElement(\"style\");\n element.appendChild(document.createTextNode(css));\n document.body.appendChild(element);\n }\n\n const js_urls = [\"https://cdn.bokeh.org/bokeh/release/bokeh-3.7.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-gl-3.7.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-3.7.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-3.7.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-mathjax-3.7.1.min.js\"];\n const css_urls = [];\n\n const inline_js = [ function(Bokeh) {\n Bokeh.set_log_level(\"info\");\n },\nfunction(Bokeh) {\n }\n ];\n\n function run_inline_js() {\n if (root.Bokeh !== undefined || force === true) {\n try {\n for (let i = 0; i < inline_js.length; i++) {\n inline_js[i].call(root, root.Bokeh);\n }\n\n } catch (error) {throw error;\n }} else if (Date.now() < root._bokeh_timeout) {\n setTimeout(run_inline_js, 100);\n } else if (!root._bokeh_failed_load) {\n console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n root._bokeh_failed_load = true;\n } else if (force !== true) {\n const cell = $(document.getElementById(null)).parents('.cell').data().cell;\n cell.output_area.append_execute_result(NB_LOAD_WARNING)\n }\n }\n\n if (root._bokeh_is_loading === 0) {\n console.debug(\"Bokeh: BokehJS loaded, going straight to plotting\");\n run_inline_js();\n } else {\n load_libs(css_urls, js_urls, function() {\n console.debug(\"Bokeh: BokehJS plotting callback run at\", now());\n run_inline_js();\n });\n }\n}(window));", "application/vnd.bokehjs_load.v0+json": "" }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "\n", "
\n" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/javascript": "(function(root) {\n function embed_document(root) {\n const docs_json = {\"5e6eaccb-9946-41d4-962b-fc8ea41c6a62\":{\"version\":\"3.7.1\",\"title\":\"Bokeh Application\",\"roots\":[{\"type\":\"object\",\"name\":\"Figure\",\"id\":\"p1865\",\"attributes\":{\"width\":400,\"height\":400,\"x_range\":{\"type\":\"object\",\"name\":\"DataRange1d\",\"id\":\"p1866\"},\"y_range\":{\"type\":\"object\",\"name\":\"DataRange1d\",\"id\":\"p1867\"},\"x_scale\":{\"type\":\"object\",\"name\":\"LinearScale\",\"id\":\"p1874\"},\"y_scale\":{\"type\":\"object\",\"name\":\"LinearScale\",\"id\":\"p1875\"},\"title\":{\"type\":\"object\",\"name\":\"Title\",\"id\":\"p1872\"},\"renderers\":[{\"type\":\"object\",\"name\":\"GraphRenderer\",\"id\":\"p1897\",\"attributes\":{\"layout_provider\":{\"type\":\"object\",\"name\":\"StaticLayoutProvider\",\"id\":\"p1914\",\"attributes\":{\"graph_layout\":{\"type\":\"map\",\"entries\":[[2,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"k3tCL3uHuL8AAAAAAADwvw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[3,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"6i8E0EimvD9jaYE7FPDtvw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[4,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"oiwSuB5Io7/38eUm1hLRPw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[5,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"34DT+YNZ3r8b6gjpBuDhPw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[6,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"F0JsyHfL07+lpoPbXfvXPw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[1,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"59pYA7cb4T+S/rUVIVXaPw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[7,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"qeVfKt5O0T9hZ9GMxbzUPw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}]]}}},\"node_renderer\":{\"type\":\"object\",\"name\":\"GlyphRenderer\",\"id\":\"p1902\",\"attributes\":{\"data_source\":{\"type\":\"object\",\"name\":\"ColumnDataSource\",\"id\":\"p1899\",\"attributes\":{\"selected\":{\"type\":\"object\",\"name\":\"Selection\",\"id\":\"p1900\",\"attributes\":{\"indices\":[],\"line_indices\":[]}},\"selection_policy\":{\"type\":\"object\",\"name\":\"UnionRenderers\",\"id\":\"p1901\"},\"data\":{\"type\":\"map\",\"entries\":[[\"type\",[\"Location\",\"Agent\",\"Agent\",\"Agent\",\"School\",\"Agent\",\"Location\"]],[\"label\",[\"Location\",null,null,null,\"School\",null,\"Location\"]],[\"bipartite\",[1,0,0,0,1,0,1]],[\"index\",[2,3,4,5,6,1,7]],[\"_marker\",[\"square\",\"circle\",\"circle\",\"circle\",\"square\",\"circle\",\"square\"]],[\"_color\",[\"steelblue\",\"firebrick\",\"firebrick\",\"firebrick\",\"steelblue\",\"firebrick\",\"steelblue\"]],[\"_alpha\",[0.5,0.5,0.5,0.5,0.5,0.5,0.5]],[\"_size\",[10,10,10,10,10,10,10]],[\"start_display\",[\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\"]],[\"end_display\",[\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\"]],[\"weight_display\",[\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\"]],[\"index_display\",[1,1,1,1,1,1,1]],[\"type_display\",[1,1,1,1,1,1,1]],[\"label_display\",[1,\"none\",\"none\",\"none\",1,\"none\",1]]]}}},\"view\":{\"type\":\"object\",\"name\":\"CDSView\",\"id\":\"p1903\",\"attributes\":{\"filter\":{\"type\":\"object\",\"name\":\"AllIndices\",\"id\":\"p1904\"}}},\"glyph\":{\"type\":\"object\",\"name\":\"Scatter\",\"id\":\"p1916\",\"attributes\":{\"size\":{\"type\":\"field\",\"field\":\"_size\"},\"line_color\":{\"type\":\"field\",\"field\":\"_color\"},\"line_alpha\":{\"type\":\"field\",\"field\":\"_alpha\"},\"fill_color\":{\"type\":\"field\",\"field\":\"_color\"},\"fill_alpha\":{\"type\":\"field\",\"field\":\"_alpha\"},\"marker\":{\"type\":\"field\",\"field\":\"_marker\"}}}}},\"edge_renderer\":{\"type\":\"object\",\"name\":\"GlyphRenderer\",\"id\":\"p1909\",\"attributes\":{\"data_source\":{\"type\":\"object\",\"name\":\"ColumnDataSource\",\"id\":\"p1906\",\"attributes\":{\"selected\":{\"type\":\"object\",\"name\":\"Selection\",\"id\":\"p1907\",\"attributes\":{\"indices\":[],\"line_indices\":[]}},\"selection_policy\":{\"type\":\"object\",\"name\":\"UnionRenderers\",\"id\":\"p1908\"},\"data\":{\"type\":\"map\",\"entries\":[[\"weight\",[1,1,1,1,1]],[\"start\",[2,4,4,5,1]],[\"end\",[3,6,7,6,7]],[\"_color\",[\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\"]],[\"_alpha\",[1.0,1.0,1.0,1.0,1.0]],[\"_size\",[1.0,1.0,1.0,1.0,1.0]],[\"start_display\",[1,1,1,1,1]],[\"end_display\",[1,1,1,1,1]],[\"weight_display\",[1,1,1,1,1]],[\"index_display\",[\"none\",\"none\",\"none\",\"none\",\"none\"]],[\"type_display\",[\"none\",\"none\",\"none\",\"none\",\"none\"]],[\"label_display\",[\"none\",\"none\",\"none\",\"none\",\"none\"]]]}}},\"view\":{\"type\":\"object\",\"name\":\"CDSView\",\"id\":\"p1910\",\"attributes\":{\"filter\":{\"type\":\"object\",\"name\":\"AllIndices\",\"id\":\"p1911\"}}},\"glyph\":{\"type\":\"object\",\"name\":\"MultiLine\",\"id\":\"p1915\",\"attributes\":{\"line_color\":{\"type\":\"field\",\"field\":\"_color\"},\"line_alpha\":{\"type\":\"field\",\"field\":\"_alpha\"},\"line_width\":{\"type\":\"field\",\"field\":\"_size\"}}}}},\"selection_policy\":{\"type\":\"object\",\"name\":\"NodesOnly\",\"id\":\"p1912\"},\"inspection_policy\":{\"type\":\"object\",\"name\":\"NodesOnly\",\"id\":\"p1913\"}}}],\"toolbar\":{\"type\":\"object\",\"name\":\"Toolbar\",\"id\":\"p1873\",\"attributes\":{\"tools\":[{\"type\":\"object\",\"name\":\"BoxZoomTool\",\"id\":\"p1886\",\"attributes\":{\"dimensions\":\"both\",\"overlay\":{\"type\":\"object\",\"name\":\"BoxAnnotation\",\"id\":\"p1887\",\"attributes\":{\"syncable\":false,\"line_color\":\"black\",\"line_alpha\":1.0,\"line_width\":2,\"line_dash\":[4,4],\"fill_color\":\"lightgrey\",\"fill_alpha\":0.5,\"level\":\"overlay\",\"visible\":false,\"left\":{\"type\":\"number\",\"value\":\"nan\"},\"right\":{\"type\":\"number\",\"value\":\"nan\"},\"top\":{\"type\":\"number\",\"value\":\"nan\"},\"bottom\":{\"type\":\"number\",\"value\":\"nan\"},\"left_units\":\"canvas\",\"right_units\":\"canvas\",\"top_units\":\"canvas\",\"bottom_units\":\"canvas\",\"handles\":{\"type\":\"object\",\"name\":\"BoxInteractionHandles\",\"id\":\"p1893\",\"attributes\":{\"all\":{\"type\":\"object\",\"name\":\"AreaVisuals\",\"id\":\"p1892\",\"attributes\":{\"fill_color\":\"white\",\"hover_fill_color\":\"lightgray\"}}}}}}}},{\"type\":\"object\",\"name\":\"ResetTool\",\"id\":\"p1894\"},{\"type\":\"object\",\"name\":\"WheelZoomTool\",\"id\":\"p1895\",\"attributes\":{\"renderers\":\"auto\"}},{\"type\":\"object\",\"name\":\"PanTool\",\"id\":\"p1896\"},{\"type\":\"object\",\"name\":\"HoverTool\",\"id\":\"p1917\",\"attributes\":{\"renderers\":[{\"id\":\"p1909\"},{\"id\":\"p1902\"}],\"tooltips\":\"
\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n
start:@start
end:@end
weight:@weight
index:@index
type:@type
label:@label
\",\"line_policy\":\"interp\"}}],\"logo\":null}},\"left\":[{\"type\":\"object\",\"name\":\"LinearAxis\",\"id\":\"p1881\",\"attributes\":{\"visible\":false,\"ticker\":{\"type\":\"object\",\"name\":\"BasicTicker\",\"id\":\"p1882\",\"attributes\":{\"mantissas\":[1,2,5]}},\"formatter\":{\"type\":\"object\",\"name\":\"BasicTickFormatter\",\"id\":\"p1883\"},\"major_label_policy\":{\"type\":\"object\",\"name\":\"AllLabels\",\"id\":\"p1884\"}}}],\"below\":[{\"type\":\"object\",\"name\":\"LinearAxis\",\"id\":\"p1876\",\"attributes\":{\"visible\":false,\"ticker\":{\"type\":\"object\",\"name\":\"BasicTicker\",\"id\":\"p1877\",\"attributes\":{\"mantissas\":[1,2,5]}},\"formatter\":{\"type\":\"object\",\"name\":\"BasicTickFormatter\",\"id\":\"p1878\"},\"major_label_policy\":{\"type\":\"object\",\"name\":\"AllLabels\",\"id\":\"p1879\"}}}],\"center\":[{\"type\":\"object\",\"name\":\"Grid\",\"id\":\"p1880\",\"attributes\":{\"axis\":{\"id\":\"p1876\"},\"grid_line_color\":null}},{\"type\":\"object\",\"name\":\"Grid\",\"id\":\"p1885\",\"attributes\":{\"dimension\":1,\"axis\":{\"id\":\"p1881\"},\"grid_line_color\":null}}]}}]}};\n const render_items = [{\"docid\":\"5e6eaccb-9946-41d4-962b-fc8ea41c6a62\",\"roots\":{\"p1865\":\"db7179b6-f7fe-4180-ba40-2d40a6cd8335\"},\"root_ids\":[\"p1865\"],\"notebook_comms_target\":\"p1918\"}];\n void root.Bokeh.embed.embed_items_notebook(docs_json, render_items);\n }\n if (root.Bokeh !== undefined) {\n embed_document(root);\n } else {\n let attempts = 0;\n const timer = setInterval(function(root) {\n if (root.Bokeh !== undefined) {\n clearInterval(timer);\n embed_document(root);\n } else {\n attempts++;\n if (attempts > 100) {\n clearInterval(timer);\n console.log(\"Bokeh: ERROR: Unable to run BokehJS code because BokehJS library is missing\");\n }\n }\n }, 10, root)\n }\n})(window);", "application/vnd.bokehjs_exec.v0+json": "" }, "metadata": { "application/vnd.bokehjs_exec.v0+json": { "id": "p1865" } }, "output_type": "display_data" }, { "data": { "application/javascript": "'use strict';\n(function(root) {\n function now() {\n return new Date();\n }\n\n const force = true;\n\n if (typeof root._bokeh_onload_callbacks === \"undefined\" || force === true) {\n root._bokeh_onload_callbacks = [];\n root._bokeh_is_loading = undefined;\n }\n\nconst JS_MIME_TYPE = 'application/javascript';\n const HTML_MIME_TYPE = 'text/html';\n const EXEC_MIME_TYPE = 'application/vnd.bokehjs_exec.v0+json';\n const CLASS_NAME = 'output_bokeh rendered_html';\n\n /**\n * Render data to the DOM node\n */\n function render(props, node) {\n const script = document.createElement(\"script\");\n node.appendChild(script);\n }\n\n /**\n * Handle when an output is cleared or removed\n */\n function handleClearOutput(event, handle) {\n function drop(id) {\n const view = Bokeh.index.get_by_id(id)\n if (view != null) {\n view.model.document.clear()\n Bokeh.index.delete(view)\n }\n }\n\n const cell = handle.cell;\n\n const id = cell.output_area._bokeh_element_id;\n const server_id = cell.output_area._bokeh_server_id;\n\n // Clean up Bokeh references\n if (id != null) {\n drop(id)\n }\n\n if (server_id !== undefined) {\n // Clean up Bokeh references\n const cmd_clean = \"from bokeh.io.state import curstate; print(curstate().uuid_to_server['\" + server_id + \"'].get_sessions()[0].document.roots[0]._id)\";\n cell.notebook.kernel.execute(cmd_clean, {\n iopub: {\n output: function(msg) {\n const id = msg.content.text.trim()\n drop(id)\n }\n }\n });\n // Destroy server and session\n const cmd_destroy = \"import bokeh.io.notebook as ion; ion.destroy_server('\" + server_id + \"')\";\n cell.notebook.kernel.execute(cmd_destroy);\n }\n }\n\n /**\n * Handle when a new output is added\n */\n function handleAddOutput(event, handle) {\n const output_area = handle.output_area;\n const output = handle.output;\n\n // limit handleAddOutput to display_data with EXEC_MIME_TYPE content only\n if ((output.output_type != \"display_data\") || (!Object.prototype.hasOwnProperty.call(output.data, EXEC_MIME_TYPE))) {\n return\n }\n\n const toinsert = output_area.element.find(\".\" + CLASS_NAME.split(' ')[0]);\n\n if (output.metadata[EXEC_MIME_TYPE][\"id\"] !== undefined) {\n toinsert[toinsert.length - 1].firstChild.textContent = output.data[JS_MIME_TYPE];\n // store reference to embed id on output_area\n output_area._bokeh_element_id = output.metadata[EXEC_MIME_TYPE][\"id\"];\n }\n if (output.metadata[EXEC_MIME_TYPE][\"server_id\"] !== undefined) {\n const bk_div = document.createElement(\"div\");\n bk_div.innerHTML = output.data[HTML_MIME_TYPE];\n const script_attrs = bk_div.children[0].attributes;\n for (let i = 0; i < script_attrs.length; i++) {\n toinsert[toinsert.length - 1].firstChild.setAttribute(script_attrs[i].name, script_attrs[i].value);\n toinsert[toinsert.length - 1].firstChild.textContent = bk_div.children[0].textContent\n }\n // store reference to server id on output_area\n output_area._bokeh_server_id = output.metadata[EXEC_MIME_TYPE][\"server_id\"];\n }\n }\n\n function register_renderer(events, OutputArea) {\n\n function append_mime(data, metadata, element) {\n // create a DOM node to render to\n const toinsert = this.create_output_subarea(\n metadata,\n CLASS_NAME,\n EXEC_MIME_TYPE\n );\n this.keyboard_manager.register_events(toinsert);\n // Render to node\n const props = {data: data, metadata: metadata[EXEC_MIME_TYPE]};\n render(props, toinsert[toinsert.length - 1]);\n element.append(toinsert);\n return toinsert\n }\n\n /* Handle when an output is cleared or removed */\n events.on('clear_output.CodeCell', handleClearOutput);\n events.on('delete.Cell', handleClearOutput);\n\n /* Handle when a new output is added */\n events.on('output_added.OutputArea', handleAddOutput);\n\n /**\n * Register the mime type and append_mime function with output_area\n */\n OutputArea.prototype.register_mime_type(EXEC_MIME_TYPE, append_mime, {\n /* Is output safe? */\n safe: true,\n /* Index of renderer in `output_area.display_order` */\n index: 0\n });\n }\n\n // register the mime type if in Jupyter Notebook environment and previously unregistered\n if (root.Jupyter !== undefined) {\n const events = require('base/js/events');\n const OutputArea = require('notebook/js/outputarea').OutputArea;\n\n if (OutputArea.prototype.mime_types().indexOf(EXEC_MIME_TYPE) == -1) {\n register_renderer(events, OutputArea);\n }\n }\n if (typeof (root._bokeh_timeout) === \"undefined\" || force === true) {\n root._bokeh_timeout = Date.now() + 5000;\n root._bokeh_failed_load = false;\n }\n\n const NB_LOAD_WARNING = {'data': {'text/html':\n \"
\\n\"+\n \"

\\n\"+\n \"BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this \\n\"+\n \"may be due to a slow or bad network connection. Possible fixes:\\n\"+\n \"

\\n\"+\n \"\\n\"+\n \"\\n\"+\n \"from bokeh.resources import INLINE\\n\"+\n \"output_notebook(resources=INLINE)\\n\"+\n \"\\n\"+\n \"
\"}};\n\n function display_loaded(error = null) {\n const el = document.getElementById(null);\n if (el != null) {\n const html = (() => {\n if (typeof root.Bokeh === \"undefined\") {\n if (error == null) {\n return \"BokehJS is loading ...\";\n } else {\n return \"BokehJS failed to load.\";\n }\n } else {\n const prefix = `BokehJS ${root.Bokeh.version}`;\n if (error == null) {\n return `${prefix} successfully loaded.`;\n } else {\n return `${prefix} encountered errors while loading and may not function as expected.`;\n }\n }\n })();\n el.innerHTML = html;\n\n if (error != null) {\n const wrapper = document.createElement(\"div\");\n wrapper.style.overflow = \"auto\";\n wrapper.style.height = \"5em\";\n wrapper.style.resize = \"vertical\";\n const content = document.createElement(\"div\");\n content.style.fontFamily = \"monospace\";\n content.style.whiteSpace = \"pre-wrap\";\n content.style.backgroundColor = \"rgb(255, 221, 221)\";\n content.textContent = error.stack ?? error.toString();\n wrapper.append(content);\n el.append(wrapper);\n }\n } else if (Date.now() < root._bokeh_timeout) {\n setTimeout(() => display_loaded(error), 100);\n }\n }\n\n function run_callbacks() {\n try {\n root._bokeh_onload_callbacks.forEach(function(callback) {\n if (callback != null)\n callback();\n });\n } finally {\n delete root._bokeh_onload_callbacks\n }\n console.debug(\"Bokeh: all callbacks have finished\");\n }\n\n function load_libs(css_urls, js_urls, callback) {\n if (css_urls == null) css_urls = [];\n if (js_urls == null) js_urls = [];\n\n root._bokeh_onload_callbacks.push(callback);\n if (root._bokeh_is_loading > 0) {\n console.debug(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n return null;\n }\n if (js_urls == null || js_urls.length === 0) {\n run_callbacks();\n return null;\n }\n console.debug(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n root._bokeh_is_loading = css_urls.length + js_urls.length;\n\n function on_load() {\n root._bokeh_is_loading--;\n if (root._bokeh_is_loading === 0) {\n console.debug(\"Bokeh: all BokehJS libraries/stylesheets loaded\");\n run_callbacks()\n }\n }\n\n function on_error(url) {\n console.error(\"failed to load \" + url);\n }\n\n for (let i = 0; i < css_urls.length; i++) {\n const url = css_urls[i];\n const element = document.createElement(\"link\");\n element.onload = on_load;\n element.onerror = on_error.bind(null, url);\n element.rel = \"stylesheet\";\n element.type = \"text/css\";\n element.href = url;\n console.debug(\"Bokeh: injecting link tag for BokehJS stylesheet: \", url);\n document.body.appendChild(element);\n }\n\n for (let i = 0; i < js_urls.length; i++) {\n const url = js_urls[i];\n const element = document.createElement('script');\n element.onload = on_load;\n element.onerror = on_error.bind(null, url);\n element.async = false;\n element.src = url;\n console.debug(\"Bokeh: injecting script tag for BokehJS library: \", url);\n document.head.appendChild(element);\n }\n };\n\n function inject_raw_css(css) {\n const element = document.createElement(\"style\");\n element.appendChild(document.createTextNode(css));\n document.body.appendChild(element);\n }\n\n const js_urls = [\"https://cdn.bokeh.org/bokeh/release/bokeh-3.7.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-gl-3.7.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-3.7.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-3.7.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-mathjax-3.7.1.min.js\"];\n const css_urls = [];\n\n const inline_js = [ function(Bokeh) {\n Bokeh.set_log_level(\"info\");\n },\nfunction(Bokeh) {\n }\n ];\n\n function run_inline_js() {\n if (root.Bokeh !== undefined || force === true) {\n try {\n for (let i = 0; i < inline_js.length; i++) {\n inline_js[i].call(root, root.Bokeh);\n }\n\n } catch (error) {throw error;\n }} else if (Date.now() < root._bokeh_timeout) {\n setTimeout(run_inline_js, 100);\n } else if (!root._bokeh_failed_load) {\n console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n root._bokeh_failed_load = true;\n } else if (force !== true) {\n const cell = $(document.getElementById(null)).parents('.cell').data().cell;\n cell.output_area.append_execute_result(NB_LOAD_WARNING)\n }\n }\n\n if (root._bokeh_is_loading === 0) {\n console.debug(\"Bokeh: BokehJS loaded, going straight to plotting\");\n run_inline_js();\n } else {\n load_libs(css_urls, js_urls, function() {\n console.debug(\"Bokeh: BokehJS plotting callback run at\", now());\n run_inline_js();\n });\n }\n}(window));", "application/vnd.bokehjs_load.v0+json": "" }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "\n", "
\n" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/javascript": "(function(root) {\n function embed_document(root) {\n const docs_json = {\"a8d83d10-83ae-4b2c-bf9d-46596104d409\":{\"version\":\"3.7.1\",\"title\":\"Bokeh Application\",\"roots\":[{\"type\":\"object\",\"name\":\"Figure\",\"id\":\"p1926\",\"attributes\":{\"width\":400,\"height\":400,\"x_range\":{\"type\":\"object\",\"name\":\"DataRange1d\",\"id\":\"p1927\"},\"y_range\":{\"type\":\"object\",\"name\":\"DataRange1d\",\"id\":\"p1928\"},\"x_scale\":{\"type\":\"object\",\"name\":\"LinearScale\",\"id\":\"p1935\"},\"y_scale\":{\"type\":\"object\",\"name\":\"LinearScale\",\"id\":\"p1936\"},\"title\":{\"type\":\"object\",\"name\":\"Title\",\"id\":\"p1933\"},\"renderers\":[{\"type\":\"object\",\"name\":\"GraphRenderer\",\"id\":\"p1958\",\"attributes\":{\"layout_provider\":{\"type\":\"object\",\"name\":\"StaticLayoutProvider\",\"id\":\"p1975\",\"attributes\":{\"graph_layout\":{\"type\":\"map\",\"entries\":[[3,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"////////77+Ey13GZtS7Pw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[4,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"tnuk2YOw1D98tbySTWmgvw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[5,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"p5y+Y+To2z+OVLYw6j7GPw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[1,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"Q885hS/Nzj93BpsXZQfQvw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}]]}}},\"node_renderer\":{\"type\":\"object\",\"name\":\"GlyphRenderer\",\"id\":\"p1963\",\"attributes\":{\"data_source\":{\"type\":\"object\",\"name\":\"ColumnDataSource\",\"id\":\"p1960\",\"attributes\":{\"selected\":{\"type\":\"object\",\"name\":\"Selection\",\"id\":\"p1961\",\"attributes\":{\"indices\":[],\"line_indices\":[]}},\"selection_policy\":{\"type\":\"object\",\"name\":\"UnionRenderers\",\"id\":\"p1962\"},\"data\":{\"type\":\"map\",\"entries\":[[\"type\",[\"Agent\",\"Agent\",\"Agent\",\"Agent\"]],[\"index\",[3,4,5,1]],[\"_marker\",[\"circle\",\"circle\",\"circle\",\"circle\"]],[\"_color\",[\"firebrick\",\"firebrick\",\"firebrick\",\"firebrick\"]],[\"_alpha\",[0.5,0.5,0.5,0.5]],[\"_size\",[10,10,10,10]],[\"start_display\",[\"none\",\"none\",\"none\",\"none\"]],[\"end_display\",[\"none\",\"none\",\"none\",\"none\"]],[\"weight_display\",[\"none\",\"none\",\"none\",\"none\"]],[\"index_display\",[1,1,1,1]],[\"type_display\",[1,1,1,1]]]}}},\"view\":{\"type\":\"object\",\"name\":\"CDSView\",\"id\":\"p1964\",\"attributes\":{\"filter\":{\"type\":\"object\",\"name\":\"AllIndices\",\"id\":\"p1965\"}}},\"glyph\":{\"type\":\"object\",\"name\":\"Scatter\",\"id\":\"p1977\",\"attributes\":{\"size\":{\"type\":\"field\",\"field\":\"_size\"},\"line_color\":{\"type\":\"field\",\"field\":\"_color\"},\"line_alpha\":{\"type\":\"field\",\"field\":\"_alpha\"},\"fill_color\":{\"type\":\"field\",\"field\":\"_color\"},\"fill_alpha\":{\"type\":\"field\",\"field\":\"_alpha\"},\"marker\":{\"type\":\"field\",\"field\":\"_marker\"}}}}},\"edge_renderer\":{\"type\":\"object\",\"name\":\"GlyphRenderer\",\"id\":\"p1970\",\"attributes\":{\"data_source\":{\"type\":\"object\",\"name\":\"ColumnDataSource\",\"id\":\"p1967\",\"attributes\":{\"selected\":{\"type\":\"object\",\"name\":\"Selection\",\"id\":\"p1968\",\"attributes\":{\"indices\":[],\"line_indices\":[]}},\"selection_policy\":{\"type\":\"object\",\"name\":\"UnionRenderers\",\"id\":\"p1969\"},\"data\":{\"type\":\"map\",\"entries\":[[\"weight\",[1,1]],[\"start\",[4,4]],[\"end\",[1,5]],[\"_color\",[\"#440154\",\"#440154\"]],[\"_alpha\",[1.0,1.0]],[\"_size\",[1.0,1.0]],[\"start_display\",[1,1]],[\"end_display\",[1,1]],[\"weight_display\",[1,1]],[\"index_display\",[\"none\",\"none\"]],[\"type_display\",[\"none\",\"none\"]]]}}},\"view\":{\"type\":\"object\",\"name\":\"CDSView\",\"id\":\"p1971\",\"attributes\":{\"filter\":{\"type\":\"object\",\"name\":\"AllIndices\",\"id\":\"p1972\"}}},\"glyph\":{\"type\":\"object\",\"name\":\"MultiLine\",\"id\":\"p1976\",\"attributes\":{\"line_color\":{\"type\":\"field\",\"field\":\"_color\"},\"line_alpha\":{\"type\":\"field\",\"field\":\"_alpha\"},\"line_width\":{\"type\":\"field\",\"field\":\"_size\"}}}}},\"selection_policy\":{\"type\":\"object\",\"name\":\"NodesOnly\",\"id\":\"p1973\"},\"inspection_policy\":{\"type\":\"object\",\"name\":\"NodesOnly\",\"id\":\"p1974\"}}}],\"toolbar\":{\"type\":\"object\",\"name\":\"Toolbar\",\"id\":\"p1934\",\"attributes\":{\"tools\":[{\"type\":\"object\",\"name\":\"BoxZoomTool\",\"id\":\"p1947\",\"attributes\":{\"dimensions\":\"both\",\"overlay\":{\"type\":\"object\",\"name\":\"BoxAnnotation\",\"id\":\"p1948\",\"attributes\":{\"syncable\":false,\"line_color\":\"black\",\"line_alpha\":1.0,\"line_width\":2,\"line_dash\":[4,4],\"fill_color\":\"lightgrey\",\"fill_alpha\":0.5,\"level\":\"overlay\",\"visible\":false,\"left\":{\"type\":\"number\",\"value\":\"nan\"},\"right\":{\"type\":\"number\",\"value\":\"nan\"},\"top\":{\"type\":\"number\",\"value\":\"nan\"},\"bottom\":{\"type\":\"number\",\"value\":\"nan\"},\"left_units\":\"canvas\",\"right_units\":\"canvas\",\"top_units\":\"canvas\",\"bottom_units\":\"canvas\",\"handles\":{\"type\":\"object\",\"name\":\"BoxInteractionHandles\",\"id\":\"p1954\",\"attributes\":{\"all\":{\"type\":\"object\",\"name\":\"AreaVisuals\",\"id\":\"p1953\",\"attributes\":{\"fill_color\":\"white\",\"hover_fill_color\":\"lightgray\"}}}}}}}},{\"type\":\"object\",\"name\":\"ResetTool\",\"id\":\"p1955\"},{\"type\":\"object\",\"name\":\"WheelZoomTool\",\"id\":\"p1956\",\"attributes\":{\"renderers\":\"auto\"}},{\"type\":\"object\",\"name\":\"PanTool\",\"id\":\"p1957\"},{\"type\":\"object\",\"name\":\"HoverTool\",\"id\":\"p1978\",\"attributes\":{\"renderers\":[{\"id\":\"p1970\"},{\"id\":\"p1963\"}],\"tooltips\":\"
\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n
start:@start
end:@end
weight:@weight
index:@index
type:@type
\",\"line_policy\":\"interp\"}}],\"logo\":null}},\"left\":[{\"type\":\"object\",\"name\":\"LinearAxis\",\"id\":\"p1942\",\"attributes\":{\"visible\":false,\"ticker\":{\"type\":\"object\",\"name\":\"BasicTicker\",\"id\":\"p1943\",\"attributes\":{\"mantissas\":[1,2,5]}},\"formatter\":{\"type\":\"object\",\"name\":\"BasicTickFormatter\",\"id\":\"p1944\"},\"major_label_policy\":{\"type\":\"object\",\"name\":\"AllLabels\",\"id\":\"p1945\"}}}],\"below\":[{\"type\":\"object\",\"name\":\"LinearAxis\",\"id\":\"p1937\",\"attributes\":{\"visible\":false,\"ticker\":{\"type\":\"object\",\"name\":\"BasicTicker\",\"id\":\"p1938\",\"attributes\":{\"mantissas\":[1,2,5]}},\"formatter\":{\"type\":\"object\",\"name\":\"BasicTickFormatter\",\"id\":\"p1939\"},\"major_label_policy\":{\"type\":\"object\",\"name\":\"AllLabels\",\"id\":\"p1940\"}}}],\"center\":[{\"type\":\"object\",\"name\":\"Grid\",\"id\":\"p1941\",\"attributes\":{\"axis\":{\"id\":\"p1937\"},\"grid_line_color\":null}},{\"type\":\"object\",\"name\":\"Grid\",\"id\":\"p1946\",\"attributes\":{\"dimension\":1,\"axis\":{\"id\":\"p1942\"},\"grid_line_color\":null}}]}}]}};\n const render_items = [{\"docid\":\"a8d83d10-83ae-4b2c-bf9d-46596104d409\",\"roots\":{\"p1926\":\"f1afc7a3-c2cb-49be-93bd-edec8ef66627\"},\"root_ids\":[\"p1926\"],\"notebook_comms_target\":\"p1979\"}];\n void root.Bokeh.embed.embed_items_notebook(docs_json, render_items);\n }\n if (root.Bokeh !== undefined) {\n embed_document(root);\n } else {\n let attempts = 0;\n const timer = setInterval(function(root) {\n if (root.Bokeh !== undefined) {\n clearInterval(timer);\n embed_document(root);\n } else {\n attempts++;\n if (attempts > 100) {\n clearInterval(timer);\n console.log(\"Bokeh: ERROR: Unable to run BokehJS code because BokehJS library is missing\");\n }\n }\n }, 10, root)\n }\n})(window);", "application/vnd.bokehjs_exec.v0+json": "" }, "metadata": { "application/vnd.bokehjs_exec.v0+json": { "id": "p1926" } }, "output_type": "display_data" } ], "source": [ "inspector.plot_networks()" ] }, { "cell_type": "markdown", "id": "54edde75", "metadata": {}, "source": [ "Let's connect those two agents also via the location type `School`:" ] }, { "cell_type": "code", "execution_count": 40, "id": "9052f25b", "metadata": {}, "outputs": [], "source": [ "agent.connect(agent=model.agents[1], location_cls=School)" ] }, { "cell_type": "code", "execution_count": 41, "id": "9cb23096", "metadata": {}, "outputs": [ { "data": { "application/javascript": "'use strict';\n(function(root) {\n function now() {\n return new Date();\n }\n\n const force = true;\n\n if (typeof root._bokeh_onload_callbacks === \"undefined\" || force === true) {\n root._bokeh_onload_callbacks = [];\n root._bokeh_is_loading = undefined;\n }\n\nconst JS_MIME_TYPE = 'application/javascript';\n const HTML_MIME_TYPE = 'text/html';\n const EXEC_MIME_TYPE = 'application/vnd.bokehjs_exec.v0+json';\n const CLASS_NAME = 'output_bokeh rendered_html';\n\n /**\n * Render data to the DOM node\n */\n function render(props, node) {\n const script = document.createElement(\"script\");\n node.appendChild(script);\n }\n\n /**\n * Handle when an output is cleared or removed\n */\n function handleClearOutput(event, handle) {\n function drop(id) {\n const view = Bokeh.index.get_by_id(id)\n if (view != null) {\n view.model.document.clear()\n Bokeh.index.delete(view)\n }\n }\n\n const cell = handle.cell;\n\n const id = cell.output_area._bokeh_element_id;\n const server_id = cell.output_area._bokeh_server_id;\n\n // Clean up Bokeh references\n if (id != null) {\n drop(id)\n }\n\n if (server_id !== undefined) {\n // Clean up Bokeh references\n const cmd_clean = \"from bokeh.io.state import curstate; print(curstate().uuid_to_server['\" + server_id + \"'].get_sessions()[0].document.roots[0]._id)\";\n cell.notebook.kernel.execute(cmd_clean, {\n iopub: {\n output: function(msg) {\n const id = msg.content.text.trim()\n drop(id)\n }\n }\n });\n // Destroy server and session\n const cmd_destroy = \"import bokeh.io.notebook as ion; ion.destroy_server('\" + server_id + \"')\";\n cell.notebook.kernel.execute(cmd_destroy);\n }\n }\n\n /**\n * Handle when a new output is added\n */\n function handleAddOutput(event, handle) {\n const output_area = handle.output_area;\n const output = handle.output;\n\n // limit handleAddOutput to display_data with EXEC_MIME_TYPE content only\n if ((output.output_type != \"display_data\") || (!Object.prototype.hasOwnProperty.call(output.data, EXEC_MIME_TYPE))) {\n return\n }\n\n const toinsert = output_area.element.find(\".\" + CLASS_NAME.split(' ')[0]);\n\n if (output.metadata[EXEC_MIME_TYPE][\"id\"] !== undefined) {\n toinsert[toinsert.length - 1].firstChild.textContent = output.data[JS_MIME_TYPE];\n // store reference to embed id on output_area\n output_area._bokeh_element_id = output.metadata[EXEC_MIME_TYPE][\"id\"];\n }\n if (output.metadata[EXEC_MIME_TYPE][\"server_id\"] !== undefined) {\n const bk_div = document.createElement(\"div\");\n bk_div.innerHTML = output.data[HTML_MIME_TYPE];\n const script_attrs = bk_div.children[0].attributes;\n for (let i = 0; i < script_attrs.length; i++) {\n toinsert[toinsert.length - 1].firstChild.setAttribute(script_attrs[i].name, script_attrs[i].value);\n toinsert[toinsert.length - 1].firstChild.textContent = bk_div.children[0].textContent\n }\n // store reference to server id on output_area\n output_area._bokeh_server_id = output.metadata[EXEC_MIME_TYPE][\"server_id\"];\n }\n }\n\n function register_renderer(events, OutputArea) {\n\n function append_mime(data, metadata, element) {\n // create a DOM node to render to\n const toinsert = this.create_output_subarea(\n metadata,\n CLASS_NAME,\n EXEC_MIME_TYPE\n );\n this.keyboard_manager.register_events(toinsert);\n // Render to node\n const props = {data: data, metadata: metadata[EXEC_MIME_TYPE]};\n render(props, toinsert[toinsert.length - 1]);\n element.append(toinsert);\n return toinsert\n }\n\n /* Handle when an output is cleared or removed */\n events.on('clear_output.CodeCell', handleClearOutput);\n events.on('delete.Cell', handleClearOutput);\n\n /* Handle when a new output is added */\n events.on('output_added.OutputArea', handleAddOutput);\n\n /**\n * Register the mime type and append_mime function with output_area\n */\n OutputArea.prototype.register_mime_type(EXEC_MIME_TYPE, append_mime, {\n /* Is output safe? */\n safe: true,\n /* Index of renderer in `output_area.display_order` */\n index: 0\n });\n }\n\n // register the mime type if in Jupyter Notebook environment and previously unregistered\n if (root.Jupyter !== undefined) {\n const events = require('base/js/events');\n const OutputArea = require('notebook/js/outputarea').OutputArea;\n\n if (OutputArea.prototype.mime_types().indexOf(EXEC_MIME_TYPE) == -1) {\n register_renderer(events, OutputArea);\n }\n }\n if (typeof (root._bokeh_timeout) === \"undefined\" || force === true) {\n root._bokeh_timeout = Date.now() + 5000;\n root._bokeh_failed_load = false;\n }\n\n const NB_LOAD_WARNING = {'data': {'text/html':\n \"
\\n\"+\n \"

\\n\"+\n \"BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this \\n\"+\n \"may be due to a slow or bad network connection. Possible fixes:\\n\"+\n \"

\\n\"+\n \"\\n\"+\n \"\\n\"+\n \"from bokeh.resources import INLINE\\n\"+\n \"output_notebook(resources=INLINE)\\n\"+\n \"\\n\"+\n \"
\"}};\n\n function display_loaded(error = null) {\n const el = document.getElementById(null);\n if (el != null) {\n const html = (() => {\n if (typeof root.Bokeh === \"undefined\") {\n if (error == null) {\n return \"BokehJS is loading ...\";\n } else {\n return \"BokehJS failed to load.\";\n }\n } else {\n const prefix = `BokehJS ${root.Bokeh.version}`;\n if (error == null) {\n return `${prefix} successfully loaded.`;\n } else {\n return `${prefix} encountered errors while loading and may not function as expected.`;\n }\n }\n })();\n el.innerHTML = html;\n\n if (error != null) {\n const wrapper = document.createElement(\"div\");\n wrapper.style.overflow = \"auto\";\n wrapper.style.height = \"5em\";\n wrapper.style.resize = \"vertical\";\n const content = document.createElement(\"div\");\n content.style.fontFamily = \"monospace\";\n content.style.whiteSpace = \"pre-wrap\";\n content.style.backgroundColor = \"rgb(255, 221, 221)\";\n content.textContent = error.stack ?? error.toString();\n wrapper.append(content);\n el.append(wrapper);\n }\n } else if (Date.now() < root._bokeh_timeout) {\n setTimeout(() => display_loaded(error), 100);\n }\n }\n\n function run_callbacks() {\n try {\n root._bokeh_onload_callbacks.forEach(function(callback) {\n if (callback != null)\n callback();\n });\n } finally {\n delete root._bokeh_onload_callbacks\n }\n console.debug(\"Bokeh: all callbacks have finished\");\n }\n\n function load_libs(css_urls, js_urls, callback) {\n if (css_urls == null) css_urls = [];\n if (js_urls == null) js_urls = [];\n\n root._bokeh_onload_callbacks.push(callback);\n if (root._bokeh_is_loading > 0) {\n console.debug(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n return null;\n }\n if (js_urls == null || js_urls.length === 0) {\n run_callbacks();\n return null;\n }\n console.debug(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n root._bokeh_is_loading = css_urls.length + js_urls.length;\n\n function on_load() {\n root._bokeh_is_loading--;\n if (root._bokeh_is_loading === 0) {\n console.debug(\"Bokeh: all BokehJS libraries/stylesheets loaded\");\n run_callbacks()\n }\n }\n\n function on_error(url) {\n console.error(\"failed to load \" + url);\n }\n\n for (let i = 0; i < css_urls.length; i++) {\n const url = css_urls[i];\n const element = document.createElement(\"link\");\n element.onload = on_load;\n element.onerror = on_error.bind(null, url);\n element.rel = \"stylesheet\";\n element.type = \"text/css\";\n element.href = url;\n console.debug(\"Bokeh: injecting link tag for BokehJS stylesheet: \", url);\n document.body.appendChild(element);\n }\n\n for (let i = 0; i < js_urls.length; i++) {\n const url = js_urls[i];\n const element = document.createElement('script');\n element.onload = on_load;\n element.onerror = on_error.bind(null, url);\n element.async = false;\n element.src = url;\n console.debug(\"Bokeh: injecting script tag for BokehJS library: \", url);\n document.head.appendChild(element);\n }\n };\n\n function inject_raw_css(css) {\n const element = document.createElement(\"style\");\n element.appendChild(document.createTextNode(css));\n document.body.appendChild(element);\n }\n\n const js_urls = [\"https://cdn.bokeh.org/bokeh/release/bokeh-3.7.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-gl-3.7.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-3.7.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-3.7.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-mathjax-3.7.1.min.js\"];\n const css_urls = [];\n\n const inline_js = [ function(Bokeh) {\n Bokeh.set_log_level(\"info\");\n },\nfunction(Bokeh) {\n }\n ];\n\n function run_inline_js() {\n if (root.Bokeh !== undefined || force === true) {\n try {\n for (let i = 0; i < inline_js.length; i++) {\n inline_js[i].call(root, root.Bokeh);\n }\n\n } catch (error) {throw error;\n }} else if (Date.now() < root._bokeh_timeout) {\n setTimeout(run_inline_js, 100);\n } else if (!root._bokeh_failed_load) {\n console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n root._bokeh_failed_load = true;\n } else if (force !== true) {\n const cell = $(document.getElementById(null)).parents('.cell').data().cell;\n cell.output_area.append_execute_result(NB_LOAD_WARNING)\n }\n }\n\n if (root._bokeh_is_loading === 0) {\n console.debug(\"Bokeh: BokehJS loaded, going straight to plotting\");\n run_inline_js();\n } else {\n load_libs(css_urls, js_urls, function() {\n console.debug(\"Bokeh: BokehJS plotting callback run at\", now());\n run_inline_js();\n });\n }\n}(window));", "application/vnd.bokehjs_load.v0+json": "" }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "\n", "
\n" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/javascript": "(function(root) {\n function embed_document(root) {\n const docs_json = {\"a4033673-bd9f-41d9-a5f4-3875fb3db823\":{\"version\":\"3.7.1\",\"title\":\"Bokeh Application\",\"roots\":[{\"type\":\"object\",\"name\":\"Figure\",\"id\":\"p1984\",\"attributes\":{\"width\":400,\"height\":400,\"x_range\":{\"type\":\"object\",\"name\":\"DataRange1d\",\"id\":\"p1985\"},\"y_range\":{\"type\":\"object\",\"name\":\"DataRange1d\",\"id\":\"p1986\"},\"x_scale\":{\"type\":\"object\",\"name\":\"LinearScale\",\"id\":\"p1993\"},\"y_scale\":{\"type\":\"object\",\"name\":\"LinearScale\",\"id\":\"p1994\"},\"title\":{\"type\":\"object\",\"name\":\"Title\",\"id\":\"p1991\"},\"renderers\":[{\"type\":\"object\",\"name\":\"GraphRenderer\",\"id\":\"p2016\",\"attributes\":{\"layout_provider\":{\"type\":\"object\",\"name\":\"StaticLayoutProvider\",\"id\":\"p2033\",\"attributes\":{\"graph_layout\":{\"type\":\"map\",\"entries\":[[2,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"RqAHsJBn1b8AAAAAAADwvw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[3,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"7ZsbmQ2U0L9CtGvYqybrvw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[4,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"KXmP9dP3tj9dJJzZprHSPw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[5,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"jb68GNcs3j/jpXl+xFWOPw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[6,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"dx7yDbej0j9WBjczKY3APw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[1,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"UDvsNJp8xL+kkwSnm4ThPw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[7,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"2fEgK55fv79stoIM9xvXPw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[8,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"S7DtpPw0mD8RC5Dfnx7gPw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}]]}}},\"node_renderer\":{\"type\":\"object\",\"name\":\"GlyphRenderer\",\"id\":\"p2021\",\"attributes\":{\"data_source\":{\"type\":\"object\",\"name\":\"ColumnDataSource\",\"id\":\"p2018\",\"attributes\":{\"selected\":{\"type\":\"object\",\"name\":\"Selection\",\"id\":\"p2019\",\"attributes\":{\"indices\":[],\"line_indices\":[]}},\"selection_policy\":{\"type\":\"object\",\"name\":\"UnionRenderers\",\"id\":\"p2020\"},\"data\":{\"type\":\"map\",\"entries\":[[\"type\",[\"Location\",\"Agent\",\"Agent\",\"Agent\",\"School\",\"Agent\",\"Location\",\"School\"]],[\"label\",[\"Location\",null,null,null,\"School\",null,\"Location\",\"School\"]],[\"bipartite\",[1,0,0,0,1,0,1,1]],[\"index\",[2,3,4,5,6,1,7,8]],[\"_marker\",[\"square\",\"circle\",\"circle\",\"circle\",\"square\",\"circle\",\"square\",\"square\"]],[\"_color\",[\"steelblue\",\"firebrick\",\"firebrick\",\"firebrick\",\"steelblue\",\"firebrick\",\"steelblue\",\"steelblue\"]],[\"_alpha\",[0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5]],[\"_size\",[10,10,10,10,10,10,10,10]],[\"start_display\",[\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\"]],[\"end_display\",[\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\"]],[\"weight_display\",[\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\"]],[\"index_display\",[1,1,1,1,1,1,1,1]],[\"type_display\",[1,1,1,1,1,1,1,1]],[\"label_display\",[1,\"none\",\"none\",\"none\",1,\"none\",1,1]]]}}},\"view\":{\"type\":\"object\",\"name\":\"CDSView\",\"id\":\"p2022\",\"attributes\":{\"filter\":{\"type\":\"object\",\"name\":\"AllIndices\",\"id\":\"p2023\"}}},\"glyph\":{\"type\":\"object\",\"name\":\"Scatter\",\"id\":\"p2035\",\"attributes\":{\"size\":{\"type\":\"field\",\"field\":\"_size\"},\"line_color\":{\"type\":\"field\",\"field\":\"_color\"},\"line_alpha\":{\"type\":\"field\",\"field\":\"_alpha\"},\"fill_color\":{\"type\":\"field\",\"field\":\"_color\"},\"fill_alpha\":{\"type\":\"field\",\"field\":\"_alpha\"},\"marker\":{\"type\":\"field\",\"field\":\"_marker\"}}}}},\"edge_renderer\":{\"type\":\"object\",\"name\":\"GlyphRenderer\",\"id\":\"p2028\",\"attributes\":{\"data_source\":{\"type\":\"object\",\"name\":\"ColumnDataSource\",\"id\":\"p2025\",\"attributes\":{\"selected\":{\"type\":\"object\",\"name\":\"Selection\",\"id\":\"p2026\",\"attributes\":{\"indices\":[],\"line_indices\":[]}},\"selection_policy\":{\"type\":\"object\",\"name\":\"UnionRenderers\",\"id\":\"p2027\"},\"data\":{\"type\":\"map\",\"entries\":[[\"weight\",[1,1,1,1,1,1,1]],[\"start\",[2,4,4,4,5,1,1]],[\"end\",[3,6,7,8,6,7,8]],[\"_color\",[\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\"]],[\"_alpha\",[1.0,1.0,1.0,1.0,1.0,1.0,1.0]],[\"_size\",[1.0,1.0,1.0,1.0,1.0,1.0,1.0]],[\"start_display\",[1,1,1,1,1,1,1]],[\"end_display\",[1,1,1,1,1,1,1]],[\"weight_display\",[1,1,1,1,1,1,1]],[\"index_display\",[\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\"]],[\"type_display\",[\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\"]],[\"label_display\",[\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\"]]]}}},\"view\":{\"type\":\"object\",\"name\":\"CDSView\",\"id\":\"p2029\",\"attributes\":{\"filter\":{\"type\":\"object\",\"name\":\"AllIndices\",\"id\":\"p2030\"}}},\"glyph\":{\"type\":\"object\",\"name\":\"MultiLine\",\"id\":\"p2034\",\"attributes\":{\"line_color\":{\"type\":\"field\",\"field\":\"_color\"},\"line_alpha\":{\"type\":\"field\",\"field\":\"_alpha\"},\"line_width\":{\"type\":\"field\",\"field\":\"_size\"}}}}},\"selection_policy\":{\"type\":\"object\",\"name\":\"NodesOnly\",\"id\":\"p2031\"},\"inspection_policy\":{\"type\":\"object\",\"name\":\"NodesOnly\",\"id\":\"p2032\"}}}],\"toolbar\":{\"type\":\"object\",\"name\":\"Toolbar\",\"id\":\"p1992\",\"attributes\":{\"tools\":[{\"type\":\"object\",\"name\":\"BoxZoomTool\",\"id\":\"p2005\",\"attributes\":{\"dimensions\":\"both\",\"overlay\":{\"type\":\"object\",\"name\":\"BoxAnnotation\",\"id\":\"p2006\",\"attributes\":{\"syncable\":false,\"line_color\":\"black\",\"line_alpha\":1.0,\"line_width\":2,\"line_dash\":[4,4],\"fill_color\":\"lightgrey\",\"fill_alpha\":0.5,\"level\":\"overlay\",\"visible\":false,\"left\":{\"type\":\"number\",\"value\":\"nan\"},\"right\":{\"type\":\"number\",\"value\":\"nan\"},\"top\":{\"type\":\"number\",\"value\":\"nan\"},\"bottom\":{\"type\":\"number\",\"value\":\"nan\"},\"left_units\":\"canvas\",\"right_units\":\"canvas\",\"top_units\":\"canvas\",\"bottom_units\":\"canvas\",\"handles\":{\"type\":\"object\",\"name\":\"BoxInteractionHandles\",\"id\":\"p2012\",\"attributes\":{\"all\":{\"type\":\"object\",\"name\":\"AreaVisuals\",\"id\":\"p2011\",\"attributes\":{\"fill_color\":\"white\",\"hover_fill_color\":\"lightgray\"}}}}}}}},{\"type\":\"object\",\"name\":\"ResetTool\",\"id\":\"p2013\"},{\"type\":\"object\",\"name\":\"WheelZoomTool\",\"id\":\"p2014\",\"attributes\":{\"renderers\":\"auto\"}},{\"type\":\"object\",\"name\":\"PanTool\",\"id\":\"p2015\"},{\"type\":\"object\",\"name\":\"HoverTool\",\"id\":\"p2036\",\"attributes\":{\"renderers\":[{\"id\":\"p2028\"},{\"id\":\"p2021\"}],\"tooltips\":\"
\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n
start:@start
end:@end
weight:@weight
index:@index
type:@type
label:@label
\",\"line_policy\":\"interp\"}}],\"logo\":null}},\"left\":[{\"type\":\"object\",\"name\":\"LinearAxis\",\"id\":\"p2000\",\"attributes\":{\"visible\":false,\"ticker\":{\"type\":\"object\",\"name\":\"BasicTicker\",\"id\":\"p2001\",\"attributes\":{\"mantissas\":[1,2,5]}},\"formatter\":{\"type\":\"object\",\"name\":\"BasicTickFormatter\",\"id\":\"p2002\"},\"major_label_policy\":{\"type\":\"object\",\"name\":\"AllLabels\",\"id\":\"p2003\"}}}],\"below\":[{\"type\":\"object\",\"name\":\"LinearAxis\",\"id\":\"p1995\",\"attributes\":{\"visible\":false,\"ticker\":{\"type\":\"object\",\"name\":\"BasicTicker\",\"id\":\"p1996\",\"attributes\":{\"mantissas\":[1,2,5]}},\"formatter\":{\"type\":\"object\",\"name\":\"BasicTickFormatter\",\"id\":\"p1997\"},\"major_label_policy\":{\"type\":\"object\",\"name\":\"AllLabels\",\"id\":\"p1998\"}}}],\"center\":[{\"type\":\"object\",\"name\":\"Grid\",\"id\":\"p1999\",\"attributes\":{\"axis\":{\"id\":\"p1995\"},\"grid_line_color\":null}},{\"type\":\"object\",\"name\":\"Grid\",\"id\":\"p2004\",\"attributes\":{\"dimension\":1,\"axis\":{\"id\":\"p2000\"},\"grid_line_color\":null}}]}}]}};\n const render_items = [{\"docid\":\"a4033673-bd9f-41d9-a5f4-3875fb3db823\",\"roots\":{\"p1984\":\"feb7a879-b4d1-400d-aa9c-3dcf72579a0b\"},\"root_ids\":[\"p1984\"],\"notebook_comms_target\":\"p2037\"}];\n void root.Bokeh.embed.embed_items_notebook(docs_json, render_items);\n }\n if (root.Bokeh !== undefined) {\n embed_document(root);\n } else {\n let attempts = 0;\n const timer = setInterval(function(root) {\n if (root.Bokeh !== undefined) {\n clearInterval(timer);\n embed_document(root);\n } else {\n attempts++;\n if (attempts > 100) {\n clearInterval(timer);\n console.log(\"Bokeh: ERROR: Unable to run BokehJS code because BokehJS library is missing\");\n }\n }\n }, 10, root)\n }\n})(window);", "application/vnd.bokehjs_exec.v0+json": "" }, "metadata": { "application/vnd.bokehjs_exec.v0+json": { "id": "p1984" } }, "output_type": "display_data" }, { "data": { "application/javascript": "'use strict';\n(function(root) {\n function now() {\n return new Date();\n }\n\n const force = true;\n\n if (typeof root._bokeh_onload_callbacks === \"undefined\" || force === true) {\n root._bokeh_onload_callbacks = [];\n root._bokeh_is_loading = undefined;\n }\n\nconst JS_MIME_TYPE = 'application/javascript';\n const HTML_MIME_TYPE = 'text/html';\n const EXEC_MIME_TYPE = 'application/vnd.bokehjs_exec.v0+json';\n const CLASS_NAME = 'output_bokeh rendered_html';\n\n /**\n * Render data to the DOM node\n */\n function render(props, node) {\n const script = document.createElement(\"script\");\n node.appendChild(script);\n }\n\n /**\n * Handle when an output is cleared or removed\n */\n function handleClearOutput(event, handle) {\n function drop(id) {\n const view = Bokeh.index.get_by_id(id)\n if (view != null) {\n view.model.document.clear()\n Bokeh.index.delete(view)\n }\n }\n\n const cell = handle.cell;\n\n const id = cell.output_area._bokeh_element_id;\n const server_id = cell.output_area._bokeh_server_id;\n\n // Clean up Bokeh references\n if (id != null) {\n drop(id)\n }\n\n if (server_id !== undefined) {\n // Clean up Bokeh references\n const cmd_clean = \"from bokeh.io.state import curstate; print(curstate().uuid_to_server['\" + server_id + \"'].get_sessions()[0].document.roots[0]._id)\";\n cell.notebook.kernel.execute(cmd_clean, {\n iopub: {\n output: function(msg) {\n const id = msg.content.text.trim()\n drop(id)\n }\n }\n });\n // Destroy server and session\n const cmd_destroy = \"import bokeh.io.notebook as ion; ion.destroy_server('\" + server_id + \"')\";\n cell.notebook.kernel.execute(cmd_destroy);\n }\n }\n\n /**\n * Handle when a new output is added\n */\n function handleAddOutput(event, handle) {\n const output_area = handle.output_area;\n const output = handle.output;\n\n // limit handleAddOutput to display_data with EXEC_MIME_TYPE content only\n if ((output.output_type != \"display_data\") || (!Object.prototype.hasOwnProperty.call(output.data, EXEC_MIME_TYPE))) {\n return\n }\n\n const toinsert = output_area.element.find(\".\" + CLASS_NAME.split(' ')[0]);\n\n if (output.metadata[EXEC_MIME_TYPE][\"id\"] !== undefined) {\n toinsert[toinsert.length - 1].firstChild.textContent = output.data[JS_MIME_TYPE];\n // store reference to embed id on output_area\n output_area._bokeh_element_id = output.metadata[EXEC_MIME_TYPE][\"id\"];\n }\n if (output.metadata[EXEC_MIME_TYPE][\"server_id\"] !== undefined) {\n const bk_div = document.createElement(\"div\");\n bk_div.innerHTML = output.data[HTML_MIME_TYPE];\n const script_attrs = bk_div.children[0].attributes;\n for (let i = 0; i < script_attrs.length; i++) {\n toinsert[toinsert.length - 1].firstChild.setAttribute(script_attrs[i].name, script_attrs[i].value);\n toinsert[toinsert.length - 1].firstChild.textContent = bk_div.children[0].textContent\n }\n // store reference to server id on output_area\n output_area._bokeh_server_id = output.metadata[EXEC_MIME_TYPE][\"server_id\"];\n }\n }\n\n function register_renderer(events, OutputArea) {\n\n function append_mime(data, metadata, element) {\n // create a DOM node to render to\n const toinsert = this.create_output_subarea(\n metadata,\n CLASS_NAME,\n EXEC_MIME_TYPE\n );\n this.keyboard_manager.register_events(toinsert);\n // Render to node\n const props = {data: data, metadata: metadata[EXEC_MIME_TYPE]};\n render(props, toinsert[toinsert.length - 1]);\n element.append(toinsert);\n return toinsert\n }\n\n /* Handle when an output is cleared or removed */\n events.on('clear_output.CodeCell', handleClearOutput);\n events.on('delete.Cell', handleClearOutput);\n\n /* Handle when a new output is added */\n events.on('output_added.OutputArea', handleAddOutput);\n\n /**\n * Register the mime type and append_mime function with output_area\n */\n OutputArea.prototype.register_mime_type(EXEC_MIME_TYPE, append_mime, {\n /* Is output safe? */\n safe: true,\n /* Index of renderer in `output_area.display_order` */\n index: 0\n });\n }\n\n // register the mime type if in Jupyter Notebook environment and previously unregistered\n if (root.Jupyter !== undefined) {\n const events = require('base/js/events');\n const OutputArea = require('notebook/js/outputarea').OutputArea;\n\n if (OutputArea.prototype.mime_types().indexOf(EXEC_MIME_TYPE) == -1) {\n register_renderer(events, OutputArea);\n }\n }\n if (typeof (root._bokeh_timeout) === \"undefined\" || force === true) {\n root._bokeh_timeout = Date.now() + 5000;\n root._bokeh_failed_load = false;\n }\n\n const NB_LOAD_WARNING = {'data': {'text/html':\n \"
\\n\"+\n \"

\\n\"+\n \"BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this \\n\"+\n \"may be due to a slow or bad network connection. Possible fixes:\\n\"+\n \"

\\n\"+\n \"\\n\"+\n \"\\n\"+\n \"from bokeh.resources import INLINE\\n\"+\n \"output_notebook(resources=INLINE)\\n\"+\n \"\\n\"+\n \"
\"}};\n\n function display_loaded(error = null) {\n const el = document.getElementById(null);\n if (el != null) {\n const html = (() => {\n if (typeof root.Bokeh === \"undefined\") {\n if (error == null) {\n return \"BokehJS is loading ...\";\n } else {\n return \"BokehJS failed to load.\";\n }\n } else {\n const prefix = `BokehJS ${root.Bokeh.version}`;\n if (error == null) {\n return `${prefix} successfully loaded.`;\n } else {\n return `${prefix} encountered errors while loading and may not function as expected.`;\n }\n }\n })();\n el.innerHTML = html;\n\n if (error != null) {\n const wrapper = document.createElement(\"div\");\n wrapper.style.overflow = \"auto\";\n wrapper.style.height = \"5em\";\n wrapper.style.resize = \"vertical\";\n const content = document.createElement(\"div\");\n content.style.fontFamily = \"monospace\";\n content.style.whiteSpace = \"pre-wrap\";\n content.style.backgroundColor = \"rgb(255, 221, 221)\";\n content.textContent = error.stack ?? error.toString();\n wrapper.append(content);\n el.append(wrapper);\n }\n } else if (Date.now() < root._bokeh_timeout) {\n setTimeout(() => display_loaded(error), 100);\n }\n }\n\n function run_callbacks() {\n try {\n root._bokeh_onload_callbacks.forEach(function(callback) {\n if (callback != null)\n callback();\n });\n } finally {\n delete root._bokeh_onload_callbacks\n }\n console.debug(\"Bokeh: all callbacks have finished\");\n }\n\n function load_libs(css_urls, js_urls, callback) {\n if (css_urls == null) css_urls = [];\n if (js_urls == null) js_urls = [];\n\n root._bokeh_onload_callbacks.push(callback);\n if (root._bokeh_is_loading > 0) {\n console.debug(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n return null;\n }\n if (js_urls == null || js_urls.length === 0) {\n run_callbacks();\n return null;\n }\n console.debug(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n root._bokeh_is_loading = css_urls.length + js_urls.length;\n\n function on_load() {\n root._bokeh_is_loading--;\n if (root._bokeh_is_loading === 0) {\n console.debug(\"Bokeh: all BokehJS libraries/stylesheets loaded\");\n run_callbacks()\n }\n }\n\n function on_error(url) {\n console.error(\"failed to load \" + url);\n }\n\n for (let i = 0; i < css_urls.length; i++) {\n const url = css_urls[i];\n const element = document.createElement(\"link\");\n element.onload = on_load;\n element.onerror = on_error.bind(null, url);\n element.rel = \"stylesheet\";\n element.type = \"text/css\";\n element.href = url;\n console.debug(\"Bokeh: injecting link tag for BokehJS stylesheet: \", url);\n document.body.appendChild(element);\n }\n\n for (let i = 0; i < js_urls.length; i++) {\n const url = js_urls[i];\n const element = document.createElement('script');\n element.onload = on_load;\n element.onerror = on_error.bind(null, url);\n element.async = false;\n element.src = url;\n console.debug(\"Bokeh: injecting script tag for BokehJS library: \", url);\n document.head.appendChild(element);\n }\n };\n\n function inject_raw_css(css) {\n const element = document.createElement(\"style\");\n element.appendChild(document.createTextNode(css));\n document.body.appendChild(element);\n }\n\n const js_urls = [\"https://cdn.bokeh.org/bokeh/release/bokeh-3.7.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-gl-3.7.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-3.7.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-3.7.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-mathjax-3.7.1.min.js\"];\n const css_urls = [];\n\n const inline_js = [ function(Bokeh) {\n Bokeh.set_log_level(\"info\");\n },\nfunction(Bokeh) {\n }\n ];\n\n function run_inline_js() {\n if (root.Bokeh !== undefined || force === true) {\n try {\n for (let i = 0; i < inline_js.length; i++) {\n inline_js[i].call(root, root.Bokeh);\n }\n\n } catch (error) {throw error;\n }} else if (Date.now() < root._bokeh_timeout) {\n setTimeout(run_inline_js, 100);\n } else if (!root._bokeh_failed_load) {\n console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n root._bokeh_failed_load = true;\n } else if (force !== true) {\n const cell = $(document.getElementById(null)).parents('.cell').data().cell;\n cell.output_area.append_execute_result(NB_LOAD_WARNING)\n }\n }\n\n if (root._bokeh_is_loading === 0) {\n console.debug(\"Bokeh: BokehJS loaded, going straight to plotting\");\n run_inline_js();\n } else {\n load_libs(css_urls, js_urls, function() {\n console.debug(\"Bokeh: BokehJS plotting callback run at\", now());\n run_inline_js();\n });\n }\n}(window));", "application/vnd.bokehjs_load.v0+json": "" }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "\n", "
\n" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/javascript": "(function(root) {\n function embed_document(root) {\n const docs_json = {\"90a172e7-cd33-40a7-99c3-2722d42f5948\":{\"version\":\"3.7.1\",\"title\":\"Bokeh Application\",\"roots\":[{\"type\":\"object\",\"name\":\"Figure\",\"id\":\"p2046\",\"attributes\":{\"width\":400,\"height\":400,\"x_range\":{\"type\":\"object\",\"name\":\"DataRange1d\",\"id\":\"p2047\"},\"y_range\":{\"type\":\"object\",\"name\":\"DataRange1d\",\"id\":\"p2048\"},\"x_scale\":{\"type\":\"object\",\"name\":\"LinearScale\",\"id\":\"p2055\"},\"y_scale\":{\"type\":\"object\",\"name\":\"LinearScale\",\"id\":\"p2056\"},\"title\":{\"type\":\"object\",\"name\":\"Title\",\"id\":\"p2053\"},\"renderers\":[{\"type\":\"object\",\"name\":\"GraphRenderer\",\"id\":\"p2078\",\"attributes\":{\"layout_provider\":{\"type\":\"object\",\"name\":\"StaticLayoutProvider\",\"id\":\"p2095\",\"attributes\":{\"graph_layout\":{\"type\":\"map\",\"entries\":[[3,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"18yiX3EItT8AAAAAAADwPw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[4,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"mb5S1UkUfr8OhixMKJ/Uvw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[5,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"23uK1eGu0L/bMExeFRPVvw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[1,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"QCfuSS3Kxz8ZSYdVwk3Wvw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}]]}}},\"node_renderer\":{\"type\":\"object\",\"name\":\"GlyphRenderer\",\"id\":\"p2083\",\"attributes\":{\"data_source\":{\"type\":\"object\",\"name\":\"ColumnDataSource\",\"id\":\"p2080\",\"attributes\":{\"selected\":{\"type\":\"object\",\"name\":\"Selection\",\"id\":\"p2081\",\"attributes\":{\"indices\":[],\"line_indices\":[]}},\"selection_policy\":{\"type\":\"object\",\"name\":\"UnionRenderers\",\"id\":\"p2082\"},\"data\":{\"type\":\"map\",\"entries\":[[\"type\",[\"Agent\",\"Agent\",\"Agent\",\"Agent\"]],[\"index\",[3,4,5,1]],[\"_marker\",[\"circle\",\"circle\",\"circle\",\"circle\"]],[\"_color\",[\"firebrick\",\"firebrick\",\"firebrick\",\"firebrick\"]],[\"_alpha\",[0.5,0.5,0.5,0.5]],[\"_size\",[10,10,10,10]],[\"start_display\",[\"none\",\"none\",\"none\",\"none\"]],[\"end_display\",[\"none\",\"none\",\"none\",\"none\"]],[\"weight_display\",[\"none\",\"none\",\"none\",\"none\"]],[\"index_display\",[1,1,1,1]],[\"type_display\",[1,1,1,1]]]}}},\"view\":{\"type\":\"object\",\"name\":\"CDSView\",\"id\":\"p2084\",\"attributes\":{\"filter\":{\"type\":\"object\",\"name\":\"AllIndices\",\"id\":\"p2085\"}}},\"glyph\":{\"type\":\"object\",\"name\":\"Scatter\",\"id\":\"p2097\",\"attributes\":{\"size\":{\"type\":\"field\",\"field\":\"_size\"},\"line_color\":{\"type\":\"field\",\"field\":\"_color\"},\"line_alpha\":{\"type\":\"field\",\"field\":\"_alpha\"},\"fill_color\":{\"type\":\"field\",\"field\":\"_color\"},\"fill_alpha\":{\"type\":\"field\",\"field\":\"_alpha\"},\"marker\":{\"type\":\"field\",\"field\":\"_marker\"}}}}},\"edge_renderer\":{\"type\":\"object\",\"name\":\"GlyphRenderer\",\"id\":\"p2090\",\"attributes\":{\"data_source\":{\"type\":\"object\",\"name\":\"ColumnDataSource\",\"id\":\"p2087\",\"attributes\":{\"selected\":{\"type\":\"object\",\"name\":\"Selection\",\"id\":\"p2088\",\"attributes\":{\"indices\":[],\"line_indices\":[]}},\"selection_policy\":{\"type\":\"object\",\"name\":\"UnionRenderers\",\"id\":\"p2089\"},\"data\":{\"type\":\"map\",\"entries\":[[\"weight\",[2,1]],[\"start\",[4,4]],[\"end\",[1,5]],[\"_color\",[\"#440154\",\"#440154\"]],[\"_alpha\",[1.0,0.5]],[\"_size\",[1.0,1.0]],[\"start_display\",[1,1]],[\"end_display\",[1,1]],[\"weight_display\",[1,1]],[\"index_display\",[\"none\",\"none\"]],[\"type_display\",[\"none\",\"none\"]]]}}},\"view\":{\"type\":\"object\",\"name\":\"CDSView\",\"id\":\"p2091\",\"attributes\":{\"filter\":{\"type\":\"object\",\"name\":\"AllIndices\",\"id\":\"p2092\"}}},\"glyph\":{\"type\":\"object\",\"name\":\"MultiLine\",\"id\":\"p2096\",\"attributes\":{\"line_color\":{\"type\":\"field\",\"field\":\"_color\"},\"line_alpha\":{\"type\":\"field\",\"field\":\"_alpha\"},\"line_width\":{\"type\":\"field\",\"field\":\"_size\"}}}}},\"selection_policy\":{\"type\":\"object\",\"name\":\"NodesOnly\",\"id\":\"p2093\"},\"inspection_policy\":{\"type\":\"object\",\"name\":\"NodesOnly\",\"id\":\"p2094\"}}}],\"toolbar\":{\"type\":\"object\",\"name\":\"Toolbar\",\"id\":\"p2054\",\"attributes\":{\"tools\":[{\"type\":\"object\",\"name\":\"BoxZoomTool\",\"id\":\"p2067\",\"attributes\":{\"dimensions\":\"both\",\"overlay\":{\"type\":\"object\",\"name\":\"BoxAnnotation\",\"id\":\"p2068\",\"attributes\":{\"syncable\":false,\"line_color\":\"black\",\"line_alpha\":1.0,\"line_width\":2,\"line_dash\":[4,4],\"fill_color\":\"lightgrey\",\"fill_alpha\":0.5,\"level\":\"overlay\",\"visible\":false,\"left\":{\"type\":\"number\",\"value\":\"nan\"},\"right\":{\"type\":\"number\",\"value\":\"nan\"},\"top\":{\"type\":\"number\",\"value\":\"nan\"},\"bottom\":{\"type\":\"number\",\"value\":\"nan\"},\"left_units\":\"canvas\",\"right_units\":\"canvas\",\"top_units\":\"canvas\",\"bottom_units\":\"canvas\",\"handles\":{\"type\":\"object\",\"name\":\"BoxInteractionHandles\",\"id\":\"p2074\",\"attributes\":{\"all\":{\"type\":\"object\",\"name\":\"AreaVisuals\",\"id\":\"p2073\",\"attributes\":{\"fill_color\":\"white\",\"hover_fill_color\":\"lightgray\"}}}}}}}},{\"type\":\"object\",\"name\":\"ResetTool\",\"id\":\"p2075\"},{\"type\":\"object\",\"name\":\"WheelZoomTool\",\"id\":\"p2076\",\"attributes\":{\"renderers\":\"auto\"}},{\"type\":\"object\",\"name\":\"PanTool\",\"id\":\"p2077\"},{\"type\":\"object\",\"name\":\"HoverTool\",\"id\":\"p2098\",\"attributes\":{\"renderers\":[{\"id\":\"p2090\"},{\"id\":\"p2083\"}],\"tooltips\":\"
\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n
start:@start
end:@end
weight:@weight
index:@index
type:@type
\",\"line_policy\":\"interp\"}}],\"logo\":null}},\"left\":[{\"type\":\"object\",\"name\":\"LinearAxis\",\"id\":\"p2062\",\"attributes\":{\"visible\":false,\"ticker\":{\"type\":\"object\",\"name\":\"BasicTicker\",\"id\":\"p2063\",\"attributes\":{\"mantissas\":[1,2,5]}},\"formatter\":{\"type\":\"object\",\"name\":\"BasicTickFormatter\",\"id\":\"p2064\"},\"major_label_policy\":{\"type\":\"object\",\"name\":\"AllLabels\",\"id\":\"p2065\"}}}],\"below\":[{\"type\":\"object\",\"name\":\"LinearAxis\",\"id\":\"p2057\",\"attributes\":{\"visible\":false,\"ticker\":{\"type\":\"object\",\"name\":\"BasicTicker\",\"id\":\"p2058\",\"attributes\":{\"mantissas\":[1,2,5]}},\"formatter\":{\"type\":\"object\",\"name\":\"BasicTickFormatter\",\"id\":\"p2059\"},\"major_label_policy\":{\"type\":\"object\",\"name\":\"AllLabels\",\"id\":\"p2060\"}}}],\"center\":[{\"type\":\"object\",\"name\":\"Grid\",\"id\":\"p2061\",\"attributes\":{\"axis\":{\"id\":\"p2057\"},\"grid_line_color\":null}},{\"type\":\"object\",\"name\":\"Grid\",\"id\":\"p2066\",\"attributes\":{\"dimension\":1,\"axis\":{\"id\":\"p2062\"},\"grid_line_color\":null}}]}}]}};\n const render_items = [{\"docid\":\"90a172e7-cd33-40a7-99c3-2722d42f5948\",\"roots\":{\"p2046\":\"f0132be5-e46b-4575-a1aa-82e96b9217dd\"},\"root_ids\":[\"p2046\"],\"notebook_comms_target\":\"p2099\"}];\n void root.Bokeh.embed.embed_items_notebook(docs_json, render_items);\n }\n if (root.Bokeh !== undefined) {\n embed_document(root);\n } else {\n let attempts = 0;\n const timer = setInterval(function(root) {\n if (root.Bokeh !== undefined) {\n clearInterval(timer);\n embed_document(root);\n } else {\n attempts++;\n if (attempts > 100) {\n clearInterval(timer);\n console.log(\"Bokeh: ERROR: Unable to run BokehJS code because BokehJS library is missing\");\n }\n }\n }, 10, root)\n }\n})(window);", "application/vnd.bokehjs_exec.v0+json": "" }, "metadata": { "application/vnd.bokehjs_exec.v0+json": { "id": "p2046" } }, "output_type": "display_data" } ], "source": [ "inspector.plot_networks()" ] }, { "cell_type": "markdown", "id": "6e891781", "metadata": {}, "source": [ "Using model.connect_agents(), we can connect more than two agents simultaneously.\n", "By setting `agents = model.agents` and `location_cls = World`, all agents in the model are assigned to a new instance of `World`." ] }, { "cell_type": "code", "execution_count": 42, "id": "33252055", "metadata": {}, "outputs": [], "source": [ "class World(p2n.Location):\n", " pass" ] }, { "cell_type": "code", "execution_count": 43, "id": "4def58f6", "metadata": {}, "outputs": [], "source": [ "model.connect_agents(agents=model.agents, location_cls=World)" ] }, { "cell_type": "code", "execution_count": 44, "id": "dd3938f2", "metadata": {}, "outputs": [ { "data": { "application/javascript": "'use strict';\n(function(root) {\n function now() {\n return new Date();\n }\n\n const force = true;\n\n if (typeof root._bokeh_onload_callbacks === \"undefined\" || force === true) {\n root._bokeh_onload_callbacks = [];\n root._bokeh_is_loading = undefined;\n }\n\nconst JS_MIME_TYPE = 'application/javascript';\n const HTML_MIME_TYPE = 'text/html';\n const EXEC_MIME_TYPE = 'application/vnd.bokehjs_exec.v0+json';\n const CLASS_NAME = 'output_bokeh rendered_html';\n\n /**\n * Render data to the DOM node\n */\n function render(props, node) {\n const script = document.createElement(\"script\");\n node.appendChild(script);\n }\n\n /**\n * Handle when an output is cleared or removed\n */\n function handleClearOutput(event, handle) {\n function drop(id) {\n const view = Bokeh.index.get_by_id(id)\n if (view != null) {\n view.model.document.clear()\n Bokeh.index.delete(view)\n }\n }\n\n const cell = handle.cell;\n\n const id = cell.output_area._bokeh_element_id;\n const server_id = cell.output_area._bokeh_server_id;\n\n // Clean up Bokeh references\n if (id != null) {\n drop(id)\n }\n\n if (server_id !== undefined) {\n // Clean up Bokeh references\n const cmd_clean = \"from bokeh.io.state import curstate; print(curstate().uuid_to_server['\" + server_id + \"'].get_sessions()[0].document.roots[0]._id)\";\n cell.notebook.kernel.execute(cmd_clean, {\n iopub: {\n output: function(msg) {\n const id = msg.content.text.trim()\n drop(id)\n }\n }\n });\n // Destroy server and session\n const cmd_destroy = \"import bokeh.io.notebook as ion; ion.destroy_server('\" + server_id + \"')\";\n cell.notebook.kernel.execute(cmd_destroy);\n }\n }\n\n /**\n * Handle when a new output is added\n */\n function handleAddOutput(event, handle) {\n const output_area = handle.output_area;\n const output = handle.output;\n\n // limit handleAddOutput to display_data with EXEC_MIME_TYPE content only\n if ((output.output_type != \"display_data\") || (!Object.prototype.hasOwnProperty.call(output.data, EXEC_MIME_TYPE))) {\n return\n }\n\n const toinsert = output_area.element.find(\".\" + CLASS_NAME.split(' ')[0]);\n\n if (output.metadata[EXEC_MIME_TYPE][\"id\"] !== undefined) {\n toinsert[toinsert.length - 1].firstChild.textContent = output.data[JS_MIME_TYPE];\n // store reference to embed id on output_area\n output_area._bokeh_element_id = output.metadata[EXEC_MIME_TYPE][\"id\"];\n }\n if (output.metadata[EXEC_MIME_TYPE][\"server_id\"] !== undefined) {\n const bk_div = document.createElement(\"div\");\n bk_div.innerHTML = output.data[HTML_MIME_TYPE];\n const script_attrs = bk_div.children[0].attributes;\n for (let i = 0; i < script_attrs.length; i++) {\n toinsert[toinsert.length - 1].firstChild.setAttribute(script_attrs[i].name, script_attrs[i].value);\n toinsert[toinsert.length - 1].firstChild.textContent = bk_div.children[0].textContent\n }\n // store reference to server id on output_area\n output_area._bokeh_server_id = output.metadata[EXEC_MIME_TYPE][\"server_id\"];\n }\n }\n\n function register_renderer(events, OutputArea) {\n\n function append_mime(data, metadata, element) {\n // create a DOM node to render to\n const toinsert = this.create_output_subarea(\n metadata,\n CLASS_NAME,\n EXEC_MIME_TYPE\n );\n this.keyboard_manager.register_events(toinsert);\n // Render to node\n const props = {data: data, metadata: metadata[EXEC_MIME_TYPE]};\n render(props, toinsert[toinsert.length - 1]);\n element.append(toinsert);\n return toinsert\n }\n\n /* Handle when an output is cleared or removed */\n events.on('clear_output.CodeCell', handleClearOutput);\n events.on('delete.Cell', handleClearOutput);\n\n /* Handle when a new output is added */\n events.on('output_added.OutputArea', handleAddOutput);\n\n /**\n * Register the mime type and append_mime function with output_area\n */\n OutputArea.prototype.register_mime_type(EXEC_MIME_TYPE, append_mime, {\n /* Is output safe? */\n safe: true,\n /* Index of renderer in `output_area.display_order` */\n index: 0\n });\n }\n\n // register the mime type if in Jupyter Notebook environment and previously unregistered\n if (root.Jupyter !== undefined) {\n const events = require('base/js/events');\n const OutputArea = require('notebook/js/outputarea').OutputArea;\n\n if (OutputArea.prototype.mime_types().indexOf(EXEC_MIME_TYPE) == -1) {\n register_renderer(events, OutputArea);\n }\n }\n if (typeof (root._bokeh_timeout) === \"undefined\" || force === true) {\n root._bokeh_timeout = Date.now() + 5000;\n root._bokeh_failed_load = false;\n }\n\n const NB_LOAD_WARNING = {'data': {'text/html':\n \"
\\n\"+\n \"

\\n\"+\n \"BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this \\n\"+\n \"may be due to a slow or bad network connection. Possible fixes:\\n\"+\n \"

\\n\"+\n \"\\n\"+\n \"\\n\"+\n \"from bokeh.resources import INLINE\\n\"+\n \"output_notebook(resources=INLINE)\\n\"+\n \"\\n\"+\n \"
\"}};\n\n function display_loaded(error = null) {\n const el = document.getElementById(null);\n if (el != null) {\n const html = (() => {\n if (typeof root.Bokeh === \"undefined\") {\n if (error == null) {\n return \"BokehJS is loading ...\";\n } else {\n return \"BokehJS failed to load.\";\n }\n } else {\n const prefix = `BokehJS ${root.Bokeh.version}`;\n if (error == null) {\n return `${prefix} successfully loaded.`;\n } else {\n return `${prefix} encountered errors while loading and may not function as expected.`;\n }\n }\n })();\n el.innerHTML = html;\n\n if (error != null) {\n const wrapper = document.createElement(\"div\");\n wrapper.style.overflow = \"auto\";\n wrapper.style.height = \"5em\";\n wrapper.style.resize = \"vertical\";\n const content = document.createElement(\"div\");\n content.style.fontFamily = \"monospace\";\n content.style.whiteSpace = \"pre-wrap\";\n content.style.backgroundColor = \"rgb(255, 221, 221)\";\n content.textContent = error.stack ?? error.toString();\n wrapper.append(content);\n el.append(wrapper);\n }\n } else if (Date.now() < root._bokeh_timeout) {\n setTimeout(() => display_loaded(error), 100);\n }\n }\n\n function run_callbacks() {\n try {\n root._bokeh_onload_callbacks.forEach(function(callback) {\n if (callback != null)\n callback();\n });\n } finally {\n delete root._bokeh_onload_callbacks\n }\n console.debug(\"Bokeh: all callbacks have finished\");\n }\n\n function load_libs(css_urls, js_urls, callback) {\n if (css_urls == null) css_urls = [];\n if (js_urls == null) js_urls = [];\n\n root._bokeh_onload_callbacks.push(callback);\n if (root._bokeh_is_loading > 0) {\n console.debug(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n return null;\n }\n if (js_urls == null || js_urls.length === 0) {\n run_callbacks();\n return null;\n }\n console.debug(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n root._bokeh_is_loading = css_urls.length + js_urls.length;\n\n function on_load() {\n root._bokeh_is_loading--;\n if (root._bokeh_is_loading === 0) {\n console.debug(\"Bokeh: all BokehJS libraries/stylesheets loaded\");\n run_callbacks()\n }\n }\n\n function on_error(url) {\n console.error(\"failed to load \" + url);\n }\n\n for (let i = 0; i < css_urls.length; i++) {\n const url = css_urls[i];\n const element = document.createElement(\"link\");\n element.onload = on_load;\n element.onerror = on_error.bind(null, url);\n element.rel = \"stylesheet\";\n element.type = \"text/css\";\n element.href = url;\n console.debug(\"Bokeh: injecting link tag for BokehJS stylesheet: \", url);\n document.body.appendChild(element);\n }\n\n for (let i = 0; i < js_urls.length; i++) {\n const url = js_urls[i];\n const element = document.createElement('script');\n element.onload = on_load;\n element.onerror = on_error.bind(null, url);\n element.async = false;\n element.src = url;\n console.debug(\"Bokeh: injecting script tag for BokehJS library: \", url);\n document.head.appendChild(element);\n }\n };\n\n function inject_raw_css(css) {\n const element = document.createElement(\"style\");\n element.appendChild(document.createTextNode(css));\n document.body.appendChild(element);\n }\n\n const js_urls = [\"https://cdn.bokeh.org/bokeh/release/bokeh-3.7.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-gl-3.7.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-3.7.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-3.7.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-mathjax-3.7.1.min.js\"];\n const css_urls = [];\n\n const inline_js = [ function(Bokeh) {\n Bokeh.set_log_level(\"info\");\n },\nfunction(Bokeh) {\n }\n ];\n\n function run_inline_js() {\n if (root.Bokeh !== undefined || force === true) {\n try {\n for (let i = 0; i < inline_js.length; i++) {\n inline_js[i].call(root, root.Bokeh);\n }\n\n } catch (error) {throw error;\n }} else if (Date.now() < root._bokeh_timeout) {\n setTimeout(run_inline_js, 100);\n } else if (!root._bokeh_failed_load) {\n console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n root._bokeh_failed_load = true;\n } else if (force !== true) {\n const cell = $(document.getElementById(null)).parents('.cell').data().cell;\n cell.output_area.append_execute_result(NB_LOAD_WARNING)\n }\n }\n\n if (root._bokeh_is_loading === 0) {\n console.debug(\"Bokeh: BokehJS loaded, going straight to plotting\");\n run_inline_js();\n } else {\n load_libs(css_urls, js_urls, function() {\n console.debug(\"Bokeh: BokehJS plotting callback run at\", now());\n run_inline_js();\n });\n }\n}(window));", "application/vnd.bokehjs_load.v0+json": "" }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "\n", "
\n" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/javascript": "(function(root) {\n function embed_document(root) {\n const docs_json = {\"821da407-c6fe-4131-838d-e8d467a7849d\":{\"version\":\"3.7.1\",\"title\":\"Bokeh Application\",\"roots\":[{\"type\":\"object\",\"name\":\"Figure\",\"id\":\"p2104\",\"attributes\":{\"width\":400,\"height\":400,\"x_range\":{\"type\":\"object\",\"name\":\"DataRange1d\",\"id\":\"p2105\"},\"y_range\":{\"type\":\"object\",\"name\":\"DataRange1d\",\"id\":\"p2106\"},\"x_scale\":{\"type\":\"object\",\"name\":\"LinearScale\",\"id\":\"p2113\"},\"y_scale\":{\"type\":\"object\",\"name\":\"LinearScale\",\"id\":\"p2114\"},\"title\":{\"type\":\"object\",\"name\":\"Title\",\"id\":\"p2111\"},\"renderers\":[{\"type\":\"object\",\"name\":\"GraphRenderer\",\"id\":\"p2136\",\"attributes\":{\"layout_provider\":{\"type\":\"object\",\"name\":\"StaticLayoutProvider\",\"id\":\"p2153\",\"attributes\":{\"graph_layout\":{\"type\":\"map\",\"entries\":[[2,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"a6jW3gFz2b8AAAAAAADwvw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[3,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"CvXSbiWm0b/U+V0Z6xbjvw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[4,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"nHIA7uj4xj+N1XkZDl3VPw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[5,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"hvo/e4f00L/iTt8qnJ3YPw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[6,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"cTlc6g/mpr9/sFXBg7DlPw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[1,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"2rXPDIN80z+dOAxkDW+tvw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[7,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"zSIyJyn54T/vVCw/5hvKPw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[8,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"nEOpENstoz95AZDM+m/APw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[9,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"CPhQuFGaub+m15S2qRezvw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}]]}}},\"node_renderer\":{\"type\":\"object\",\"name\":\"GlyphRenderer\",\"id\":\"p2141\",\"attributes\":{\"data_source\":{\"type\":\"object\",\"name\":\"ColumnDataSource\",\"id\":\"p2138\",\"attributes\":{\"selected\":{\"type\":\"object\",\"name\":\"Selection\",\"id\":\"p2139\",\"attributes\":{\"indices\":[],\"line_indices\":[]}},\"selection_policy\":{\"type\":\"object\",\"name\":\"UnionRenderers\",\"id\":\"p2140\"},\"data\":{\"type\":\"map\",\"entries\":[[\"type\",[\"Location\",\"Agent\",\"Agent\",\"Agent\",\"School\",\"Agent\",\"Location\",\"School\",\"World\"]],[\"label\",[\"Location\",null,null,null,\"School\",null,\"Location\",\"School\",\"World\"]],[\"bipartite\",[1,0,0,0,1,0,1,1,1]],[\"index\",[2,3,4,5,6,1,7,8,9]],[\"_marker\",[\"square\",\"circle\",\"circle\",\"circle\",\"square\",\"circle\",\"square\",\"square\",\"square\"]],[\"_color\",[\"steelblue\",\"firebrick\",\"firebrick\",\"firebrick\",\"steelblue\",\"firebrick\",\"steelblue\",\"steelblue\",\"steelblue\"]],[\"_alpha\",[0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5]],[\"_size\",[10,10,10,10,10,10,10,10,10]],[\"start_display\",[\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\"]],[\"end_display\",[\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\"]],[\"weight_display\",[\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\"]],[\"index_display\",[1,1,1,1,1,1,1,1,1]],[\"type_display\",[1,1,1,1,1,1,1,1,1]],[\"label_display\",[1,\"none\",\"none\",\"none\",1,\"none\",1,1,1]]]}}},\"view\":{\"type\":\"object\",\"name\":\"CDSView\",\"id\":\"p2142\",\"attributes\":{\"filter\":{\"type\":\"object\",\"name\":\"AllIndices\",\"id\":\"p2143\"}}},\"glyph\":{\"type\":\"object\",\"name\":\"Scatter\",\"id\":\"p2155\",\"attributes\":{\"size\":{\"type\":\"field\",\"field\":\"_size\"},\"line_color\":{\"type\":\"field\",\"field\":\"_color\"},\"line_alpha\":{\"type\":\"field\",\"field\":\"_alpha\"},\"fill_color\":{\"type\":\"field\",\"field\":\"_color\"},\"fill_alpha\":{\"type\":\"field\",\"field\":\"_alpha\"},\"marker\":{\"type\":\"field\",\"field\":\"_marker\"}}}}},\"edge_renderer\":{\"type\":\"object\",\"name\":\"GlyphRenderer\",\"id\":\"p2148\",\"attributes\":{\"data_source\":{\"type\":\"object\",\"name\":\"ColumnDataSource\",\"id\":\"p2145\",\"attributes\":{\"selected\":{\"type\":\"object\",\"name\":\"Selection\",\"id\":\"p2146\",\"attributes\":{\"indices\":[],\"line_indices\":[]}},\"selection_policy\":{\"type\":\"object\",\"name\":\"UnionRenderers\",\"id\":\"p2147\"},\"data\":{\"type\":\"map\",\"entries\":[[\"weight\",[1,1,1,1,1,1,1,1,1,1,1]],[\"start\",[2,3,4,4,4,4,5,5,1,1,1]],[\"end\",[3,9,6,7,8,9,6,9,7,8,9]],[\"_color\",[\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\"]],[\"_alpha\",[1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0]],[\"_size\",[1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0]],[\"start_display\",[1,1,1,1,1,1,1,1,1,1,1]],[\"end_display\",[1,1,1,1,1,1,1,1,1,1,1]],[\"weight_display\",[1,1,1,1,1,1,1,1,1,1,1]],[\"index_display\",[\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\"]],[\"type_display\",[\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\"]],[\"label_display\",[\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\"]]]}}},\"view\":{\"type\":\"object\",\"name\":\"CDSView\",\"id\":\"p2149\",\"attributes\":{\"filter\":{\"type\":\"object\",\"name\":\"AllIndices\",\"id\":\"p2150\"}}},\"glyph\":{\"type\":\"object\",\"name\":\"MultiLine\",\"id\":\"p2154\",\"attributes\":{\"line_color\":{\"type\":\"field\",\"field\":\"_color\"},\"line_alpha\":{\"type\":\"field\",\"field\":\"_alpha\"},\"line_width\":{\"type\":\"field\",\"field\":\"_size\"}}}}},\"selection_policy\":{\"type\":\"object\",\"name\":\"NodesOnly\",\"id\":\"p2151\"},\"inspection_policy\":{\"type\":\"object\",\"name\":\"NodesOnly\",\"id\":\"p2152\"}}}],\"toolbar\":{\"type\":\"object\",\"name\":\"Toolbar\",\"id\":\"p2112\",\"attributes\":{\"tools\":[{\"type\":\"object\",\"name\":\"BoxZoomTool\",\"id\":\"p2125\",\"attributes\":{\"dimensions\":\"both\",\"overlay\":{\"type\":\"object\",\"name\":\"BoxAnnotation\",\"id\":\"p2126\",\"attributes\":{\"syncable\":false,\"line_color\":\"black\",\"line_alpha\":1.0,\"line_width\":2,\"line_dash\":[4,4],\"fill_color\":\"lightgrey\",\"fill_alpha\":0.5,\"level\":\"overlay\",\"visible\":false,\"left\":{\"type\":\"number\",\"value\":\"nan\"},\"right\":{\"type\":\"number\",\"value\":\"nan\"},\"top\":{\"type\":\"number\",\"value\":\"nan\"},\"bottom\":{\"type\":\"number\",\"value\":\"nan\"},\"left_units\":\"canvas\",\"right_units\":\"canvas\",\"top_units\":\"canvas\",\"bottom_units\":\"canvas\",\"handles\":{\"type\":\"object\",\"name\":\"BoxInteractionHandles\",\"id\":\"p2132\",\"attributes\":{\"all\":{\"type\":\"object\",\"name\":\"AreaVisuals\",\"id\":\"p2131\",\"attributes\":{\"fill_color\":\"white\",\"hover_fill_color\":\"lightgray\"}}}}}}}},{\"type\":\"object\",\"name\":\"ResetTool\",\"id\":\"p2133\"},{\"type\":\"object\",\"name\":\"WheelZoomTool\",\"id\":\"p2134\",\"attributes\":{\"renderers\":\"auto\"}},{\"type\":\"object\",\"name\":\"PanTool\",\"id\":\"p2135\"},{\"type\":\"object\",\"name\":\"HoverTool\",\"id\":\"p2156\",\"attributes\":{\"renderers\":[{\"id\":\"p2148\"},{\"id\":\"p2141\"}],\"tooltips\":\"
\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n
start:@start
end:@end
weight:@weight
index:@index
type:@type
label:@label
\",\"line_policy\":\"interp\"}}],\"logo\":null}},\"left\":[{\"type\":\"object\",\"name\":\"LinearAxis\",\"id\":\"p2120\",\"attributes\":{\"visible\":false,\"ticker\":{\"type\":\"object\",\"name\":\"BasicTicker\",\"id\":\"p2121\",\"attributes\":{\"mantissas\":[1,2,5]}},\"formatter\":{\"type\":\"object\",\"name\":\"BasicTickFormatter\",\"id\":\"p2122\"},\"major_label_policy\":{\"type\":\"object\",\"name\":\"AllLabels\",\"id\":\"p2123\"}}}],\"below\":[{\"type\":\"object\",\"name\":\"LinearAxis\",\"id\":\"p2115\",\"attributes\":{\"visible\":false,\"ticker\":{\"type\":\"object\",\"name\":\"BasicTicker\",\"id\":\"p2116\",\"attributes\":{\"mantissas\":[1,2,5]}},\"formatter\":{\"type\":\"object\",\"name\":\"BasicTickFormatter\",\"id\":\"p2117\"},\"major_label_policy\":{\"type\":\"object\",\"name\":\"AllLabels\",\"id\":\"p2118\"}}}],\"center\":[{\"type\":\"object\",\"name\":\"Grid\",\"id\":\"p2119\",\"attributes\":{\"axis\":{\"id\":\"p2115\"},\"grid_line_color\":null}},{\"type\":\"object\",\"name\":\"Grid\",\"id\":\"p2124\",\"attributes\":{\"dimension\":1,\"axis\":{\"id\":\"p2120\"},\"grid_line_color\":null}}]}}]}};\n const render_items = [{\"docid\":\"821da407-c6fe-4131-838d-e8d467a7849d\",\"roots\":{\"p2104\":\"ae086e9a-f9bb-45ef-8161-2d68d6497c35\"},\"root_ids\":[\"p2104\"],\"notebook_comms_target\":\"p2157\"}];\n void root.Bokeh.embed.embed_items_notebook(docs_json, render_items);\n }\n if (root.Bokeh !== undefined) {\n embed_document(root);\n } else {\n let attempts = 0;\n const timer = setInterval(function(root) {\n if (root.Bokeh !== undefined) {\n clearInterval(timer);\n embed_document(root);\n } else {\n attempts++;\n if (attempts > 100) {\n clearInterval(timer);\n console.log(\"Bokeh: ERROR: Unable to run BokehJS code because BokehJS library is missing\");\n }\n }\n }, 10, root)\n }\n})(window);", "application/vnd.bokehjs_exec.v0+json": "" }, "metadata": { "application/vnd.bokehjs_exec.v0+json": { "id": "p2104" } }, "output_type": "display_data" }, { "data": { "application/javascript": "'use strict';\n(function(root) {\n function now() {\n return new Date();\n }\n\n const force = true;\n\n if (typeof root._bokeh_onload_callbacks === \"undefined\" || force === true) {\n root._bokeh_onload_callbacks = [];\n root._bokeh_is_loading = undefined;\n }\n\nconst JS_MIME_TYPE = 'application/javascript';\n const HTML_MIME_TYPE = 'text/html';\n const EXEC_MIME_TYPE = 'application/vnd.bokehjs_exec.v0+json';\n const CLASS_NAME = 'output_bokeh rendered_html';\n\n /**\n * Render data to the DOM node\n */\n function render(props, node) {\n const script = document.createElement(\"script\");\n node.appendChild(script);\n }\n\n /**\n * Handle when an output is cleared or removed\n */\n function handleClearOutput(event, handle) {\n function drop(id) {\n const view = Bokeh.index.get_by_id(id)\n if (view != null) {\n view.model.document.clear()\n Bokeh.index.delete(view)\n }\n }\n\n const cell = handle.cell;\n\n const id = cell.output_area._bokeh_element_id;\n const server_id = cell.output_area._bokeh_server_id;\n\n // Clean up Bokeh references\n if (id != null) {\n drop(id)\n }\n\n if (server_id !== undefined) {\n // Clean up Bokeh references\n const cmd_clean = \"from bokeh.io.state import curstate; print(curstate().uuid_to_server['\" + server_id + \"'].get_sessions()[0].document.roots[0]._id)\";\n cell.notebook.kernel.execute(cmd_clean, {\n iopub: {\n output: function(msg) {\n const id = msg.content.text.trim()\n drop(id)\n }\n }\n });\n // Destroy server and session\n const cmd_destroy = \"import bokeh.io.notebook as ion; ion.destroy_server('\" + server_id + \"')\";\n cell.notebook.kernel.execute(cmd_destroy);\n }\n }\n\n /**\n * Handle when a new output is added\n */\n function handleAddOutput(event, handle) {\n const output_area = handle.output_area;\n const output = handle.output;\n\n // limit handleAddOutput to display_data with EXEC_MIME_TYPE content only\n if ((output.output_type != \"display_data\") || (!Object.prototype.hasOwnProperty.call(output.data, EXEC_MIME_TYPE))) {\n return\n }\n\n const toinsert = output_area.element.find(\".\" + CLASS_NAME.split(' ')[0]);\n\n if (output.metadata[EXEC_MIME_TYPE][\"id\"] !== undefined) {\n toinsert[toinsert.length - 1].firstChild.textContent = output.data[JS_MIME_TYPE];\n // store reference to embed id on output_area\n output_area._bokeh_element_id = output.metadata[EXEC_MIME_TYPE][\"id\"];\n }\n if (output.metadata[EXEC_MIME_TYPE][\"server_id\"] !== undefined) {\n const bk_div = document.createElement(\"div\");\n bk_div.innerHTML = output.data[HTML_MIME_TYPE];\n const script_attrs = bk_div.children[0].attributes;\n for (let i = 0; i < script_attrs.length; i++) {\n toinsert[toinsert.length - 1].firstChild.setAttribute(script_attrs[i].name, script_attrs[i].value);\n toinsert[toinsert.length - 1].firstChild.textContent = bk_div.children[0].textContent\n }\n // store reference to server id on output_area\n output_area._bokeh_server_id = output.metadata[EXEC_MIME_TYPE][\"server_id\"];\n }\n }\n\n function register_renderer(events, OutputArea) {\n\n function append_mime(data, metadata, element) {\n // create a DOM node to render to\n const toinsert = this.create_output_subarea(\n metadata,\n CLASS_NAME,\n EXEC_MIME_TYPE\n );\n this.keyboard_manager.register_events(toinsert);\n // Render to node\n const props = {data: data, metadata: metadata[EXEC_MIME_TYPE]};\n render(props, toinsert[toinsert.length - 1]);\n element.append(toinsert);\n return toinsert\n }\n\n /* Handle when an output is cleared or removed */\n events.on('clear_output.CodeCell', handleClearOutput);\n events.on('delete.Cell', handleClearOutput);\n\n /* Handle when a new output is added */\n events.on('output_added.OutputArea', handleAddOutput);\n\n /**\n * Register the mime type and append_mime function with output_area\n */\n OutputArea.prototype.register_mime_type(EXEC_MIME_TYPE, append_mime, {\n /* Is output safe? */\n safe: true,\n /* Index of renderer in `output_area.display_order` */\n index: 0\n });\n }\n\n // register the mime type if in Jupyter Notebook environment and previously unregistered\n if (root.Jupyter !== undefined) {\n const events = require('base/js/events');\n const OutputArea = require('notebook/js/outputarea').OutputArea;\n\n if (OutputArea.prototype.mime_types().indexOf(EXEC_MIME_TYPE) == -1) {\n register_renderer(events, OutputArea);\n }\n }\n if (typeof (root._bokeh_timeout) === \"undefined\" || force === true) {\n root._bokeh_timeout = Date.now() + 5000;\n root._bokeh_failed_load = false;\n }\n\n const NB_LOAD_WARNING = {'data': {'text/html':\n \"
\\n\"+\n \"

\\n\"+\n \"BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this \\n\"+\n \"may be due to a slow or bad network connection. Possible fixes:\\n\"+\n \"

\\n\"+\n \"\\n\"+\n \"\\n\"+\n \"from bokeh.resources import INLINE\\n\"+\n \"output_notebook(resources=INLINE)\\n\"+\n \"\\n\"+\n \"
\"}};\n\n function display_loaded(error = null) {\n const el = document.getElementById(null);\n if (el != null) {\n const html = (() => {\n if (typeof root.Bokeh === \"undefined\") {\n if (error == null) {\n return \"BokehJS is loading ...\";\n } else {\n return \"BokehJS failed to load.\";\n }\n } else {\n const prefix = `BokehJS ${root.Bokeh.version}`;\n if (error == null) {\n return `${prefix} successfully loaded.`;\n } else {\n return `${prefix} encountered errors while loading and may not function as expected.`;\n }\n }\n })();\n el.innerHTML = html;\n\n if (error != null) {\n const wrapper = document.createElement(\"div\");\n wrapper.style.overflow = \"auto\";\n wrapper.style.height = \"5em\";\n wrapper.style.resize = \"vertical\";\n const content = document.createElement(\"div\");\n content.style.fontFamily = \"monospace\";\n content.style.whiteSpace = \"pre-wrap\";\n content.style.backgroundColor = \"rgb(255, 221, 221)\";\n content.textContent = error.stack ?? error.toString();\n wrapper.append(content);\n el.append(wrapper);\n }\n } else if (Date.now() < root._bokeh_timeout) {\n setTimeout(() => display_loaded(error), 100);\n }\n }\n\n function run_callbacks() {\n try {\n root._bokeh_onload_callbacks.forEach(function(callback) {\n if (callback != null)\n callback();\n });\n } finally {\n delete root._bokeh_onload_callbacks\n }\n console.debug(\"Bokeh: all callbacks have finished\");\n }\n\n function load_libs(css_urls, js_urls, callback) {\n if (css_urls == null) css_urls = [];\n if (js_urls == null) js_urls = [];\n\n root._bokeh_onload_callbacks.push(callback);\n if (root._bokeh_is_loading > 0) {\n console.debug(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n return null;\n }\n if (js_urls == null || js_urls.length === 0) {\n run_callbacks();\n return null;\n }\n console.debug(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n root._bokeh_is_loading = css_urls.length + js_urls.length;\n\n function on_load() {\n root._bokeh_is_loading--;\n if (root._bokeh_is_loading === 0) {\n console.debug(\"Bokeh: all BokehJS libraries/stylesheets loaded\");\n run_callbacks()\n }\n }\n\n function on_error(url) {\n console.error(\"failed to load \" + url);\n }\n\n for (let i = 0; i < css_urls.length; i++) {\n const url = css_urls[i];\n const element = document.createElement(\"link\");\n element.onload = on_load;\n element.onerror = on_error.bind(null, url);\n element.rel = \"stylesheet\";\n element.type = \"text/css\";\n element.href = url;\n console.debug(\"Bokeh: injecting link tag for BokehJS stylesheet: \", url);\n document.body.appendChild(element);\n }\n\n for (let i = 0; i < js_urls.length; i++) {\n const url = js_urls[i];\n const element = document.createElement('script');\n element.onload = on_load;\n element.onerror = on_error.bind(null, url);\n element.async = false;\n element.src = url;\n console.debug(\"Bokeh: injecting script tag for BokehJS library: \", url);\n document.head.appendChild(element);\n }\n };\n\n function inject_raw_css(css) {\n const element = document.createElement(\"style\");\n element.appendChild(document.createTextNode(css));\n document.body.appendChild(element);\n }\n\n const js_urls = [\"https://cdn.bokeh.org/bokeh/release/bokeh-3.7.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-gl-3.7.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-3.7.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-3.7.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-mathjax-3.7.1.min.js\"];\n const css_urls = [];\n\n const inline_js = [ function(Bokeh) {\n Bokeh.set_log_level(\"info\");\n },\nfunction(Bokeh) {\n }\n ];\n\n function run_inline_js() {\n if (root.Bokeh !== undefined || force === true) {\n try {\n for (let i = 0; i < inline_js.length; i++) {\n inline_js[i].call(root, root.Bokeh);\n }\n\n } catch (error) {throw error;\n }} else if (Date.now() < root._bokeh_timeout) {\n setTimeout(run_inline_js, 100);\n } else if (!root._bokeh_failed_load) {\n console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n root._bokeh_failed_load = true;\n } else if (force !== true) {\n const cell = $(document.getElementById(null)).parents('.cell').data().cell;\n cell.output_area.append_execute_result(NB_LOAD_WARNING)\n }\n }\n\n if (root._bokeh_is_loading === 0) {\n console.debug(\"Bokeh: BokehJS loaded, going straight to plotting\");\n run_inline_js();\n } else {\n load_libs(css_urls, js_urls, function() {\n console.debug(\"Bokeh: BokehJS plotting callback run at\", now());\n run_inline_js();\n });\n }\n}(window));", "application/vnd.bokehjs_load.v0+json": "" }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "\n", "
\n" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/javascript": "(function(root) {\n function embed_document(root) {\n const docs_json = {\"265c9100-f461-4cb4-b590-21d647572f2c\":{\"version\":\"3.7.1\",\"title\":\"Bokeh Application\",\"roots\":[{\"type\":\"object\",\"name\":\"Figure\",\"id\":\"p2167\",\"attributes\":{\"width\":400,\"height\":400,\"x_range\":{\"type\":\"object\",\"name\":\"DataRange1d\",\"id\":\"p2168\"},\"y_range\":{\"type\":\"object\",\"name\":\"DataRange1d\",\"id\":\"p2169\"},\"x_scale\":{\"type\":\"object\",\"name\":\"LinearScale\",\"id\":\"p2176\"},\"y_scale\":{\"type\":\"object\",\"name\":\"LinearScale\",\"id\":\"p2177\"},\"title\":{\"type\":\"object\",\"name\":\"Title\",\"id\":\"p2174\"},\"renderers\":[{\"type\":\"object\",\"name\":\"GraphRenderer\",\"id\":\"p2199\",\"attributes\":{\"layout_provider\":{\"type\":\"object\",\"name\":\"StaticLayoutProvider\",\"id\":\"p2216\",\"attributes\":{\"graph_layout\":{\"type\":\"map\",\"entries\":[[3,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"pa3BLzQ+zT8AAAAAAADwPw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[4,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"yBTv86tFvr99+OUsjNPnvw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[5,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"SXGwbAOA7b8eTEZ4UvK0Pw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[1,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"eug93yv56T8JokVEfJXVvw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}]]}}},\"node_renderer\":{\"type\":\"object\",\"name\":\"GlyphRenderer\",\"id\":\"p2204\",\"attributes\":{\"data_source\":{\"type\":\"object\",\"name\":\"ColumnDataSource\",\"id\":\"p2201\",\"attributes\":{\"selected\":{\"type\":\"object\",\"name\":\"Selection\",\"id\":\"p2202\",\"attributes\":{\"indices\":[],\"line_indices\":[]}},\"selection_policy\":{\"type\":\"object\",\"name\":\"UnionRenderers\",\"id\":\"p2203\"},\"data\":{\"type\":\"map\",\"entries\":[[\"type\",[\"Agent\",\"Agent\",\"Agent\",\"Agent\"]],[\"index\",[3,4,5,1]],[\"_marker\",[\"circle\",\"circle\",\"circle\",\"circle\"]],[\"_color\",[\"firebrick\",\"firebrick\",\"firebrick\",\"firebrick\"]],[\"_alpha\",[0.5,0.5,0.5,0.5]],[\"_size\",[10,10,10,10]],[\"start_display\",[\"none\",\"none\",\"none\",\"none\"]],[\"end_display\",[\"none\",\"none\",\"none\",\"none\"]],[\"weight_display\",[\"none\",\"none\",\"none\",\"none\"]],[\"index_display\",[1,1,1,1]],[\"type_display\",[1,1,1,1]]]}}},\"view\":{\"type\":\"object\",\"name\":\"CDSView\",\"id\":\"p2205\",\"attributes\":{\"filter\":{\"type\":\"object\",\"name\":\"AllIndices\",\"id\":\"p2206\"}}},\"glyph\":{\"type\":\"object\",\"name\":\"Scatter\",\"id\":\"p2218\",\"attributes\":{\"size\":{\"type\":\"field\",\"field\":\"_size\"},\"line_color\":{\"type\":\"field\",\"field\":\"_color\"},\"line_alpha\":{\"type\":\"field\",\"field\":\"_alpha\"},\"fill_color\":{\"type\":\"field\",\"field\":\"_color\"},\"fill_alpha\":{\"type\":\"field\",\"field\":\"_alpha\"},\"marker\":{\"type\":\"field\",\"field\":\"_marker\"}}}}},\"edge_renderer\":{\"type\":\"object\",\"name\":\"GlyphRenderer\",\"id\":\"p2211\",\"attributes\":{\"data_source\":{\"type\":\"object\",\"name\":\"ColumnDataSource\",\"id\":\"p2208\",\"attributes\":{\"selected\":{\"type\":\"object\",\"name\":\"Selection\",\"id\":\"p2209\",\"attributes\":{\"indices\":[],\"line_indices\":[]}},\"selection_policy\":{\"type\":\"object\",\"name\":\"UnionRenderers\",\"id\":\"p2210\"},\"data\":{\"type\":\"map\",\"entries\":[[\"weight\",[1,1,1,3,2,1]],[\"start\",[3,3,3,4,4,5]],[\"end\",[1,4,5,1,5,1]],[\"_color\",[\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\"]],[\"_alpha\",[0.3333333333333333,0.3333333333333333,0.3333333333333333,1.0,0.6666666666666666,0.3333333333333333]],[\"_size\",[1.0,1.0,1.0,1.0,1.0,1.0]],[\"start_display\",[1,1,1,1,1,1]],[\"end_display\",[1,1,1,1,1,1]],[\"weight_display\",[1,1,1,1,1,1]],[\"index_display\",[\"none\",\"none\",\"none\",\"none\",\"none\",\"none\"]],[\"type_display\",[\"none\",\"none\",\"none\",\"none\",\"none\",\"none\"]]]}}},\"view\":{\"type\":\"object\",\"name\":\"CDSView\",\"id\":\"p2212\",\"attributes\":{\"filter\":{\"type\":\"object\",\"name\":\"AllIndices\",\"id\":\"p2213\"}}},\"glyph\":{\"type\":\"object\",\"name\":\"MultiLine\",\"id\":\"p2217\",\"attributes\":{\"line_color\":{\"type\":\"field\",\"field\":\"_color\"},\"line_alpha\":{\"type\":\"field\",\"field\":\"_alpha\"},\"line_width\":{\"type\":\"field\",\"field\":\"_size\"}}}}},\"selection_policy\":{\"type\":\"object\",\"name\":\"NodesOnly\",\"id\":\"p2214\"},\"inspection_policy\":{\"type\":\"object\",\"name\":\"NodesOnly\",\"id\":\"p2215\"}}}],\"toolbar\":{\"type\":\"object\",\"name\":\"Toolbar\",\"id\":\"p2175\",\"attributes\":{\"tools\":[{\"type\":\"object\",\"name\":\"BoxZoomTool\",\"id\":\"p2188\",\"attributes\":{\"dimensions\":\"both\",\"overlay\":{\"type\":\"object\",\"name\":\"BoxAnnotation\",\"id\":\"p2189\",\"attributes\":{\"syncable\":false,\"line_color\":\"black\",\"line_alpha\":1.0,\"line_width\":2,\"line_dash\":[4,4],\"fill_color\":\"lightgrey\",\"fill_alpha\":0.5,\"level\":\"overlay\",\"visible\":false,\"left\":{\"type\":\"number\",\"value\":\"nan\"},\"right\":{\"type\":\"number\",\"value\":\"nan\"},\"top\":{\"type\":\"number\",\"value\":\"nan\"},\"bottom\":{\"type\":\"number\",\"value\":\"nan\"},\"left_units\":\"canvas\",\"right_units\":\"canvas\",\"top_units\":\"canvas\",\"bottom_units\":\"canvas\",\"handles\":{\"type\":\"object\",\"name\":\"BoxInteractionHandles\",\"id\":\"p2195\",\"attributes\":{\"all\":{\"type\":\"object\",\"name\":\"AreaVisuals\",\"id\":\"p2194\",\"attributes\":{\"fill_color\":\"white\",\"hover_fill_color\":\"lightgray\"}}}}}}}},{\"type\":\"object\",\"name\":\"ResetTool\",\"id\":\"p2196\"},{\"type\":\"object\",\"name\":\"WheelZoomTool\",\"id\":\"p2197\",\"attributes\":{\"renderers\":\"auto\"}},{\"type\":\"object\",\"name\":\"PanTool\",\"id\":\"p2198\"},{\"type\":\"object\",\"name\":\"HoverTool\",\"id\":\"p2219\",\"attributes\":{\"renderers\":[{\"id\":\"p2211\"},{\"id\":\"p2204\"}],\"tooltips\":\"
\\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n \\n
start:@start
end:@end
weight:@weight
index:@index
type:@type
\",\"line_policy\":\"interp\"}}],\"logo\":null}},\"left\":[{\"type\":\"object\",\"name\":\"LinearAxis\",\"id\":\"p2183\",\"attributes\":{\"visible\":false,\"ticker\":{\"type\":\"object\",\"name\":\"BasicTicker\",\"id\":\"p2184\",\"attributes\":{\"mantissas\":[1,2,5]}},\"formatter\":{\"type\":\"object\",\"name\":\"BasicTickFormatter\",\"id\":\"p2185\"},\"major_label_policy\":{\"type\":\"object\",\"name\":\"AllLabels\",\"id\":\"p2186\"}}}],\"below\":[{\"type\":\"object\",\"name\":\"LinearAxis\",\"id\":\"p2178\",\"attributes\":{\"visible\":false,\"ticker\":{\"type\":\"object\",\"name\":\"BasicTicker\",\"id\":\"p2179\",\"attributes\":{\"mantissas\":[1,2,5]}},\"formatter\":{\"type\":\"object\",\"name\":\"BasicTickFormatter\",\"id\":\"p2180\"},\"major_label_policy\":{\"type\":\"object\",\"name\":\"AllLabels\",\"id\":\"p2181\"}}}],\"center\":[{\"type\":\"object\",\"name\":\"Grid\",\"id\":\"p2182\",\"attributes\":{\"axis\":{\"id\":\"p2178\"},\"grid_line_color\":null}},{\"type\":\"object\",\"name\":\"Grid\",\"id\":\"p2187\",\"attributes\":{\"dimension\":1,\"axis\":{\"id\":\"p2183\"},\"grid_line_color\":null}}]}}]}};\n const render_items = [{\"docid\":\"265c9100-f461-4cb4-b590-21d647572f2c\",\"roots\":{\"p2167\":\"aca1916b-c0d5-4d3b-b10d-2143157dbf9a\"},\"root_ids\":[\"p2167\"],\"notebook_comms_target\":\"p2220\"}];\n void root.Bokeh.embed.embed_items_notebook(docs_json, render_items);\n }\n if (root.Bokeh !== undefined) {\n embed_document(root);\n } else {\n let attempts = 0;\n const timer = setInterval(function(root) {\n if (root.Bokeh !== undefined) {\n clearInterval(timer);\n embed_document(root);\n } else {\n attempts++;\n if (attempts > 100) {\n clearInterval(timer);\n console.log(\"Bokeh: ERROR: Unable to run BokehJS code because BokehJS library is missing\");\n }\n }\n }, 10, root)\n }\n})(window);", "application/vnd.bokehjs_exec.v0+json": "" }, "metadata": { "application/vnd.bokehjs_exec.v0+json": { "id": "p2167" } }, "output_type": "display_data" } ], "source": [ "inspector.plot_networks()" ] }, { "attachments": {}, "cell_type": "markdown", "id": "c589c08a", "metadata": {}, "source": [ "## Finding neighbors and shared locations" ] }, { "attachments": {}, "cell_type": "markdown", "id": "d6df0a8d", "metadata": {}, "source": [ "From the perspective of an agent, it is very important to know with whom the agent is connected in the network.\n", "As Pop2net works with bipartite networks, technically agents are only connected with locations.\n", "As you might already know, agents can access all connected locations via `agent.locations`:" ] }, { "cell_type": "code", "execution_count": 45, "id": "7bce25cc", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "LocationList (3 objects)" ] }, "execution_count": 45, "metadata": {}, "output_type": "execute_result" } ], "source": [ "agent.locations" ] }, { "attachments": {}, "cell_type": "markdown", "id": "a7b58d88", "metadata": {}, "source": [ "As locations are mainly a helping tool to connect agents, we often want to know which other agents are connected to the same locations.\n", "Every agent can access those other agents who are at the same location via `agent.neighbors()`:" ] }, { "cell_type": "code", "execution_count": 46, "id": "86805136", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "AgentList (3 objects)" ] }, "execution_count": 46, "metadata": {}, "output_type": "execute_result" } ], "source": [ "agent.neighbors()" ] }, { "attachments": {}, "cell_type": "markdown", "id": "c53237c3", "metadata": {}, "source": [ "If we want to find only those *neighbors* who share a specific type of location with the agent, we can use the argument `location_labels` to filter by types of locations.\n", "In the following we only want *neighbors* who share a location of the type `School` with the agent:" ] }, { "cell_type": "code", "execution_count": 47, "id": "382fdaf6", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "AgentList (1 object)" ] }, "execution_count": 47, "metadata": {}, "output_type": "execute_result" } ], "source": [ "agent.neighbors(location_labels=[\"School\"])" ] }, { "attachments": {}, "cell_type": "markdown", "id": "ce5bdaec", "metadata": {}, "source": [ "By using different types of locations we can organize the relations of an agent to other agents and then access *neighbors* with a certain relation to the agent as we just did it above." ] }, { "attachments": {}, "cell_type": "markdown", "id": "eff31d09", "metadata": {}, "source": [ "Sometimes we need to access all the locations an agent shares with another agent.\n", "This can be done using `agent.shared_locations()`:" ] }, { "cell_type": "code", "execution_count": 48, "id": "cfc34c05", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "LocationList (3 objects)" ] }, "execution_count": 48, "metadata": {}, "output_type": "execute_result" } ], "source": [ "agent2 = model.agents[1]\n", "\n", "agent.shared_locations(agent2)" ] }, { "attachments": {}, "cell_type": "markdown", "id": "b68f36f2", "metadata": {}, "source": [ "`Agent.shared_locations()` also has the argument `location_labels` to filter by the type of the location:" ] }, { "cell_type": "code", "execution_count": 49, "id": "9f88013a", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[World (Obj 9)]" ] }, "execution_count": 49, "metadata": {}, "output_type": "execute_result" } ], "source": [ "agent.shared_locations(agent2, location_labels=[\"World\"])" ] }, { "cell_type": "code", "execution_count": 50, "id": "ce820499", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[School (Obj 8)]" ] }, "execution_count": 50, "metadata": {}, "output_type": "execute_result" } ], "source": [ "agent.shared_locations(agent2, location_labels=[\"School\"])" ] } ], "metadata": { "kernelspec": { "display_name": ".venv", "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.13.2" } }, "nbformat": 4, "nbformat_minor": 5 }