{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "%load_ext autoreload\n", "%autoreload 2" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Tutorial" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "A hands-on tutorial is always better than just scanning API documentations (especially for a visualization library). We will therefore explain the workings of this package on some examples." ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "import networkx as nx\n", "from bokehgraph import BokehGraph" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## A simple unipartite graph\n", "\n", "The simplest example is probably the well known karate club graph.\n", "\n", "A (almost) minimal working example is this. We use, however, an optional line for `plot.layout(seed=42)`, just to make the documentation reproducible. If you want, you can safely omit this line but will get a different layout everytime.\n", "\n", "The default layout for unipartite graphs is `nx.spring_layout`." ] }, { "cell_type": "code", "execution_count": 3, "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.6.3.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-gl-3.6.3.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-3.6.3.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-3.6.3.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-mathjax-3.6.3.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 = {\"55a21a5f-5da5-4bd8-bd89-b4dfbc374d9c\":{\"version\":\"3.6.3\",\"title\":\"Bokeh Application\",\"roots\":[{\"type\":\"object\",\"name\":\"Figure\",\"id\":\"p1001\",\"attributes\":{\"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\":[[0,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"DqR/v9CMpL8ebcgSVafXPw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[1,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"G2i+Ffr/wb9aUKusJX7LPw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[2,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"cCFcIjIksL9Q1Vv7p2WlPw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[3,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"TQyHPhqV0b+lJK8G9/vRPw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[4,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"H59XAvrawT8NcYPqDXHjPw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[5,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"ApMly6OnxD9dBDSSSAvoPw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[6,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"pVf1QpQKsT9ky5bUSLvoPw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[7,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"hGecB42t0L8u/lxNUtLHPw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[8,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"bEZHWn5/rb+zLvTUBsq7vw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[9,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"XU5thmjkvb96y/k5d+Levw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[10,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"JJyDZyl90T9wpvaC4IrkPw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[11,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"hQggPPZazr8IkTreLabmPw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[12,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"dywW0+0f4L+7tlxfBr3cPw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[13,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"8TJaR7OLwr862+eLVmiyPw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[14,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"XsyNudZNr7+jONjbEfvlvw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[15,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"tS9rnBezyL8rgmPyAiThvw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[16,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"Fb2QcDINyj/////////vPw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[17,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"S8wIiUXjwr/Bd9HGuIrjPw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[18,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"WBppH638sz9YtP/T837ovw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[19,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"mJsDmmIBvT8dFPDzcxXHPw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[20,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"NHwuWHgiz7+IU55Vsuvlvw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[21,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"+wd67eWv079SkZK9ZWLfPw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[22,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"t/UfN0Yt07/A5ab7CjTdvw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[23,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"zqLJUH7Lxz9VIvARAkLcvw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[24,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"faqGJ7bo3z8i9rPwKObRvw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[25,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"FCIcOsES1j+BQHfRBV3Wvw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[26,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"wkDHvqdG2T9F+RHNRjrhvw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[27,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"xuEiVKcPzj9jTV2z8yvRvw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[28,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"xicKohkYyz+UfH28WIuvvw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[29,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"/LRaTxNIyT8Txe+k+pLivw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[30,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"NdAaU+pRxr+XyzEyIp3Ivw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[31,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"d2n3jDOPxj/JWupJYArIvw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[32,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"9KxrC8E1m7+An4kA0HTavw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[33,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"YIzccHBRiT/plDUmKAHWvw==\"},\"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\":[[\"club\",[\"Mr. Hi\",\"Mr. Hi\",\"Mr. Hi\",\"Mr. Hi\",\"Mr. Hi\",\"Mr. Hi\",\"Mr. Hi\",\"Mr. Hi\",\"Mr. Hi\",\"Officer\",\"Mr. Hi\",\"Mr. Hi\",\"Mr. Hi\",\"Mr. Hi\",\"Officer\",\"Officer\",\"Mr. Hi\",\"Mr. Hi\",\"Officer\",\"Mr. Hi\",\"Officer\",\"Mr. Hi\",\"Officer\",\"Officer\",\"Officer\",\"Officer\",\"Officer\",\"Officer\",\"Officer\",\"Officer\",\"Officer\",\"Officer\",\"Officer\",\"Officer\"]],[\"index\",[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33]],[\"_marker\",[\"circle\",\"circle\",\"circle\",\"circle\",\"circle\",\"circle\",\"circle\",\"circle\",\"circle\",\"circle\",\"circle\",\"circle\",\"circle\",\"circle\",\"circle\",\"circle\",\"circle\",\"circle\",\"circle\",\"circle\",\"circle\",\"circle\",\"circle\",\"circle\",\"circle\",\"circle\",\"circle\",\"circle\",\"circle\",\"circle\",\"circle\",\"circle\",\"circle\",\"circle\"]],[\"_color\",[\"firebrick\",\"firebrick\",\"firebrick\",\"firebrick\",\"firebrick\",\"firebrick\",\"firebrick\",\"firebrick\",\"firebrick\",\"firebrick\",\"firebrick\",\"firebrick\",\"firebrick\",\"firebrick\",\"firebrick\",\"firebrick\",\"firebrick\",\"firebrick\",\"firebrick\",\"firebrick\",\"firebrick\",\"firebrick\",\"firebrick\",\"firebrick\",\"firebrick\",\"firebrick\",\"firebrick\",\"firebrick\",\"firebrick\",\"firebrick\",\"firebrick\",\"firebrick\",\"firebrick\",\"firebrick\"]],[\"_alpha\",[0.9,0.9,0.9,0.9,0.9,0.9,0.9,0.9,0.9,0.9,0.9,0.9,0.9,0.9,0.9,0.9,0.9,0.9,0.9,0.9,0.9,0.9,0.9,0.9,0.9,0.9,0.9,0.9,0.9,0.9,0.9,0.9,0.9,0.9]],[\"_size\",[12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12]],[\"start_display\",[\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\"]],[\"end_display\",[\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\"]],[\"weight_display\",[\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\"]],[\"index_display\",[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]],[\"club_display\",[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]]]}}},\"view\":{\"type\":\"object\",\"name\":\"CDSView\",\"id\":\"p1039\",\"attributes\":{\"filter\":{\"type\":\"object\",\"name\":\"AllIndices\",\"id\":\"p1040\"}}},\"glyph\":{\"type\":\"object\",\"name\":\"Scatter\",\"id\":\"p1052\",\"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\":[[\"weight\",[4,5,3,3,3,3,2,2,2,3,1,3,2,2,2,2,6,3,4,5,1,2,2,2,3,4,5,1,3,2,2,2,3,3,3,2,3,5,3,3,3,3,3,4,2,3,3,2,3,4,1,2,1,3,1,2,3,5,4,3,5,4,2,3,2,7,4,2,4,2,2,4,2,3,3,4,4,5]],[\"start\",[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,3,3,3,4,4,5,5,5,6,8,8,8,9,13,14,14,15,15,18,18,19,20,20,22,22,23,23,23,23,23,24,24,24,25,26,26,27,28,28,29,29,30,30,31,31,32]],[\"end\",[1,2,3,4,5,6,7,8,10,11,12,13,17,19,21,31,2,3,7,13,17,19,21,30,3,7,8,9,13,27,28,32,7,12,13,6,10,6,10,16,16,30,32,33,33,33,32,33,32,33,32,33,33,32,33,32,33,25,27,29,32,33,25,27,31,31,29,33,33,31,33,32,33,32,33,32,33,33]],[\"_color\",[\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#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,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,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,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,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,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]],[\"end_display\",[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]],[\"weight_display\",[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]],[\"index_display\",[\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\"]],[\"club_display\",[\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\"]]]}}},\"view\":{\"type\":\"object\",\"name\":\"CDSView\",\"id\":\"p1046\",\"attributes\":{\"filter\":{\"type\":\"object\",\"name\":\"AllIndices\",\"id\":\"p1047\"}}},\"glyph\":{\"type\":\"object\",\"name\":\"MultiLine\",\"id\":\"p1051\",\"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\":\"p1048\"},\"inspection_policy\":{\"type\":\"object\",\"name\":\"NodesOnly\",\"id\":\"p1049\"}}}],\"toolbar\":{\"type\":\"object\",\"name\":\"Toolbar\",\"id\":\"p1009\",\"attributes\":{\"logo\":null,\"tools\":[{\"type\":\"object\",\"name\":\"BoxZoomTool\",\"id\":\"p1022\",\"attributes\":{\"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\":\"p1053\",\"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
weight:@weight
index:@index
club:@club
\",\"line_policy\":\"interp\"}}]}},\"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\":\"55a21a5f-5da5-4bd8-bd89-b4dfbc374d9c\",\"roots\":{\"p1001\":\"de4d498e-5557-40ac-a80e-d92c14686ff2\"},\"root_ids\":[\"p1001\"],\"notebook_comms_target\":\"p1054\"}];\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": [ "g = nx.karate_club_graph()\n", "\n", "plot = BokehGraph(g, hover_edges=True)\n", "plot.layout(seed=42)\n", "fig = plot.draw(return_figure=False)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## A simple bipartite graph\n", "\n", "NetworkX has not built-in subclass for bipartite networks. We can therefore not automatically detect whether or not a network is actually bipartite or not.\n", "To enable a bipartite visualization of a network, we can simply set `bipartite=1` during the initialization of the `BokehGraph` object.\n", "Make sure that all nodes have the bipartite attribute actually set to either 0 or 1 or you will encounter errors moving forward.\n" ] }, { "cell_type": "code", "execution_count": 4, "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.6.3.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-gl-3.6.3.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-3.6.3.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-3.6.3.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-mathjax-3.6.3.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 = {\"47d4fa9b-886a-4ae4-a99e-de033fb92070\":{\"version\":\"3.6.3\",\"title\":\"Bokeh Application\",\"roots\":[{\"type\":\"object\",\"name\":\"Figure\",\"id\":\"p1089\",\"attributes\":{\"x_range\":{\"type\":\"object\",\"name\":\"DataRange1d\",\"id\":\"p1090\"},\"y_range\":{\"type\":\"object\",\"name\":\"DataRange1d\",\"id\":\"p1091\"},\"x_scale\":{\"type\":\"object\",\"name\":\"LinearScale\",\"id\":\"p1098\"},\"y_scale\":{\"type\":\"object\",\"name\":\"LinearScale\",\"id\":\"p1099\"},\"title\":{\"type\":\"object\",\"name\":\"Title\",\"id\":\"p1096\"},\"renderers\":[{\"type\":\"object\",\"name\":\"GraphRenderer\",\"id\":\"p1121\",\"attributes\":{\"layout_provider\":{\"type\":\"object\",\"name\":\"StaticLayoutProvider\",\"id\":\"p1138\",\"attributes\":{\"graph_layout\":{\"type\":\"map\",\"entries\":[[1,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"AAAAAAAA6L8AAAAAAADwvw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[2,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"AAAAAAAA6D8AAAAAAADwvw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[3,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"AAAAAAAA6L8AAAAAAADwPw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[4,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"AAAAAAAA6D8AAAAAAADwPw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}]]}}},\"node_renderer\":{\"type\":\"object\",\"name\":\"GlyphRenderer\",\"id\":\"p1126\",\"attributes\":{\"data_source\":{\"type\":\"object\",\"name\":\"ColumnDataSource\",\"id\":\"p1123\",\"attributes\":{\"selected\":{\"type\":\"object\",\"name\":\"Selection\",\"id\":\"p1124\",\"attributes\":{\"indices\":[],\"line_indices\":[]}},\"selection_policy\":{\"type\":\"object\",\"name\":\"UnionRenderers\",\"id\":\"p1125\"},\"data\":{\"type\":\"map\",\"entries\":[[\"gender\",[null,null,\"m\",\"w\"]],[\"bipartite\",[0,0,1,1]],[\"index\",[1,2,3,4]],[\"_marker\",[\"circle\",\"circle\",\"square\",\"square\"]],[\"_color\",[\"firebrick\",\"firebrick\",\"steelblue\",\"steelblue\"]],[\"_alpha\",[0.9,0.9,0.9,0.9]],[\"_size\",[19,19,19,19]],[\"start_display\",[\"none\",\"none\",\"none\",\"none\"]],[\"end_display\",[\"none\",\"none\",\"none\",\"none\"]],[\"index_display\",[1,1,1,1]],[\"gender_display\",[\"none\",\"none\",1,1]]]}}},\"view\":{\"type\":\"object\",\"name\":\"CDSView\",\"id\":\"p1127\",\"attributes\":{\"filter\":{\"type\":\"object\",\"name\":\"AllIndices\",\"id\":\"p1128\"}}},\"glyph\":{\"type\":\"object\",\"name\":\"Scatter\",\"id\":\"p1140\",\"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\":\"p1133\",\"attributes\":{\"data_source\":{\"type\":\"object\",\"name\":\"ColumnDataSource\",\"id\":\"p1130\",\"attributes\":{\"selected\":{\"type\":\"object\",\"name\":\"Selection\",\"id\":\"p1131\",\"attributes\":{\"indices\":[],\"line_indices\":[]}},\"selection_policy\":{\"type\":\"object\",\"name\":\"UnionRenderers\",\"id\":\"p1132\"},\"data\":{\"type\":\"map\",\"entries\":[[\"start\",[1,1,2,2]],[\"end\",[3,4,3,4]],[\"_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]],[\"index_display\",[\"none\",\"none\",\"none\",\"none\"]],[\"gender_display\",[\"none\",\"none\",\"none\",\"none\"]]]}}},\"view\":{\"type\":\"object\",\"name\":\"CDSView\",\"id\":\"p1134\",\"attributes\":{\"filter\":{\"type\":\"object\",\"name\":\"AllIndices\",\"id\":\"p1135\"}}},\"glyph\":{\"type\":\"object\",\"name\":\"MultiLine\",\"id\":\"p1139\",\"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\":\"p1136\"},\"inspection_policy\":{\"type\":\"object\",\"name\":\"NodesOnly\",\"id\":\"p1137\"}}}],\"toolbar\":{\"type\":\"object\",\"name\":\"Toolbar\",\"id\":\"p1097\",\"attributes\":{\"logo\":null,\"tools\":[{\"type\":\"object\",\"name\":\"BoxZoomTool\",\"id\":\"p1110\",\"attributes\":{\"overlay\":{\"type\":\"object\",\"name\":\"BoxAnnotation\",\"id\":\"p1111\",\"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\":\"p1117\",\"attributes\":{\"all\":{\"type\":\"object\",\"name\":\"AreaVisuals\",\"id\":\"p1116\",\"attributes\":{\"fill_color\":\"white\",\"hover_fill_color\":\"lightgray\"}}}}}}}},{\"type\":\"object\",\"name\":\"ResetTool\",\"id\":\"p1118\"},{\"type\":\"object\",\"name\":\"WheelZoomTool\",\"id\":\"p1119\",\"attributes\":{\"renderers\":\"auto\"}},{\"type\":\"object\",\"name\":\"PanTool\",\"id\":\"p1120\"},{\"type\":\"object\",\"name\":\"HoverTool\",\"id\":\"p1141\",\"attributes\":{\"renderers\":[{\"id\":\"p1133\"},{\"id\":\"p1126\"}],\"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
gender:@gender
\",\"line_policy\":\"interp\"}}]}},\"left\":[{\"type\":\"object\",\"name\":\"LinearAxis\",\"id\":\"p1105\",\"attributes\":{\"visible\":false,\"ticker\":{\"type\":\"object\",\"name\":\"BasicTicker\",\"id\":\"p1106\",\"attributes\":{\"mantissas\":[1,2,5]}},\"formatter\":{\"type\":\"object\",\"name\":\"BasicTickFormatter\",\"id\":\"p1107\"},\"major_label_policy\":{\"type\":\"object\",\"name\":\"AllLabels\",\"id\":\"p1108\"}}}],\"below\":[{\"type\":\"object\",\"name\":\"LinearAxis\",\"id\":\"p1100\",\"attributes\":{\"visible\":false,\"ticker\":{\"type\":\"object\",\"name\":\"BasicTicker\",\"id\":\"p1101\",\"attributes\":{\"mantissas\":[1,2,5]}},\"formatter\":{\"type\":\"object\",\"name\":\"BasicTickFormatter\",\"id\":\"p1102\"},\"major_label_policy\":{\"type\":\"object\",\"name\":\"AllLabels\",\"id\":\"p1103\"}}}],\"center\":[{\"type\":\"object\",\"name\":\"Grid\",\"id\":\"p1104\",\"attributes\":{\"axis\":{\"id\":\"p1100\"},\"grid_line_color\":null}},{\"type\":\"object\",\"name\":\"Grid\",\"id\":\"p1109\",\"attributes\":{\"dimension\":1,\"axis\":{\"id\":\"p1105\"},\"grid_line_color\":null}}]}}]}};\n const render_items = [{\"docid\":\"47d4fa9b-886a-4ae4-a99e-de033fb92070\",\"roots\":{\"p1089\":\"c5c05748-8837-412b-af34-e219d3867dfc\"},\"root_ids\":[\"p1089\"],\"notebook_comms_target\":\"p1142\"}];\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": "p1089" } }, "output_type": "display_data" } ], "source": [ "g = nx.Graph()\n", "g.add_node(1, bipartite=0)\n", "g.add_node(2, bipartite=0)\n", "g.add_node(3, bipartite=1, gender=\"m\")\n", "g.add_node(4, bipartite=1, gender=\"w\")\n", "g.add_edge(1, 3)\n", "g.add_edge(1, 4)\n", "g.add_edge(2, 3)\n", "g.add_edge(2, 4)\n", "\n", "plot = BokehGraph(\n", " g,\n", " hover_edges=True,\n", " bipartite=True,\n", ")\n", "plot.layout(seed=42)\n", "plot.draw(node_size=19)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Setting parameters in BokehGraph.draw \n", "\n", "To set parameters to modify the visualization, all parameters starting with `node_` can be set to either 1 or 2 values. The purpose is to allow parameters to be set separately for level 0 and level 1 of bipartite graphs. Since edges are not split into multiple levels, this \n", "\n", "If only on parameter is set in a bipartite graph, it will be used for both levels.\n", "\n", "If 2 parameters are set for a unipartite graph, only the first parameter will be used and the latter one will be ignored.\n", "\n", "Most parameters can be set to either a node/edge attribute or to a specific value. If it is set to a node/edge attribute the nodes/edges will be colored accordingly. In this example `firebrick` is not a node attribute but a predefined color of bokeh, so all nodes on level 0 have the same color but level 1 nodes are colored by the node attribute `housing_type`." ] }, { "cell_type": "code", "execution_count": 5, "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.6.3.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-gl-3.6.3.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-3.6.3.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-3.6.3.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-mathjax-3.6.3.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 = {\"59709ed1-bbe4-4318-8a5e-f44c4fe3058d\":{\"version\":\"3.6.3\",\"title\":\"Bokeh Application\",\"roots\":[{\"type\":\"object\",\"name\":\"Figure\",\"id\":\"p1147\",\"attributes\":{\"x_range\":{\"type\":\"object\",\"name\":\"DataRange1d\",\"id\":\"p1148\"},\"y_range\":{\"type\":\"object\",\"name\":\"DataRange1d\",\"id\":\"p1149\"},\"x_scale\":{\"type\":\"object\",\"name\":\"LinearScale\",\"id\":\"p1156\"},\"y_scale\":{\"type\":\"object\",\"name\":\"LinearScale\",\"id\":\"p1157\"},\"title\":{\"type\":\"object\",\"name\":\"Title\",\"id\":\"p1154\"},\"renderers\":[{\"type\":\"object\",\"name\":\"GraphRenderer\",\"id\":\"p1179\",\"attributes\":{\"layout_provider\":{\"type\":\"object\",\"name\":\"StaticLayoutProvider\",\"id\":\"p1196\",\"attributes\":{\"graph_layout\":{\"type\":\"map\",\"entries\":[[1,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"AAAAAAAA6L8AAAAAAADwvw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[2,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"AAAAAAAA6D8AAAAAAADwvw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[3,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"AAAAAAAA6L8AAAAAAADwPw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[4,{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"AAAAAAAA6D8AAAAAAADwPw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}]]}}},\"node_renderer\":{\"type\":\"object\",\"name\":\"GlyphRenderer\",\"id\":\"p1184\",\"attributes\":{\"data_source\":{\"type\":\"object\",\"name\":\"ColumnDataSource\",\"id\":\"p1181\",\"attributes\":{\"selected\":{\"type\":\"object\",\"name\":\"Selection\",\"id\":\"p1182\",\"attributes\":{\"indices\":[],\"line_indices\":[]}},\"selection_policy\":{\"type\":\"object\",\"name\":\"UnionRenderers\",\"id\":\"p1183\"},\"data\":{\"type\":\"map\",\"entries\":[[\"housing_type\",[null,null,\"castle\",\"house\"]],[\"gender\",[\"female\",\"male\",null,null]],[\"bipartite\",[0,0,1,1]],[\"index\",[1,2,3,4]],[\"_marker\",[\"circle\",\"circle\",\"square\",\"square\"]],[\"_color\",[\"firebrick\",\"firebrick\",\"#1f77b4\",\"#ff7f0e\"]],[\"_alpha\",[0.9,0.9,0.9,0.9]],[\"_size\",[19,19,25,25]],[\"index_display\",[1,1,1,1]],[\"housing_type_display\",[\"none\",\"none\",1,1]],[\"gender_display\",[1,1,\"none\",\"none\"]]]}}},\"view\":{\"type\":\"object\",\"name\":\"CDSView\",\"id\":\"p1185\",\"attributes\":{\"filter\":{\"type\":\"object\",\"name\":\"AllIndices\",\"id\":\"p1186\"}}},\"glyph\":{\"type\":\"object\",\"name\":\"Scatter\",\"id\":\"p1198\",\"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\":\"p1191\",\"attributes\":{\"data_source\":{\"type\":\"object\",\"name\":\"ColumnDataSource\",\"id\":\"p1188\",\"attributes\":{\"selected\":{\"type\":\"object\",\"name\":\"Selection\",\"id\":\"p1189\",\"attributes\":{\"indices\":[],\"line_indices\":[]}},\"selection_policy\":{\"type\":\"object\",\"name\":\"UnionRenderers\",\"id\":\"p1190\"},\"data\":{\"type\":\"map\",\"entries\":[[\"start\",[1,1,2,2]],[\"end\",[3,4,3,4]],[\"_color\",[\"#440154\",\"#440154\",\"#440154\",\"#440154\"]],[\"_alpha\",[1.0,1.0,1.0,1.0]],[\"_size\",[1.0,1.0,1.0,1.0]],[\"index_display\",[\"none\",\"none\",\"none\",\"none\"]],[\"housing_type_display\",[\"none\",\"none\",\"none\",\"none\"]],[\"gender_display\",[\"none\",\"none\",\"none\",\"none\"]]]}}},\"view\":{\"type\":\"object\",\"name\":\"CDSView\",\"id\":\"p1192\",\"attributes\":{\"filter\":{\"type\":\"object\",\"name\":\"AllIndices\",\"id\":\"p1193\"}}},\"glyph\":{\"type\":\"object\",\"name\":\"MultiLine\",\"id\":\"p1197\",\"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\":\"p1194\"},\"inspection_policy\":{\"type\":\"object\",\"name\":\"NodesOnly\",\"id\":\"p1195\"}}}],\"toolbar\":{\"type\":\"object\",\"name\":\"Toolbar\",\"id\":\"p1155\",\"attributes\":{\"logo\":null,\"tools\":[{\"type\":\"object\",\"name\":\"BoxZoomTool\",\"id\":\"p1168\",\"attributes\":{\"overlay\":{\"type\":\"object\",\"name\":\"BoxAnnotation\",\"id\":\"p1169\",\"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\":\"p1175\",\"attributes\":{\"all\":{\"type\":\"object\",\"name\":\"AreaVisuals\",\"id\":\"p1174\",\"attributes\":{\"fill_color\":\"white\",\"hover_fill_color\":\"lightgray\"}}}}}}}},{\"type\":\"object\",\"name\":\"ResetTool\",\"id\":\"p1176\"},{\"type\":\"object\",\"name\":\"WheelZoomTool\",\"id\":\"p1177\",\"attributes\":{\"renderers\":\"auto\"}},{\"type\":\"object\",\"name\":\"PanTool\",\"id\":\"p1178\"},{\"type\":\"object\",\"name\":\"HoverTool\",\"id\":\"p1199\",\"attributes\":{\"renderers\":[{\"id\":\"p1184\"}],\"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
index:@index
housing_type:@housing_type
gender:@gender
\",\"line_policy\":\"interp\"}}]}},\"left\":[{\"type\":\"object\",\"name\":\"LinearAxis\",\"id\":\"p1163\",\"attributes\":{\"visible\":false,\"ticker\":{\"type\":\"object\",\"name\":\"BasicTicker\",\"id\":\"p1164\",\"attributes\":{\"mantissas\":[1,2,5]}},\"formatter\":{\"type\":\"object\",\"name\":\"BasicTickFormatter\",\"id\":\"p1165\"},\"major_label_policy\":{\"type\":\"object\",\"name\":\"AllLabels\",\"id\":\"p1166\"}}}],\"below\":[{\"type\":\"object\",\"name\":\"LinearAxis\",\"id\":\"p1158\",\"attributes\":{\"visible\":false,\"ticker\":{\"type\":\"object\",\"name\":\"BasicTicker\",\"id\":\"p1159\",\"attributes\":{\"mantissas\":[1,2,5]}},\"formatter\":{\"type\":\"object\",\"name\":\"BasicTickFormatter\",\"id\":\"p1160\"},\"major_label_policy\":{\"type\":\"object\",\"name\":\"AllLabels\",\"id\":\"p1161\"}}}],\"center\":[{\"type\":\"object\",\"name\":\"Grid\",\"id\":\"p1162\",\"attributes\":{\"axis\":{\"id\":\"p1158\"},\"grid_line_color\":null}},{\"type\":\"object\",\"name\":\"Grid\",\"id\":\"p1167\",\"attributes\":{\"dimension\":1,\"axis\":{\"id\":\"p1163\"},\"grid_line_color\":null}}]}}]}};\n const render_items = [{\"docid\":\"59709ed1-bbe4-4318-8a5e-f44c4fe3058d\",\"roots\":{\"p1147\":\"a0023917-4895-4dbf-89f6-4a1e5ba4099d\"},\"root_ids\":[\"p1147\"],\"notebook_comms_target\":\"p1200\"}];\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": "p1147" } }, "output_type": "display_data" } ], "source": [ "g = nx.Graph()\n", "g.add_node(1, bipartite=0, gender=\"female\")\n", "g.add_node(2, bipartite=0, gender=\"male\")\n", "g.add_node(3, bipartite=1, housing_type=\"castle\")\n", "g.add_node(4, bipartite=1, housing_type=\"house\")\n", "g.add_edge(1, 3)\n", "g.add_edge(1, 4)\n", "g.add_edge(2, 3)\n", "g.add_edge(2, 4)\n", "\n", "plot = BokehGraph(\n", " g,\n", " bipartite=True,\n", ")\n", "plot.layout(seed=42)\n", "plot.draw(\n", " node_size=(19, 25),\n", " node_color=(\"firebrick\", \"housing_type\"),\n", ")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## A more complex example to showcase some features" ] }, { "cell_type": "code", "execution_count": 6, "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.6.3.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-gl-3.6.3.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-3.6.3.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-3.6.3.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-mathjax-3.6.3.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 = {\"5292afdc-08ac-4acc-a6f8-e99a0f0d7c94\":{\"version\":\"3.6.3\",\"title\":\"Bokeh Application\",\"roots\":[{\"type\":\"object\",\"name\":\"Figure\",\"id\":\"p1205\",\"attributes\":{\"width\":700,\"height\":800,\"x_range\":{\"type\":\"object\",\"name\":\"DataRange1d\",\"id\":\"p1206\"},\"y_range\":{\"type\":\"object\",\"name\":\"DataRange1d\",\"id\":\"p1207\"},\"x_scale\":{\"type\":\"object\",\"name\":\"LinearScale\",\"id\":\"p1214\"},\"y_scale\":{\"type\":\"object\",\"name\":\"LinearScale\",\"id\":\"p1215\"},\"title\":{\"type\":\"object\",\"name\":\"Title\",\"id\":\"p1212\"},\"renderers\":[{\"type\":\"object\",\"name\":\"GraphRenderer\",\"id\":\"p1237\",\"attributes\":{\"layout_provider\":{\"type\":\"object\",\"name\":\"StaticLayoutProvider\",\"id\":\"p1254\",\"attributes\":{\"graph_layout\":{\"type\":\"map\",\"entries\":[[\"Evelyn Jefferson\",{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"JpxnwtxV4L8XKISbrYeDPw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[\"Laura Mandeville\",{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"1hzmZ5bz4r/O3joX3kq1vw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[\"Theresa Anderson\",{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"AbIWQgnq2r/9Tefbiaa8Pw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[\"Brenda Rogers\",{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"z7u86ROv47/UC69WIHq8Pw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[\"Charlotte McDowd\",{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"tJdEC5DV5r8+8bY8XJfgPw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[\"Frances Anderson\",{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"KXDJbQiV2L+ejd9+HKLdPw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[\"Eleanor Nye\",{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"2oYGKBEYyr+BgFqYvwrYPw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[\"Pearl Oglethorpe\",{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"wVyc0sCBub9NR7Q26+jUvw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[\"Ruth DeSand\",{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"V7MAyTGqlL/43ZrGDcTaPw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[\"Verne Sanderson\",{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"EFVupJKixj+Ecof+gBDKvw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[\"Myra Liddel\",{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"mjFyU96R4z/89SOysYuyvw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[\"Katherina Rogers\",{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"IDt1auc13D+Y6KabO9Ldvw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[\"Sylvia Avondale\",{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"Ubw6g39B0z92aXhwTZ3Zvw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[\"Nora Fayette\",{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"NU9/hxjx2D8afdQZBLDQvw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[\"Helen Lloyd\",{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"+8fn03ty3j+EczG9mRB0Pw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[\"Dorothy Murchison\",{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"LlOhEkVJ1D8kuPon78DfPw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[\"Olivia Carleton\",{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"lH46O/em6D+YmxuEi4zdPw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[\"Flora Price\",{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"61dv03WH7T/nbUPuTyvVPw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[\"E1\",{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"AAAAAAAA8L8LIGPPsFC6vw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[\"E2\",{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"6Wy+WQ0r6r/B3h5NKHXRvw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[\"E3\",{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"7UsvPWw86L+GZFyRhn7SPw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[\"E4\",{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"rIPCSDK/7b9wqgvJWH/PPw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[\"E5\",{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"H+5bi6Ff4L+YFe5PDiTXPw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[\"E6\",{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"m5WL5Yvl0L/azukYXSqdvw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[\"E7\",{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"uebpQEZPv7+XBT/C8Z+vPw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[\"E8\",{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"vdqS84T9fL+ODsYk86mbPw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[\"E9\",{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"RsW5fC2Vzz8Q+tYGDkGxPw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[\"E10\",{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"v+cvRSoi6D8UrJbPPIPWvw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[\"E11\",{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"IwtAqfBm7D+TyaK8RRi4Pw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[\"E12\",{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"fnsnXnw84z9EcXzOMl7Wvw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[\"E13\",{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"f4yaJutV2z+PW1vk4sXpvw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}],[\"E14\",{\"type\":\"ndarray\",\"array\":{\"type\":\"bytes\",\"data\":\"YLSLoTy15D9qOeE1XzLnvw==\"},\"shape\":[2],\"dtype\":\"float64\",\"order\":\"little\"}]]}}},\"node_renderer\":{\"type\":\"object\",\"name\":\"GlyphRenderer\",\"id\":\"p1242\",\"attributes\":{\"data_source\":{\"type\":\"object\",\"name\":\"ColumnDataSource\",\"id\":\"p1239\",\"attributes\":{\"selected\":{\"type\":\"object\",\"name\":\"Selection\",\"id\":\"p1240\",\"attributes\":{\"indices\":[],\"line_indices\":[]}},\"selection_policy\":{\"type\":\"object\",\"name\":\"UnionRenderers\",\"id\":\"p1241\"},\"data\":{\"type\":\"map\",\"entries\":[[\"betweenness\",[0.09658472108029267,0.05135761326872536,0.08759468547944677,0.0494865998160072,0.010596096282664414,0.01071434286960598,0.00944412334473028,0.006800323334013807,0.016783108139791406,0.015737665757646964,0.016344348365012626,0.047362754029819695,0.07170914508501829,0.11346136204298476,0.04238754006434827,0.0019535268594996565,0.005054505236263333,0.005054505236263333,0.002154310782629367,0.0020886968954039286,0.01822439085252718,0.0077020526738029406,0.03769444252500667,0.06501635047516072,0.12950174424519842,0.24381946234957552,0.22551359177204106,0.011442302600971925,0.01966539088919154,0.018094182051395145,0.002240655987795576,0.002240655987795576]],[\"bipartite\",[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1]],[\"index\",[\"Evelyn Jefferson\",\"Laura Mandeville\",\"Theresa Anderson\",\"Brenda Rogers\",\"Charlotte McDowd\",\"Frances Anderson\",\"Eleanor Nye\",\"Pearl Oglethorpe\",\"Ruth DeSand\",\"Verne Sanderson\",\"Myra Liddel\",\"Katherina Rogers\",\"Sylvia Avondale\",\"Nora Fayette\",\"Helen Lloyd\",\"Dorothy Murchison\",\"Olivia Carleton\",\"Flora Price\",\"E1\",\"E2\",\"E3\",\"E4\",\"E5\",\"E6\",\"E7\",\"E8\",\"E9\",\"E10\",\"E11\",\"E12\",\"E13\",\"E14\"]],[\"_marker\",[\"hex\",\"hex\",\"hex\",\"hex\",\"hex\",\"hex\",\"hex\",\"hex\",\"hex\",\"hex\",\"hex\",\"hex\",\"hex\",\"hex\",\"hex\",\"hex\",\"hex\",\"hex\",\"inverted_triangle\",\"inverted_triangle\",\"inverted_triangle\",\"inverted_triangle\",\"inverted_triangle\",\"inverted_triangle\",\"inverted_triangle\",\"inverted_triangle\",\"inverted_triangle\",\"inverted_triangle\",\"inverted_triangle\",\"inverted_triangle\",\"inverted_triangle\",\"inverted_triangle\"]],[\"_color\",[\"#FBFCBF\",\"#B53679\",\"#FBFCBF\",\"#B53679\",\"#000003\",\"#000003\",\"#000003\",\"#000003\",\"#4F117B\",\"#4F117B\",\"#4F117B\",\"#B53679\",\"#FB8660\",\"#FBFCBF\",\"#B53679\",\"#000003\",\"#000003\",\"#000003\",\"steelblue\",\"steelblue\",\"steelblue\",\"steelblue\",\"steelblue\",\"steelblue\",\"steelblue\",\"steelblue\",\"steelblue\",\"steelblue\",\"steelblue\",\"steelblue\",\"steelblue\",\"steelblue\"]],[\"_alpha\",[0.9,0.9,0.9,0.9,0.9,0.9,0.9,0.9,0.9,0.9,0.9,0.9,0.9,0.9,0.9,0.9,0.9,0.9,0.9,0.9,0.9,0.9,0.9,0.9,0.9,0.9,0.9,0.9,0.9,0.9,0.9,0.9]],[\"_size\",[25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],[\"start_display\",[\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\"]],[\"end_display\",[\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\"]],[\"index_display\",[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]],[\"betweenness_display\",[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]]]}}},\"view\":{\"type\":\"object\",\"name\":\"CDSView\",\"id\":\"p1243\",\"attributes\":{\"filter\":{\"type\":\"object\",\"name\":\"AllIndices\",\"id\":\"p1244\"}}},\"glyph\":{\"type\":\"object\",\"name\":\"Scatter\",\"id\":\"p1256\",\"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\":\"p1249\",\"attributes\":{\"data_source\":{\"type\":\"object\",\"name\":\"ColumnDataSource\",\"id\":\"p1246\",\"attributes\":{\"selected\":{\"type\":\"object\",\"name\":\"Selection\",\"id\":\"p1247\",\"attributes\":{\"indices\":[],\"line_indices\":[]}},\"selection_policy\":{\"type\":\"object\",\"name\":\"UnionRenderers\",\"id\":\"p1248\"},\"data\":{\"type\":\"map\",\"entries\":[[\"start\",[\"Evelyn Jefferson\",\"Evelyn Jefferson\",\"Evelyn Jefferson\",\"Evelyn Jefferson\",\"Evelyn Jefferson\",\"Evelyn Jefferson\",\"Evelyn Jefferson\",\"Evelyn Jefferson\",\"Laura Mandeville\",\"Laura Mandeville\",\"Laura Mandeville\",\"Laura Mandeville\",\"Laura Mandeville\",\"Laura Mandeville\",\"Laura Mandeville\",\"Theresa Anderson\",\"Theresa Anderson\",\"Theresa Anderson\",\"Theresa Anderson\",\"Theresa Anderson\",\"Theresa Anderson\",\"Theresa Anderson\",\"Theresa Anderson\",\"Brenda Rogers\",\"Brenda Rogers\",\"Brenda Rogers\",\"Brenda Rogers\",\"Brenda Rogers\",\"Brenda Rogers\",\"Brenda Rogers\",\"Charlotte McDowd\",\"Charlotte McDowd\",\"Charlotte McDowd\",\"Charlotte McDowd\",\"Frances Anderson\",\"Frances Anderson\",\"Frances Anderson\",\"Frances Anderson\",\"Eleanor Nye\",\"Eleanor Nye\",\"Eleanor Nye\",\"Eleanor Nye\",\"Pearl Oglethorpe\",\"Pearl Oglethorpe\",\"Pearl Oglethorpe\",\"Ruth DeSand\",\"Ruth DeSand\",\"Ruth DeSand\",\"Ruth DeSand\",\"Verne Sanderson\",\"Verne Sanderson\",\"Verne Sanderson\",\"Verne Sanderson\",\"Myra Liddel\",\"Myra Liddel\",\"Myra Liddel\",\"Myra Liddel\",\"Katherina Rogers\",\"Katherina Rogers\",\"Katherina Rogers\",\"Katherina Rogers\",\"Katherina Rogers\",\"Katherina Rogers\",\"Sylvia Avondale\",\"Sylvia Avondale\",\"Sylvia Avondale\",\"Sylvia Avondale\",\"Sylvia Avondale\",\"Sylvia Avondale\",\"Sylvia Avondale\",\"Nora Fayette\",\"Nora Fayette\",\"Nora Fayette\",\"Nora Fayette\",\"Nora Fayette\",\"Nora Fayette\",\"Nora Fayette\",\"Nora Fayette\",\"Helen Lloyd\",\"Helen Lloyd\",\"Helen Lloyd\",\"Helen Lloyd\",\"Helen Lloyd\",\"Dorothy Murchison\",\"Dorothy Murchison\",\"Olivia Carleton\",\"Olivia Carleton\",\"Flora Price\",\"Flora Price\"]],[\"end\",[\"E1\",\"E2\",\"E3\",\"E4\",\"E5\",\"E6\",\"E8\",\"E9\",\"E1\",\"E2\",\"E3\",\"E5\",\"E6\",\"E7\",\"E8\",\"E2\",\"E3\",\"E4\",\"E5\",\"E6\",\"E7\",\"E8\",\"E9\",\"E1\",\"E3\",\"E4\",\"E5\",\"E6\",\"E7\",\"E8\",\"E3\",\"E4\",\"E5\",\"E7\",\"E3\",\"E5\",\"E6\",\"E8\",\"E5\",\"E6\",\"E7\",\"E8\",\"E6\",\"E8\",\"E9\",\"E5\",\"E7\",\"E8\",\"E9\",\"E7\",\"E8\",\"E9\",\"E12\",\"E8\",\"E9\",\"E10\",\"E12\",\"E8\",\"E9\",\"E10\",\"E12\",\"E13\",\"E14\",\"E7\",\"E8\",\"E9\",\"E10\",\"E12\",\"E13\",\"E14\",\"E6\",\"E7\",\"E9\",\"E10\",\"E11\",\"E12\",\"E13\",\"E14\",\"E7\",\"E8\",\"E10\",\"E11\",\"E12\",\"E8\",\"E9\",\"E9\",\"E11\",\"E9\",\"E11\"]],[\"_color\",[\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#440154\",\"#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,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,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,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,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,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]],[\"end_display\",[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]],[\"index_display\",[\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\"]],[\"betweenness_display\",[\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\",\"none\"]]]}}},\"view\":{\"type\":\"object\",\"name\":\"CDSView\",\"id\":\"p1250\",\"attributes\":{\"filter\":{\"type\":\"object\",\"name\":\"AllIndices\",\"id\":\"p1251\"}}},\"glyph\":{\"type\":\"object\",\"name\":\"MultiLine\",\"id\":\"p1255\",\"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\":\"p1252\"},\"inspection_policy\":{\"type\":\"object\",\"name\":\"NodesOnly\",\"id\":\"p1253\"}}}],\"toolbar\":{\"type\":\"object\",\"name\":\"Toolbar\",\"id\":\"p1213\",\"attributes\":{\"logo\":null,\"tools\":[{\"type\":\"object\",\"name\":\"BoxZoomTool\",\"id\":\"p1226\",\"attributes\":{\"overlay\":{\"type\":\"object\",\"name\":\"BoxAnnotation\",\"id\":\"p1227\",\"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\":\"p1233\",\"attributes\":{\"all\":{\"type\":\"object\",\"name\":\"AreaVisuals\",\"id\":\"p1232\",\"attributes\":{\"fill_color\":\"white\",\"hover_fill_color\":\"lightgray\"}}}}}}}},{\"type\":\"object\",\"name\":\"ResetTool\",\"id\":\"p1234\"},{\"type\":\"object\",\"name\":\"WheelZoomTool\",\"id\":\"p1235\",\"attributes\":{\"renderers\":\"auto\"}},{\"type\":\"object\",\"name\":\"PanTool\",\"id\":\"p1236\"},{\"type\":\"object\",\"name\":\"HoverTool\",\"id\":\"p1257\",\"attributes\":{\"renderers\":[{\"id\":\"p1249\"},{\"id\":\"p1242\"}],\"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
betweenness:@betweenness
\",\"line_policy\":\"interp\"}}]}},\"left\":[{\"type\":\"object\",\"name\":\"LinearAxis\",\"id\":\"p1221\",\"attributes\":{\"visible\":false,\"ticker\":{\"type\":\"object\",\"name\":\"BasicTicker\",\"id\":\"p1222\",\"attributes\":{\"mantissas\":[1,2,5]}},\"formatter\":{\"type\":\"object\",\"name\":\"BasicTickFormatter\",\"id\":\"p1223\"},\"major_label_policy\":{\"type\":\"object\",\"name\":\"AllLabels\",\"id\":\"p1224\"}}}],\"below\":[{\"type\":\"object\",\"name\":\"LinearAxis\",\"id\":\"p1216\",\"attributes\":{\"visible\":false,\"ticker\":{\"type\":\"object\",\"name\":\"BasicTicker\",\"id\":\"p1217\",\"attributes\":{\"mantissas\":[1,2,5]}},\"formatter\":{\"type\":\"object\",\"name\":\"BasicTickFormatter\",\"id\":\"p1218\"},\"major_label_policy\":{\"type\":\"object\",\"name\":\"AllLabels\",\"id\":\"p1219\"}}}],\"center\":[{\"type\":\"object\",\"name\":\"Grid\",\"id\":\"p1220\",\"attributes\":{\"axis\":{\"id\":\"p1216\"},\"grid_line_color\":null}},{\"type\":\"object\",\"name\":\"Grid\",\"id\":\"p1225\",\"attributes\":{\"dimension\":1,\"axis\":{\"id\":\"p1221\"},\"grid_line_color\":null}}]}}]}};\n const render_items = [{\"docid\":\"5292afdc-08ac-4acc-a6f8-e99a0f0d7c94\",\"roots\":{\"p1205\":\"bb6d17fe-33fa-4f68-be01-955fe22d2d7e\"},\"root_ids\":[\"p1205\"],\"notebook_comms_target\":\"p1258\"}];\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": "p1205" } }, "output_type": "display_data" } ], "source": [ "g = nx.davis_southern_women_graph()\n", "\n", "plot = BokehGraph(\n", " graph=g,\n", " width=700,\n", " height=800,\n", " inline=True,\n", " hover_edges=True,\n", " hover_nodes=True,\n", " bipartite=True,\n", ")\n", "\n", "betweenness = nx.bipartite.betweenness_centrality(\n", " g, nodes=(node for node, data in g.nodes(data=True) if data[\"bipartite\"] == 1)\n", ")\n", "nx.set_node_attributes(g, betweenness, \"betweenness\")\n", "\n", "layout = nx.spring_layout(g, seed=42)\n", "plot.layout(layout)\n", "plot.draw(\n", " node_marker=(\"hex\", \"inverted_triangle\"),\n", " node_color=(\"betweenness\", \"steelblue\"),\n", " node_palette=\"magma\",\n", " node_max_colors=5,\n", " node_size=(25, 30),\n", " edge_alpha=0.4,\n", ")" ] } ], "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": 2 }