Visualizing networks with straight paths

The first step is to import the required packages:

import mathfrom bokeh.io import show, output_filefrom bokeh.plotting import figurefrom bokeh.models import GraphRenderer, StaticLayoutProvider, Ovalfrom bokeh.palettes import Spectral10

The packages that are new here are math, GraphRenderer, StaticLayoutProvider, Oval, and Spectral10. As we progress into building our very own network, you will see why and when the following packages are used. 

In this example, we are going to build a network with 10 nodes. Let's construct a list from 0 to 9, which we can use as the points of the nodes in our network. This is illustrated for you in the code shown here:

total_nodes = 10node_points = list(range(total_nodes)) ...

Get Hands-On Data Visualization with Bokeh now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.