5.7 Network Graph
1. Network
Networks help us visualize relationships between people and items. For example, a simple network can show you how people are related to each other. This is illustrated for you in the following diagram.
We can see Helen and Marius used to date but Helen is with Jonas, while Jonas and Marius are siblings. Marius and Ben are friends but Ben has no connection with Jonas.

Bokeh supports for creating network graph visualizations with configurable interactions between edges and nodes. One way is to connect two nodes with default straight lines, the other is to connect these networks by defining a shape for the path that we choose.
2. Edge and Node Renderers
The key feature of the GraphRenderer is that it maintains separate sub-GlyphRenderers for the graph nodes and the graph edges. This allows for customizing the nodes by modifying the GraphRenderer’s node_rendererproperty.
3. Basic Network Graph

4. NetworkX: Zachary’s Karate Club graph

5. NetworkX
The easiest way to plot network graphs with Bokeh is to use thefrom_networkxfunction. The example below shows a Bokeh plot ofnx.desargues_graph(), setting some of the node and edge properties.

Adding Extra Data Columns

6. Inspection and Selection
It’s possible to configure the selection or inspection behavior of graphs by setting the GraphRenderer’s selection_policy and inspection_policy attributes. These policy attributes accept a specialGraphHitTestPolicymodel instance.
For example, settingselection_policy=NodesAndLinkedEdges() will cause a selected node to also select the associated edges. Similarly, settinginspection_policy=EdgesAndLinkedNodes()will cause the start and end nodes of an edge to also be inspected upon hovering an edge with the HoverTool.

Last updated
Was this helpful?