#-----------------------------------------------------------------------------# Copyright (c) 2012 - 2022, Anaconda, Inc., and Bokeh Contributors.# All rights reserved.## The full license is in the file LICENSE.txt, distributed with this software.#-----------------------------------------------------------------------------#-----------------------------------------------------------------------------# Boilerplate#-----------------------------------------------------------------------------from__future__importannotationsimportlogging# isort:skiplog=logging.getLogger(__name__)#-----------------------------------------------------------------------------# Imports#-----------------------------------------------------------------------------# Bokeh importsfrom..core.has_propsimportabstractfrom..core.propertiesimport(Any,Dict,Either,Instance,Int,Seq,String,)from..modelimportModelfrom.expressionsimportCoordinateTransform#-----------------------------------------------------------------------------# Globals and constants#-----------------------------------------------------------------------------__all__=('EdgesAndLinkedNodes','EdgeCoordinates','EdgesOnly','GraphCoordinates','GraphHitTestPolicy','LayoutProvider','NodeCoordinates','NodesAndLinkedEdges','NodesOnly','StaticLayoutProvider',)#-----------------------------------------------------------------------------# General API#-----------------------------------------------------------------------------#-----------------------------------------------------------------------------# Dev API#-----------------------------------------------------------------------------
[docs]classStaticLayoutProvider(LayoutProvider):''' '''graph_layout=Dict(Either(String,Int),Seq(Any),default={},help=""" The coordinates of the graph nodes in cartesian space. The dictionary keys correspond to a node index and the values are a two element sequence containing the x and y coordinates of the node. .. code-block:: python { 0 : [0.5, 0.5], 1 : [1.0, 0.86], 2 : [0.86, 1], } """)
[docs]@abstractclassGraphCoordinates(CoordinateTransform):''' Abstract class for coordinate transform expression obtained from ``LayoutProvider`` '''layout=Instance(LayoutProvider)
[docs]classNodeCoordinates(GraphCoordinates):''' Node coordinate expression obtained from ``LayoutProvider`` '''pass
[docs]classEdgeCoordinates(GraphCoordinates):''' Node coordinate expression obtained from ``LayoutProvider`` '''pass
[docs]classEdgesOnly(GraphHitTestPolicy):''' With the ``EdgesOnly`` policy, only graph edges are able to be selected and inspected. There is no selection or inspection of graph nodes. '''pass
[docs]classNodesOnly(GraphHitTestPolicy):''' With the ``NodesOnly`` policy, only graph nodes are able to be selected and inspected. There is no selection or inspection of graph edges. '''pass
[docs]classNodesAndLinkedEdges(GraphHitTestPolicy):''' With the ``NodesAndLinkedEdges`` policy, inspection or selection of graph nodes will result in the inspection or selection of the node and of the linked graph edges. There is no direct selection or inspection of graph edges. '''pass
[docs]classEdgesAndLinkedNodes(GraphHitTestPolicy):''' With the ``EdgesAndLinkedNodes`` policy, inspection or selection of graph edges will result in the inspection or selection of the edge and of the linked graph nodes. There is no direct selection or inspection of graph nodes. '''pass
#-----------------------------------------------------------------------------# Private API#-----------------------------------------------------------------------------#-----------------------------------------------------------------------------# Code#-----------------------------------------------------------------------------# TODO (bev) deprecation: 3.0deffrom_networkx(graph,layout_function,**kwargs):frombokeh.plottingimportfrom_networkxasreal_from_networkxfrombokeh.util.deprecationimportdeprecateddeprecated("Importing from_networkx from bokeh.models.graphs is deprecated and will be removed in Bokeh 3.0. Import from bokeh.plotting instead")returnreal_from_networkx(graph,layout_function,**kwargs)