Karana.KUtils.visjs
===================

.. py:module:: Karana.KUtils.visjs

.. autoapi-nested-parse::

   Module containing classes and functions to visualize dot graphs.



Classes
-------

.. autoapisummary::

   Karana.KUtils.visjs.Node
   Karana.KUtils.visjs.Edge
   Karana.KUtils.visjs.NetworkGraph
   Karana.KUtils.visjs.Button
   Karana.KUtils.visjs.FontStyleOptions
   Karana.KUtils.visjs.FontOptions
   Karana.KUtils.visjs.ShadowOptions
   Karana.KUtils.visjs.ShapeProperties
   Karana.KUtils.visjs.WidthConstraintOptions
   Karana.KUtils.visjs.NodeScalingOptions
   Karana.KUtils.visjs.EdgeScalingOptions
   Karana.KUtils.visjs.ArrowStyle
   Karana.KUtils.visjs.SmoothOptions
   Karana.KUtils.visjs.ChosenNodeStyle
   Karana.KUtils.visjs.ChosenEdgeStyle
   Karana.KUtils.visjs.ChosenLabelStyle
   Karana.KUtils.visjs.ChosenNodeOptions
   Karana.KUtils.visjs.ChosenEdgeOptions
   Karana.KUtils.visjs.NodeColorOptions
   Karana.KUtils.visjs.NodeFontOptions
   Karana.KUtils.visjs.ClusterDefinition
   Karana.KUtils.visjs.ClusterNodeProperties
   Karana.KUtils.visjs.NodeOptions
   Karana.KUtils.visjs.EdgeColorOptions
   Karana.KUtils.visjs.ArrowOptions
   Karana.KUtils.visjs.EdgeOptions
   Karana.KUtils.visjs.PhysicsStabilizationOptions
   Karana.KUtils.visjs.BarnesHutSolverOptions
   Karana.KUtils.visjs.ForceAtlasToBasedSolverOptions
   Karana.KUtils.visjs.RepulsionSolverOptions
   Karana.KUtils.visjs.HierarchicalRepulsionSolverOptions
   Karana.KUtils.visjs.PhysicsOptions
   Karana.KUtils.visjs.KeyboardSpeedOptions
   Karana.KUtils.visjs.KeyboardOptions
   Karana.KUtils.visjs.InteractionOptions
   Karana.KUtils.visjs.HierarchicalLayoutOptions
   Karana.KUtils.visjs.LayoutOptions
   Karana.KUtils.visjs.Groups
   Karana.KUtils.visjs.GroupOptions
   Karana.KUtils.visjs.PredefinedClusterOptions
   Karana.KUtils.visjs.ExpandableClusteringOptions
   Karana.KUtils.visjs.ClusteringOptions
   Karana.KUtils.visjs.ManipulationOptions
   Karana.KUtils.visjs.NetworkOptions
   Karana.KUtils.visjs.GraphServer
   Karana.KUtils.visjs.MultibodyGraphServer
   Karana.KUtils.visjs.GraphServer
   Karana.KUtils.visjs.ArrowOptions
   Karana.KUtils.visjs.ArrowStyle
   Karana.KUtils.visjs.Edge
   Karana.KUtils.visjs.NetworkGraph
   Karana.KUtils.visjs.NetworkOptions
   Karana.KUtils.visjs.NodeColorOptions
   Karana.KUtils.visjs.NodeFontOptions
   Karana.KUtils.visjs.NodeOptions
   Karana.KUtils.visjs.EdgeOptions
   Karana.KUtils.visjs.Node
   Karana.KUtils.visjs.SmoothOptions
   Karana.KUtils.visjs.FSM
   Karana.KUtils.visjs.FSMTransition
   Karana.KUtils.visjs.FSMGraphServer


Functions
---------

.. autoapisummary::

   Karana.KUtils.visjs.buildStandaloneHtml
   Karana.KUtils.visjs.framesToGraph
   Karana.KUtils.visjs.subGraphToGraph
   Karana.KUtils.visjs.multibodyConstraintEdges


Package Contents
----------------

.. py:class:: Node

   Represents a node in the network graph.

   .. attribute:: id

      Unique ID for the node, automatically generated by default

      :type: int | str

   .. attribute:: label

      Text label displayed on the node

      :type: str

   .. attribute:: options

      Optional Node-specific styling and behavior options

      :type: NodeOptions | None

   .. attribute:: title

      Optional tooltip content (plain text or HTML)

      :type: str | None

   .. attribute:: cluster_group

      Optional cluster group name for expandable clustering (enables
      clustering when set)

      :type: str | None


   .. py:attribute:: id
      :type:  int | str
      :value: ''



   .. py:attribute:: label
      :type:  str
      :value: ''



   .. py:attribute:: options
      :type:  NodeOptions | None
      :value: None



   .. py:attribute:: title
      :type:  str | None
      :value: None



   .. py:attribute:: cluster_group
      :type:  str | None
      :value: None



   .. py:method:: __post_init__()

      Validate tooltip behavior after initialization.



   .. py:method:: toDict() -> dict[str, JsonType]

      Convert node to dictionary for JSON serialization.



.. py:class:: Edge

   Represents an edge between nodes in the network graph.

   .. attribute:: from_

      Source node ID

      :type: int | str

   .. attribute:: to

      Target node ID

      :type: int | str

   .. attribute:: id

      Unique ID for the edge, automatically generated by default

      :type: int | str

   .. attribute:: options

      Optional Edge-specific styling and behavior options

      :type: EdgeOptions | None

   .. attribute:: title

      Optional tooltip content (plain text or HTML)

      :type: str | None


   .. py:attribute:: from_
      :type:  int | str


   .. py:attribute:: to
      :type:  int | str


   .. py:attribute:: id
      :type:  int | str
      :value: ''



   .. py:attribute:: options
      :type:  EdgeOptions | None
      :value: None



   .. py:attribute:: title
      :type:  str | None
      :value: None



   .. py:method:: __post_init__()

      Validate tooltip behavior after initialization.



   .. py:method:: toDict() -> dict[str, JsonType]

      Convert edge to dictionary for JSON serialization.



.. py:class:: NetworkGraph

   Bases: :py:obj:`ToDictMixin`


   Represents a graph with nodes, edges, and global options.

   .. attribute:: nodes

      Nodes in the graph. Default is empty list.

      :type: list[Node]

   .. attribute:: edges

      Edges connecting the nodes. Default is empty list.

      :type: list[Edge]

   .. attribute:: options

      Global options for the graph.

      :type: NetworkOptions

   .. attribute:: title

      Title for the graph. Default is "kdFlex Graph Visualization"

      :type: str


   .. py:attribute:: nodes
      :type:  list[Node]
      :value: []



   .. py:attribute:: edges
      :type:  list[Edge]
      :value: []



   .. py:attribute:: options
      :type:  NetworkOptions


   .. py:attribute:: title
      :type:  str
      :value: 'kdFlex Graph Visualization'



   .. py:method:: clone() -> Self

      Get a deep copy.



   .. py:method:: __or__(other: Self) -> Self

      Take the union of this graph and other.

      :param other: The other graph to take the union with.
      :type other: Self

      :returns: A union of this graph and other.
      :rtype: Self



   .. py:method:: __ior__(other: Self) -> Self

      Take the union of this graph and other, but removes duplicates.

      :param other: The other graph to union with.
      :type other: Self

      :returns: The union of this graph and other with duplicates removed.
      :rtype: Self



   .. py:method:: removeIsolatedNodes()

      Remove any nodes that aren't touched by an edge.



.. py:class:: Button

   Bases: :py:obj:`ToDictMixin`


   Custom button to be displayed in the UI.

   .. attribute:: text

      The text displayed inside the button

      :type: str

   .. attribute:: callback

      No-argument, optionally async function called upon button press

      :type: Callable

   .. attribute:: id

      Unique id for the button, will be generated if omitted

      :type: str

   .. attribute:: style

      CSS styling for the button

      :type: dict[str, str]

   .. attribute:: type

      Context to show the button. Defaults to global.

      :type: Literal["global", "selected-node", "selected-edge"]

   .. attribute:: Note



      :type: style keys must be valid JavaScript identifiers. Use camelCase

   .. attribute:: where appropriate. See this MDN page for details



   .. attribute:: https



      :type: //developer.mozilla.org/en-US/docs/Web/API/HTMLElement/style


   .. py:attribute:: text
      :type:  str


   .. py:attribute:: callback
      :type:  collections.abc.Callable


   .. py:attribute:: id
      :type:  str
      :value: ''



   .. py:attribute:: style
      :type:  dict[str, str]


   .. py:attribute:: type
      :type:  Literal['global', 'selected-node', 'selected-edge']
      :value: 'global'



.. py:class:: FontStyleOptions

   Bases: :py:obj:`ToDictMixin`


   Style options for font variants.


   .. py:attribute:: color
      :type:  str | None
      :value: None



   .. py:attribute:: size
      :type:  int | None
      :value: None



   .. py:attribute:: face
      :type:  str | None
      :value: None



   .. py:attribute:: mod
      :type:  str | None
      :value: None



.. py:class:: FontOptions

   Bases: :py:obj:`ToDictMixin`


   Font options for labels.


   .. py:attribute:: color
      :type:  str | None
      :value: None



   .. py:attribute:: size
      :type:  int | None
      :value: None



   .. py:attribute:: face
      :type:  str | None
      :value: None



   .. py:attribute:: background
      :type:  str | None
      :value: None



   .. py:attribute:: strokeWidth
      :type:  int | None
      :value: None



   .. py:attribute:: strokeColor
      :type:  str | None
      :value: None



   .. py:attribute:: align
      :type:  str | None
      :value: None



   .. py:attribute:: vadjust
      :type:  int | None
      :value: None



   .. py:attribute:: bold
      :type:  FontStyleOptions | None
      :value: None



   .. py:attribute:: ital
      :type:  FontStyleOptions | None
      :value: None



   .. py:attribute:: mono
      :type:  FontStyleOptions | None
      :value: None



   .. py:attribute:: multi
      :type:  bool | None
      :value: None



   .. py:attribute:: sizeMax
      :type:  int | None
      :value: None



.. py:class:: ShadowOptions

   Bases: :py:obj:`ToDictMixin`


   Shadow options for nodes and edges.


   .. py:attribute:: enabled
      :type:  bool | None
      :value: None



   .. py:attribute:: color
      :type:  str | None
      :value: None



   .. py:attribute:: size
      :type:  int | None
      :value: None



   .. py:attribute:: x
      :type:  float | None
      :value: None



   .. py:attribute:: y
      :type:  float | None
      :value: None



.. py:class:: ShapeProperties

   Bases: :py:obj:`ToDictMixin`


   Properties for custom node shapes.


   .. py:attribute:: borderDashes
      :type:  list[int] | None
      :value: None



   .. py:attribute:: borderRadius
      :type:  int | None
      :value: None



   .. py:attribute:: interpolation
      :type:  bool | None
      :value: None



.. py:class:: WidthConstraintOptions

   Bases: :py:obj:`ToDictMixin`


   Width constraint options for nodes.


   .. py:attribute:: minimum
      :type:  int | None
      :value: None



   .. py:attribute:: maximum
      :type:  int | None
      :value: None



.. py:class:: NodeScalingOptions

   Bases: :py:obj:`ToDictMixin`


   Scaling options for nodes.


   .. py:attribute:: min
      :type:  int | None
      :value: None



   .. py:attribute:: max
      :type:  int | None
      :value: None



   .. py:attribute:: label
      :type:  FontOptions | None
      :value: None



.. py:class:: EdgeScalingOptions

   Bases: :py:obj:`ToDictMixin`


   Scaling options for edges.


   .. py:attribute:: min
      :type:  int | None
      :value: None



   .. py:attribute:: max
      :type:  int | None
      :value: None



   .. py:attribute:: label
      :type:  FontOptions | None
      :value: None



.. py:class:: ArrowStyle

   Bases: :py:obj:`ToDictMixin`


   Individual arrow style options.


   .. py:attribute:: enabled
      :type:  bool | None
      :value: None



   .. py:attribute:: imageHeight
      :type:  int | None
      :value: None



   .. py:attribute:: imageWidth
      :type:  int | None
      :value: None



   .. py:attribute:: scaleFactor
      :type:  float | None
      :value: None



   .. py:attribute:: src
      :type:  str | None
      :value: None



.. py:class:: SmoothOptions

   Bases: :py:obj:`ToDictMixin`


   Smooth options for edges.


   .. py:attribute:: type
      :type:  EdgeSmoothType | None
      :value: None



   .. py:attribute:: forceDirection
      :type:  str | None
      :value: None



   .. py:attribute:: roundness
      :type:  float | None
      :value: None



.. py:class:: ChosenNodeStyle

   Bases: :py:obj:`ToDictMixin`


   Style options for chosen (selected) nodes.


   .. py:attribute:: borderWidth
      :type:  int | None
      :value: None



   .. py:attribute:: borderWidthSelected
      :type:  int | None
      :value: None



   .. py:attribute:: brokenImage
      :type:  str | None
      :value: None



   .. py:attribute:: color
      :type:  str | None
      :value: None



   .. py:attribute:: fontColor
      :type:  str | None
      :value: None



   .. py:attribute:: fontSize
      :type:  int | None
      :value: None



   .. py:attribute:: fontFace
      :type:  str | None
      :value: None



   .. py:attribute:: fontWeight
      :type:  str | None
      :value: None



   .. py:attribute:: icon
      :type:  str | None
      :value: None



   .. py:attribute:: iconFace
      :type:  str | None
      :value: None



   .. py:attribute:: iconSize
      :type:  int | None
      :value: None



   .. py:attribute:: iconWeight
      :type:  str | None
      :value: None



   .. py:attribute:: image
      :type:  str | None
      :value: None



   .. py:attribute:: image_padding
      :type:  int | None
      :value: None



   .. py:attribute:: label
      :type:  str | None
      :value: None



   .. py:attribute:: label_highlight_bold
      :type:  bool | None
      :value: None



   .. py:attribute:: level
      :type:  int | None
      :value: None



   .. py:attribute:: mass
      :type:  float | None
      :value: None



   .. py:attribute:: opacity
      :type:  float | None
      :value: None



   .. py:attribute:: physics
      :type:  bool | None
      :value: None



   .. py:attribute:: scaling
      :type:  NodeScalingOptions | None
      :value: None



   .. py:attribute:: shadow
      :type:  ShadowOptions | None
      :value: None



   .. py:attribute:: shape
      :type:  str | None
      :value: None



   .. py:attribute:: shapeProperties
      :type:  ShapeProperties | None
      :value: None



   .. py:attribute:: size
      :type:  int | float | None
      :value: None



   .. py:attribute:: title
      :type:  str | None
      :value: None



   .. py:attribute:: value
      :type:  int | float | None
      :value: None



   .. py:attribute:: widthConstraint
      :type:  bool | int | WidthConstraintOptions | None
      :value: None



   .. py:attribute:: x
      :type:  float | None
      :value: None



   .. py:attribute:: y
      :type:  float | None
      :value: None



.. py:class:: ChosenEdgeStyle

   Bases: :py:obj:`ToDictMixin`


   Style options for chosen (selected) edges.


   .. py:attribute:: arrows
      :type:  str | ArrowStyle | None
      :value: None



   .. py:attribute:: arrowStrikethrough
      :type:  bool | None
      :value: None



   .. py:attribute:: color
      :type:  str | None
      :value: None



   .. py:attribute:: dashes
      :type:  bool | list[int] | None
      :value: None



   .. py:attribute:: font
      :type:  FontOptions | None
      :value: None



   .. py:attribute:: hidden
      :type:  bool | None
      :value: None



   .. py:attribute:: hoverWidth
      :type:  int | float | None
      :value: None



   .. py:attribute:: label
      :type:  str | None
      :value: None



   .. py:attribute:: labelHighlightBold
      :type:  bool | None
      :value: None



   .. py:attribute:: length
      :type:  float | None
      :value: None



   .. py:attribute:: physics
      :type:  bool | None
      :value: None



   .. py:attribute:: scaling
      :type:  EdgeScalingOptions | None
      :value: None



   .. py:attribute:: selectionWidth
      :type:  int | float | None
      :value: None



   .. py:attribute:: selfReferenceSize
      :type:  int | None
      :value: None



   .. py:attribute:: shadow
      :type:  ShadowOptions | None
      :value: None



   .. py:attribute:: smooth
      :type:  bool | str | SmoothOptions | None
      :value: None



   .. py:attribute:: title
      :type:  str | None
      :value: None



   .. py:attribute:: width
      :type:  int | float | None
      :value: None



   .. py:attribute:: widthConstraint
      :type:  bool | int | WidthConstraintOptions | None
      :value: None



.. py:class:: ChosenLabelStyle

   Bases: :py:obj:`ToDictMixin`


   Style options for chosen (selected) labels.


   .. py:attribute:: color
      :type:  str | None
      :value: None



   .. py:attribute:: face
      :type:  str | None
      :value: None



   .. py:attribute:: size
      :type:  int | None
      :value: None



   .. py:attribute:: strokeWidth
      :type:  int | None
      :value: None



   .. py:attribute:: strokeColor
      :type:  str | None
      :value: None



   .. py:attribute:: align
      :type:  str | None
      :value: None



.. py:class:: ChosenNodeOptions

   Bases: :py:obj:`ToDictMixin`


   Options for chosen (selected) nodes.


   .. py:attribute:: node
      :type:  ChosenNodeStyle | None
      :value: None



   .. py:attribute:: label
      :type:  ChosenLabelStyle | None
      :value: None



.. py:class:: ChosenEdgeOptions

   Bases: :py:obj:`ToDictMixin`


   Options for chosen (selected) edges.


   .. py:attribute:: edge
      :type:  ChosenEdgeStyle | None
      :value: None



   .. py:attribute:: label
      :type:  ChosenLabelStyle | None
      :value: None



.. py:class:: NodeColorOptions

   Bases: :py:obj:`ToDictMixin`


   Color options for nodes.


   .. py:attribute:: border
      :type:  str | None
      :value: None



   .. py:attribute:: background
      :type:  str | None
      :value: None



   .. py:attribute:: highlight
      :type:  dict[str, str] | None
      :value: None



   .. py:attribute:: hover
      :type:  dict[str, str] | None
      :value: None



.. py:class:: NodeFontOptions

   Bases: :py:obj:`ToDictMixin`


   Font options for node labels.


   .. py:attribute:: color
      :type:  str | None
      :value: None



   .. py:attribute:: size
      :type:  int | None
      :value: None



   .. py:attribute:: face
      :type:  str | None
      :value: None



   .. py:attribute:: background
      :type:  str | None
      :value: None



   .. py:attribute:: strokeWidth
      :type:  int | None
      :value: None



   .. py:attribute:: strokeColor
      :type:  str | None
      :value: None



   .. py:attribute:: align
      :type:  str | None
      :value: None



   .. py:attribute:: vadjust
      :type:  int | None
      :value: None



   .. py:attribute:: multi
      :type:  bool | None
      :value: None



   .. py:attribute:: bold
      :type:  FontStyleOptions | None
      :value: None



   .. py:attribute:: ital
      :type:  FontStyleOptions | None
      :value: None



   .. py:attribute:: mono
      :type:  FontStyleOptions | None
      :value: None



.. py:class:: ClusterDefinition

   Bases: :py:obj:`ToDictMixin`


   Definition for a predefined cluster.


   .. py:attribute:: cluster_id
      :type:  str


   .. py:attribute:: label
      :type:  str


   .. py:attribute:: node_ids
      :type:  list[str]


   .. py:attribute:: color
      :type:  str | None
      :value: None



   .. py:attribute:: shape
      :type:  str | None
      :value: None



   .. py:attribute:: size
      :type:  int | None
      :value: None



   .. py:attribute:: group
      :type:  str | None
      :value: None



   .. py:attribute:: description
      :type:  str | None
      :value: None



.. py:class:: ClusterNodeProperties

   Bases: :py:obj:`ToDictMixin`


   Properties for cluster nodes.


   .. py:attribute:: allowSingleNodeCluster
      :type:  bool | None
      :value: None



   .. py:attribute:: clusterNodeProperties
      :type:  dict[str, JsonType] | None
      :value: None



.. py:class:: NodeOptions

   Bases: :py:obj:`ToDictMixin`


   Complete node styling and behavior options.


   .. py:attribute:: borderWidth
      :type:  int | None
      :value: None



   .. py:attribute:: borderWidthSelected
      :type:  int | None
      :value: None



   .. py:attribute:: brokenImage
      :type:  str | None
      :value: None



   .. py:attribute:: chosen
      :type:  ChosenNodeOptions | None
      :value: None



   .. py:attribute:: clusterNodeProperties
      :type:  ClusterNodeProperties | None
      :value: None



   .. py:attribute:: color
      :type:  str | NodeColorOptions | None
      :value: None



   .. py:attribute:: font
      :type:  NodeFontOptions | None
      :value: None



   .. py:attribute:: group
      :type:  str | None
      :value: None



   .. py:attribute:: hidden
      :type:  bool | None
      :value: None



   .. py:attribute:: icon
      :type:  str | None
      :value: None



   .. py:attribute:: iconFontFace
      :type:  str | None
      :value: None



   .. py:attribute:: iconSize
      :type:  int | None
      :value: None



   .. py:attribute:: image
      :type:  str | None
      :value: None



   .. py:attribute:: imagePadding
      :type:  int | None
      :value: None



   .. py:attribute:: label
      :type:  str | None
      :value: None



   .. py:attribute:: labelHighlightBold
      :type:  bool | None
      :value: None



   .. py:attribute:: level
      :type:  int | None
      :value: None



   .. py:attribute:: margin
      :type:  dict[str, int] | None
      :value: None



   .. py:attribute:: mass
      :type:  float | None
      :value: None



   .. py:attribute:: physics
      :type:  bool | None
      :value: None



   .. py:attribute:: scaling
      :type:  NodeScalingOptions | None
      :value: None



   .. py:attribute:: shadow
      :type:  ShadowOptions | None
      :value: None



   .. py:attribute:: shape
      :type:  NodeShape | None
      :value: None



   .. py:attribute:: shapeProperties
      :type:  ShapeProperties | None
      :value: None



   .. py:attribute:: size
      :type:  int | float | None
      :value: None



   .. py:attribute:: title
      :type:  str | None
      :value: None



   .. py:attribute:: value
      :type:  int | float | None
      :value: None



   .. py:attribute:: widthConstraint
      :type:  bool | int | WidthConstraintOptions | None
      :value: None



   .. py:attribute:: x
      :type:  float | None
      :value: None



   .. py:attribute:: y
      :type:  float | None
      :value: None



.. py:class:: EdgeColorOptions

   Bases: :py:obj:`ToDictMixin`


   Color options for edges.


   .. py:attribute:: color
      :type:  str | None
      :value: None



   .. py:attribute:: highlight
      :type:  str | None
      :value: None



   .. py:attribute:: hover
      :type:  str | None
      :value: None



   .. py:attribute:: inherit
      :type:  bool | str | None
      :value: None



   .. py:attribute:: opacity
      :type:  float | None
      :value: None



.. py:class:: ArrowOptions

   Bases: :py:obj:`ToDictMixin`


   Arrow options for edges.


   .. py:attribute:: to
      :type:  ArrowStyle | None
      :value: None



   .. py:attribute:: middle
      :type:  ArrowStyle | None
      :value: None



   .. py:attribute:: from_
      :type:  ArrowStyle | None
      :value: None



.. py:class:: EdgeOptions

   Bases: :py:obj:`ToDictMixin`


   Complete edge styling and behavior options.


   .. py:attribute:: arrows
      :type:  str | ArrowOptions | None
      :value: None



   .. py:attribute:: arrowStrikethrough
      :type:  bool | None
      :value: None



   .. py:attribute:: chosen
      :type:  ChosenEdgeOptions | None
      :value: None



   .. py:attribute:: color
      :type:  str | EdgeColorOptions | None
      :value: None



   .. py:attribute:: dashes
      :type:  bool | list[int] | None
      :value: None



   .. py:attribute:: font
      :type:  FontOptions | None
      :value: None



   .. py:attribute:: from_
      :type:  str | int | None
      :value: None



   .. py:attribute:: hidden
      :type:  bool | None
      :value: None



   .. py:attribute:: hoverWidth
      :type:  int | float | None
      :value: None



   .. py:attribute:: label
      :type:  str | None
      :value: None



   .. py:attribute:: label_highlight_bold
      :type:  bool | None
      :value: None



   .. py:attribute:: length
      :type:  float | None
      :value: None



   .. py:attribute:: physics
      :type:  bool | None
      :value: None



   .. py:attribute:: scaling
      :type:  EdgeScalingOptions | None
      :value: None



   .. py:attribute:: selectionWidth
      :type:  int | float | None
      :value: None



   .. py:attribute:: selfReferenceSize
      :type:  int | None
      :value: None



   .. py:attribute:: shadow
      :type:  ShadowOptions | None
      :value: None



   .. py:attribute:: smooth
      :type:  bool | SmoothOptions | None
      :value: None



   .. py:attribute:: title
      :type:  str | None
      :value: None



   .. py:attribute:: to
      :type:  str | int | None
      :value: None



   .. py:attribute:: value
      :type:  int | float | None
      :value: None



   .. py:attribute:: width
      :type:  int | float | None
      :value: None



   .. py:attribute:: widthConstraint
      :type:  bool | int | WidthConstraintOptions | None
      :value: None



.. py:class:: PhysicsStabilizationOptions

   Bases: :py:obj:`ToDictMixin`


   Physics stabilization options.


   .. py:attribute:: enabled
      :type:  bool | None
      :value: None



   .. py:attribute:: iterations
      :type:  int | None
      :value: None



   .. py:attribute:: updateInterval
      :type:  int | None
      :value: None



   .. py:attribute:: onlyDynamicEdges
      :type:  bool | None
      :value: None



   .. py:attribute:: fit
      :type:  bool | None
      :value: None



.. py:class:: BarnesHutSolverOptions

   Bases: :py:obj:`ToDictMixin`


   Barnes Hut physics solver options.


   .. py:attribute:: theta
      :type:  float | None
      :value: None



   .. py:attribute:: gravitationalConstant
      :type:  float | None
      :value: None



   .. py:attribute:: centralGravity
      :type:  float | None
      :value: None



   .. py:attribute:: springLength
      :type:  float | None
      :value: None



   .. py:attribute:: springConstant
      :type:  float | None
      :value: None



   .. py:attribute:: damping
      :type:  float | None
      :value: None



   .. py:attribute:: avoidOverlap
      :type:  float | None
      :value: None



.. py:class:: ForceAtlasToBasedSolverOptions

   Bases: :py:obj:`ToDictMixin`


   Force Atlas 2 physics solver options.


   .. py:attribute:: theta
      :type:  float | None
      :value: None



   .. py:attribute:: gravitationalConstant
      :type:  float | None
      :value: None



   .. py:attribute:: centralGravity
      :type:  float | None
      :value: None



   .. py:attribute:: springLength
      :type:  float | None
      :value: None



   .. py:attribute:: springConstant
      :type:  float | None
      :value: None



   .. py:attribute:: damping
      :type:  float | None
      :value: None



   .. py:attribute:: avoidOverlap
      :type:  float | None
      :value: None



.. py:class:: RepulsionSolverOptions

   Bases: :py:obj:`ToDictMixin`


   Repulsion physics solver options.


   .. py:attribute:: nodeDistance
      :type:  float | None
      :value: None



   .. py:attribute:: centralGravity
      :type:  float | None
      :value: None



   .. py:attribute:: springLength
      :type:  float | None
      :value: None



   .. py:attribute:: springConstant
      :type:  float | None
      :value: None



   .. py:attribute:: damping
      :type:  float | None
      :value: None



.. py:class:: HierarchicalRepulsionSolverOptions

   Bases: :py:obj:`ToDictMixin`


   Hierarchical Repulsion physics solver options.


   .. py:attribute:: nodeDistance
      :type:  float | None
      :value: None



   .. py:attribute:: centralGravity
      :type:  float | None
      :value: None



   .. py:attribute:: springLength
      :type:  float | None
      :value: None



   .. py:attribute:: springConstant
      :type:  float | None
      :value: None



   .. py:attribute:: damping
      :type:  float | None
      :value: None



   .. py:attribute:: avoidOverlap
      :type:  float | None
      :value: None



.. py:class:: PhysicsOptions

   Bases: :py:obj:`ToDictMixin`


   Physics simulation options.


   .. py:attribute:: enabled
      :type:  bool | None
      :value: None



   .. py:attribute:: timestep
      :type:  float | None
      :value: None



   .. py:attribute:: adaptiveTimestep
      :type:  bool | None
      :value: None



   .. py:attribute:: maxVelocity
      :type:  float | None
      :value: None



   .. py:attribute:: minVelocity
      :type:  float | None
      :value: None



   .. py:attribute:: stabilization
      :type:  PhysicsStabilizationOptions | None
      :value: None



   .. py:attribute:: solver
      :type:  PhysicsSolver | None
      :value: None



   .. py:attribute:: barnesHut
      :type:  BarnesHutSolverOptions | None
      :value: None



   .. py:attribute:: forceAtlasToBased
      :type:  ForceAtlasToBasedSolverOptions | None
      :value: None



   .. py:attribute:: repulsion
      :type:  RepulsionSolverOptions | None
      :value: None



   .. py:attribute:: hierarchicalRepulsion
      :type:  HierarchicalRepulsionSolverOptions | None
      :value: None



.. py:class:: KeyboardSpeedOptions

   Bases: :py:obj:`ToDictMixin`


   Keyboard speed options.


   .. py:attribute:: x
      :type:  float | None
      :value: None



   .. py:attribute:: y
      :type:  float | None
      :value: None



.. py:class:: KeyboardOptions

   Bases: :py:obj:`ToDictMixin`


   Keyboard interaction options.


   .. py:attribute:: enabled
      :type:  bool | None
      :value: None



   .. py:attribute:: speed
      :type:  KeyboardSpeedOptions | None
      :value: None



   .. py:attribute:: bindToWindow
      :type:  bool | None
      :value: None



.. py:class:: InteractionOptions

   Bases: :py:obj:`ToDictMixin`


   User interaction options.


   .. py:attribute:: dragNodes
      :type:  bool | None
      :value: None



   .. py:attribute:: dragView
      :type:  bool | None
      :value: None



   .. py:attribute:: hideEdgesOnDrag
      :type:  bool | None
      :value: None



   .. py:attribute:: hideEdgesOnZoom
      :type:  bool | None
      :value: None



   .. py:attribute:: hideNodesOnDrag
      :type:  bool | None
      :value: None



   .. py:attribute:: hover
      :type:  bool | None
      :value: None



   .. py:attribute:: hoverConnectedEdges
      :type:  bool | None
      :value: None



   .. py:attribute:: keyboard
      :type:  bool | KeyboardOptions | None
      :value: None



   .. py:attribute:: multiselect
      :type:  bool | None
      :value: None



   .. py:attribute:: navigationButtons
      :type:  bool | None
      :value: None



   .. py:attribute:: selectConnectedEdges
      :type:  bool | None
      :value: None



   .. py:attribute:: tooltipDelay
      :type:  int | None
      :value: None



   .. py:attribute:: zoomSpeed
      :type:  float | None
      :value: None



   .. py:attribute:: zoomView
      :type:  bool | None
      :value: None



.. py:class:: HierarchicalLayoutOptions

   Bases: :py:obj:`ToDictMixin`


   Hierarchical layout options.


   .. py:attribute:: enabled
      :type:  bool
      :value: False



   .. py:attribute:: levelSeparation
      :type:  float
      :value: 150



   .. py:attribute:: nodeSpacing
      :type:  float
      :value: 100



   .. py:attribute:: treeSpacing
      :type:  float
      :value: 200



   .. py:attribute:: blockShifting
      :type:  bool
      :value: True



   .. py:attribute:: edgeMinimization
      :type:  bool
      :value: True



   .. py:attribute:: parentCentralization
      :type:  bool
      :value: True



   .. py:attribute:: direction
      :type:  HierarchicalDirection
      :value: 'UD'



   .. py:attribute:: sortMethod
      :type:  HierarchicalSortMethod
      :value: 'hubsize'



.. py:class:: LayoutOptions

   Bases: :py:obj:`ToDictMixin`


   Layout configuration options.


   .. py:attribute:: improvedLayout
      :type:  bool
      :value: True



   .. py:attribute:: hierarchical
      :type:  HierarchicalLayoutOptions | None
      :value: None



.. py:class:: Groups

   Bases: :py:obj:`ToDictMixin`


   Group definitions.


.. py:class:: GroupOptions

   Bases: :py:obj:`ToDictMixin`


   Group options.


   .. py:attribute:: useDefaultGroups
      :type:  bool | None
      :value: None



   .. py:attribute:: groups
      :type:  Groups | None
      :value: None



.. py:class:: PredefinedClusterOptions

   Bases: :py:obj:`ToDictMixin`


   Options for predefined clustering behavior.


   .. py:attribute:: auto_cluster_on_load
      :type:  bool
      :value: True



   .. py:attribute:: preserve_cluster_state
      :type:  bool
      :value: True



   .. py:attribute:: cluster_by_group
      :type:  bool
      :value: True



   .. py:attribute:: min_nodes_for_cluster
      :type:  int
      :value: 2



   .. py:attribute:: cluster_shape
      :type:  NodeShape
      :value: 'ellipse'



   .. py:attribute:: cluster_border_width
      :type:  int
      :value: 3



   .. py:attribute:: show_cluster_count
      :type:  bool
      :value: True



.. py:class:: ExpandableClusteringOptions

   Bases: :py:obj:`ToDictMixin`


   Options for expandable clustering behavior.


   .. py:attribute:: enabled
      :type:  bool
      :value: True



   .. py:attribute:: auto_detect_groups
      :type:  bool
      :value: True



   .. py:attribute:: min_nodes_for_cluster
      :type:  int
      :value: 2



   .. py:attribute:: cluster_shape
      :type:  NodeShape
      :value: 'ellipse'



   .. py:attribute:: cluster_size
      :type:  int
      :value: 40



   .. py:attribute:: cluster_border_width
      :type:  int
      :value: 3



   .. py:attribute:: cluster_font_size
      :type:  int
      :value: 14



   .. py:attribute:: cluster_font_color
      :type:  str
      :value: '#FFFFFF'



   .. py:attribute:: show_cluster_count
      :type:  bool
      :value: True



   .. py:attribute:: preserve_edge_connections
      :type:  bool
      :value: True



   .. py:attribute:: enable_double_click_expand
      :type:  bool
      :value: True



   .. py:attribute:: enable_buttons
      :type:  bool
      :value: True



   .. py:attribute:: color_scheme
      :type:  dict[str, str]
      :value: None



   .. py:method:: __post_init__()

      Set default color scheme if not provided.



.. py:class:: ClusteringOptions

   Bases: :py:obj:`ToDictMixin`


   Comprehensive node clustering options.


   .. py:attribute:: enabled
      :type:  bool | None
      :value: None



   .. py:attribute:: predefined_clusters
      :type:  list[ClusterDefinition] | None
      :value: None



   .. py:attribute:: predefined_options
      :type:  PredefinedClusterOptions | None
      :value: None



   .. py:attribute:: expandable
      :type:  ExpandableClusteringOptions | None
      :value: None



   .. py:attribute:: default_cluster_color
      :type:  str
      :value: '#95A5A6'



   .. py:attribute:: preserve_original_properties
      :type:  bool
      :value: True



.. py:class:: ManipulationOptions

   Bases: :py:obj:`ToDictMixin`


   Optional GUI to alter the data in the network.

   Leave a value as None to use the vis.js default.

   Details at:
       https://visjs.github.io/vis-network/docs/network/manipulation.html


   .. py:attribute:: enabled
      :type:  bool | None
      :value: None



.. py:class:: NetworkOptions

   Bases: :py:obj:`ToDictMixin`


   Complete network configuration options.


   .. py:attribute:: nodes
      :type:  NodeOptions | None
      :value: None



   .. py:attribute:: edges
      :type:  EdgeOptions | None
      :value: None



   .. py:attribute:: physics
      :type:  PhysicsOptions | None
      :value: None



   .. py:attribute:: layout
      :type:  LayoutOptions | None
      :value: None



   .. py:attribute:: interaction
      :type:  InteractionOptions | None
      :value: None



   .. py:attribute:: groups
      :type:  GroupOptions | None
      :value: None



   .. py:attribute:: configure
      :type:  ConfigureOptions | None
      :value: None



   .. py:attribute:: clustering
      :type:  ClusteringOptions | None
      :value: None



   .. py:attribute:: manipulation
      :type:  ManipulationOptions | None
      :value: None



   .. py:method:: __post_init__()

      Set default values after initialization.



.. py:function:: buildStandaloneHtml(graph: Karana.KUtils.visjs._datatypes.NetworkGraph) -> str

   Generate an html file for offline graph viewing.

   Given a NetworkGraph, this generates the contents a complete,
   self-contained HTML file showing the graph with vis.js. The HTML
   bundles all required information including the vis.js library, so it
   can be saved to a file and later viewed offline in a web browser.

   :param graph: The graph to visualize
   :type graph: NetworkGraph

   :returns: The contents of the standalone html file
   :rtype: str


.. py:class:: GraphServer(graph: Karana.KUtils.visjs._datatypes.NetworkGraph | None = None, *, port=8765, buttons: list[Karana.KUtils.visjs._datatypes.Button] | None = None)

   Bases: :py:obj:`Karana.WebUI.HttpWsServer`


   A generic graph visualization server.

   This builds on HttpWsServer and uses the vis.js library to provide
   provide a server for visualizing and interacting with graph
   topologies in the web browser. The server can be specialized with
   frontend buttons and event handlers that trigger server-side
   callbacks. Additionally the server can broadcast to clients changes
   to the graph topology and appearance via a live websocket
   connection.



   .. py:attribute:: graph


   .. py:attribute:: buttons


   .. py:method:: launchLocalClient(standalone: bool = False)

      Open a client in a browser tab local to the server.

      :param standalone: If True, instead open the `/standalone.html` URL, which
                         serves a self-contained HTML file that is missing some
                         features but can be saved and later opened for offline
                         viewing. Defaults to False.
      :type standalone: bool



   .. py:method:: updateClientGraphs()

      Update clients to use the current graph.

      This must be called after modifying or replacing self.graph for
      the modifications to show up in connected clients.



   .. py:method:: addButton(button: Karana.KUtils.visjs._datatypes.Button)

      Add a button to current and future frontends.

      :param button: Description of the button, including a server-side callback
      :type button: Button



   .. py:method:: setSelection(ids: collections.abc.Sequence[int | str])

      Set which node and/or edge ids are selected on the frontends.

      :param node_id: Id of the node to select
      :type node_id: int | str



   .. py:method:: onConnect(client_id: int)

      Handle a new client connecting.

      We initialize the graph and UI elements of the new client.

      :param client_id: Value identifying the connected client
      :type client_id: int



   .. py:method:: onMessage(message: str, client_id)

      Handle receiving a websocket client message.

      Based on the message type we delegate to the appropriate handler
      method.

      :param message: The message text as a plain unparsed string
      :type message: str
      :param client_id: Value identifying the client
      :type client_id: int



   .. py:method:: addEdge(edge: Karana.KUtils.visjs._datatypes.Edge)

      Add a new edge.

      This immediately broadcasts the change to clients.

      :param edge: The new edge to add
      :type edge: Edge



   .. py:method:: removeEdge(edge: Karana.KUtils.visjs._datatypes.Edge | int | str)

      Remove any edges with the given id.

      This immediately broadcasts the change to clients.

      :param edge: Edge or Edge id to be removed
      :type edge: Edge | int | str



   .. py:method:: onDisconnect(client_id: int)

      Handle a websocket client disconnecting.

      There's nothing extra we need to do so this is a no-op.

      :param client_id: Value identifying the client
      :type client_id: int



   .. py:method:: onClickNode(client_id: int, node_id: int | str)

      When a user clicks on a node, this method is called.

      :param client_id: Value identifying the client
      :type client_id: int
      :param node_id: The node clicked on.
      :type node_id: int | str



   .. py:method:: onClickEdge(client_id: int, edge_id: int | str)

      When a user clicks on an edge, this method is called.

      :param client_id: Value identifying the client
      :type client_id: int
      :param edge_id: The edge clicked on.
      :type edge_id: int | str



.. py:function:: framesToGraph(frames: Karana.Frame.FrameContainer, *, title='Frame layer', label_map: dict[int | str, str] | None = None, coloring: Literal['type', 'valency'] = 'type', chains: bool = False) -> Karana.KUtils.visjs._datatypes.NetworkGraph

   Convert a FrameContainer to a visjs NetworkGraph.

   :param frames: Source of frames to show.
   :type frames: FrameContainer
   :param title: Title of the graph, defaults to "Frame layer"
   :type title: str
   :param label_map: Optional map to look up string labels for frames. Keys may be
                     either frame ids or frame names.
   :type label_map: dict[int | str, str] | None
   :param coloring:
                    How to color the nodes and edges in the visualization:
                        type: Color based on the type of the Frame or FrameToFrame
                        valency: Color nodes based on number of connecting edges
                    Defaults to the "type" coloring.
   :type coloring: Literal["type", "valency"]
   :param chains: Whether to show edges for ChainedFrameToFrames.
                  Defaults to False.
   :type chains: bool

   :returns: The NetworkGraph for the FrameContainer, ready for visualization
   :rtype: NetworkGraph


.. py:function:: subGraphToGraph(subgraph: Karana.Dynamics.SubGraph, title='Multibody System', label_map: dict[int | str, str] | None = None, constraints: bool = True) -> Karana.KUtils.visjs._datatypes.NetworkGraph

   Convert a SubGraph to a visjs NetworkGraph.

   :param subgraph: The subgraph object to show
   :type subgraph: SubGraph
   :param title: Title of the graph, defaults to "Multibody System"
   :type title: str
   :param label_map: Optional map to look up string labels for bodies. Keys may be
                     either body ids or body names.
   :type label_map: dict[int | str, str] | None
   :param constraints: Whether to created edges for constraints; True by default
   :type constraints: bool

   :returns: The NetworkGraph for the SubGraph, ready for visualization
   :rtype: NetworkGraph


.. py:function:: multibodyConstraintEdges(subgraph: Karana.Dynamics.SubGraph) -> list[Karana.KUtils.visjs._datatypes.Edge]

   Create edges for all constraints in the provided SubGraph.

   :param subgraph: The SubGraph whose constraints will be used to create edges.
   :type subgraph: SubGraph

   :returns: A list of edges, where every edge is associated with a constraint in the provided SubGraph.
   :rtype: list[Edge]


.. py:class:: MultibodyGraphServer(subgraph: Karana.Dynamics.SubGraph, *, title='Multibody System', port=8765, buttons: list[Karana.KUtils.visjs._datatypes.Button] | None = None, label_map: dict[int | str, str] | None = None, extra_edges: dict[str, list[Karana.KUtils.visjs._datatypes.Edge]] | list[Karana.KUtils.visjs._datatypes.Edge] | None = None)

   Bases: :py:obj:`Karana.KUtils.visjs._server.GraphServer`


   Specialized GraphServer for SubGraph viewing.

   Given a SubGraph, this automatically generates a set of graphs
   with and without constraints and other sets of extra edges. Buttons
   are automatically added to toggle different parts of the graph on
   and off.


   .. py:method:: hasSubGraph(label: str)

      Check for the SubGraph with the given label.

      :param label: The SubGraph to check for.
      :type label: str

      :returns: True if the SubGraph exists, False otherwise.
      :rtype: bool



   .. py:method:: enableSubGraph(label: str)

      Enable the SubGraph with the given label.

      :param label: The SubGraph to enable.
      :type label: str



   .. py:method:: disableSubGraph(label: str)

      Disable the SubGraph with the given label.

      :param label: The SubGraph to disable.
      :type label: str



.. py:class:: GraphServer(graph: Karana.KUtils.visjs._datatypes.NetworkGraph | None = None, *, port=8765, buttons: list[Karana.KUtils.visjs._datatypes.Button] | None = None)

   Bases: :py:obj:`Karana.WebUI.HttpWsServer`


   A generic graph visualization server.

   This builds on HttpWsServer and uses the vis.js library to provide
   provide a server for visualizing and interacting with graph
   topologies in the web browser. The server can be specialized with
   frontend buttons and event handlers that trigger server-side
   callbacks. Additionally the server can broadcast to clients changes
   to the graph topology and appearance via a live websocket
   connection.



   .. py:attribute:: graph


   .. py:attribute:: buttons


   .. py:method:: launchLocalClient(standalone: bool = False)

      Open a client in a browser tab local to the server.

      :param standalone: If True, instead open the `/standalone.html` URL, which
                         serves a self-contained HTML file that is missing some
                         features but can be saved and later opened for offline
                         viewing. Defaults to False.
      :type standalone: bool



   .. py:method:: updateClientGraphs()

      Update clients to use the current graph.

      This must be called after modifying or replacing self.graph for
      the modifications to show up in connected clients.



   .. py:method:: addButton(button: Karana.KUtils.visjs._datatypes.Button)

      Add a button to current and future frontends.

      :param button: Description of the button, including a server-side callback
      :type button: Button



   .. py:method:: setSelection(ids: collections.abc.Sequence[int | str])

      Set which node and/or edge ids are selected on the frontends.

      :param node_id: Id of the node to select
      :type node_id: int | str



   .. py:method:: onConnect(client_id: int)

      Handle a new client connecting.

      We initialize the graph and UI elements of the new client.

      :param client_id: Value identifying the connected client
      :type client_id: int



   .. py:method:: onMessage(message: str, client_id)

      Handle receiving a websocket client message.

      Based on the message type we delegate to the appropriate handler
      method.

      :param message: The message text as a plain unparsed string
      :type message: str
      :param client_id: Value identifying the client
      :type client_id: int



   .. py:method:: addEdge(edge: Karana.KUtils.visjs._datatypes.Edge)

      Add a new edge.

      This immediately broadcasts the change to clients.

      :param edge: The new edge to add
      :type edge: Edge



   .. py:method:: removeEdge(edge: Karana.KUtils.visjs._datatypes.Edge | int | str)

      Remove any edges with the given id.

      This immediately broadcasts the change to clients.

      :param edge: Edge or Edge id to be removed
      :type edge: Edge | int | str



   .. py:method:: onDisconnect(client_id: int)

      Handle a websocket client disconnecting.

      There's nothing extra we need to do so this is a no-op.

      :param client_id: Value identifying the client
      :type client_id: int



   .. py:method:: onClickNode(client_id: int, node_id: int | str)

      When a user clicks on a node, this method is called.

      :param client_id: Value identifying the client
      :type client_id: int
      :param node_id: The node clicked on.
      :type node_id: int | str



   .. py:method:: onClickEdge(client_id: int, edge_id: int | str)

      When a user clicks on an edge, this method is called.

      :param client_id: Value identifying the client
      :type client_id: int
      :param edge_id: The edge clicked on.
      :type edge_id: int | str



.. py:class:: ArrowOptions

   Bases: :py:obj:`ToDictMixin`


   Arrow options for edges.


   .. py:attribute:: to
      :type:  ArrowStyle | None
      :value: None



   .. py:attribute:: middle
      :type:  ArrowStyle | None
      :value: None



   .. py:attribute:: from_
      :type:  ArrowStyle | None
      :value: None



.. py:class:: ArrowStyle

   Bases: :py:obj:`ToDictMixin`


   Individual arrow style options.


   .. py:attribute:: enabled
      :type:  bool | None
      :value: None



   .. py:attribute:: imageHeight
      :type:  int | None
      :value: None



   .. py:attribute:: imageWidth
      :type:  int | None
      :value: None



   .. py:attribute:: scaleFactor
      :type:  float | None
      :value: None



   .. py:attribute:: src
      :type:  str | None
      :value: None



.. py:class:: Edge

   Represents an edge between nodes in the network graph.

   .. attribute:: from_

      Source node ID

      :type: int | str

   .. attribute:: to

      Target node ID

      :type: int | str

   .. attribute:: id

      Unique ID for the edge, automatically generated by default

      :type: int | str

   .. attribute:: options

      Optional Edge-specific styling and behavior options

      :type: EdgeOptions | None

   .. attribute:: title

      Optional tooltip content (plain text or HTML)

      :type: str | None


   .. py:attribute:: from_
      :type:  int | str


   .. py:attribute:: to
      :type:  int | str


   .. py:attribute:: id
      :type:  int | str
      :value: ''



   .. py:attribute:: options
      :type:  EdgeOptions | None
      :value: None



   .. py:attribute:: title
      :type:  str | None
      :value: None



   .. py:method:: __post_init__()

      Validate tooltip behavior after initialization.



   .. py:method:: toDict() -> dict[str, JsonType]

      Convert edge to dictionary for JSON serialization.



.. py:class:: NetworkGraph

   Bases: :py:obj:`ToDictMixin`


   Represents a graph with nodes, edges, and global options.

   .. attribute:: nodes

      Nodes in the graph. Default is empty list.

      :type: list[Node]

   .. attribute:: edges

      Edges connecting the nodes. Default is empty list.

      :type: list[Edge]

   .. attribute:: options

      Global options for the graph.

      :type: NetworkOptions

   .. attribute:: title

      Title for the graph. Default is "kdFlex Graph Visualization"

      :type: str


   .. py:attribute:: nodes
      :type:  list[Node]
      :value: []



   .. py:attribute:: edges
      :type:  list[Edge]
      :value: []



   .. py:attribute:: options
      :type:  NetworkOptions


   .. py:attribute:: title
      :type:  str
      :value: 'kdFlex Graph Visualization'



   .. py:method:: clone() -> Self

      Get a deep copy.



   .. py:method:: __or__(other: Self) -> Self

      Take the union of this graph and other.

      :param other: The other graph to take the union with.
      :type other: Self

      :returns: A union of this graph and other.
      :rtype: Self



   .. py:method:: __ior__(other: Self) -> Self

      Take the union of this graph and other, but removes duplicates.

      :param other: The other graph to union with.
      :type other: Self

      :returns: The union of this graph and other with duplicates removed.
      :rtype: Self



   .. py:method:: removeIsolatedNodes()

      Remove any nodes that aren't touched by an edge.



.. py:class:: NetworkOptions

   Bases: :py:obj:`ToDictMixin`


   Complete network configuration options.


   .. py:attribute:: nodes
      :type:  NodeOptions | None
      :value: None



   .. py:attribute:: edges
      :type:  EdgeOptions | None
      :value: None



   .. py:attribute:: physics
      :type:  PhysicsOptions | None
      :value: None



   .. py:attribute:: layout
      :type:  LayoutOptions | None
      :value: None



   .. py:attribute:: interaction
      :type:  InteractionOptions | None
      :value: None



   .. py:attribute:: groups
      :type:  GroupOptions | None
      :value: None



   .. py:attribute:: configure
      :type:  ConfigureOptions | None
      :value: None



   .. py:attribute:: clustering
      :type:  ClusteringOptions | None
      :value: None



   .. py:attribute:: manipulation
      :type:  ManipulationOptions | None
      :value: None



   .. py:method:: __post_init__()

      Set default values after initialization.



.. py:class:: NodeColorOptions

   Bases: :py:obj:`ToDictMixin`


   Color options for nodes.


   .. py:attribute:: border
      :type:  str | None
      :value: None



   .. py:attribute:: background
      :type:  str | None
      :value: None



   .. py:attribute:: highlight
      :type:  dict[str, str] | None
      :value: None



   .. py:attribute:: hover
      :type:  dict[str, str] | None
      :value: None



.. py:class:: NodeFontOptions

   Bases: :py:obj:`ToDictMixin`


   Font options for node labels.


   .. py:attribute:: color
      :type:  str | None
      :value: None



   .. py:attribute:: size
      :type:  int | None
      :value: None



   .. py:attribute:: face
      :type:  str | None
      :value: None



   .. py:attribute:: background
      :type:  str | None
      :value: None



   .. py:attribute:: strokeWidth
      :type:  int | None
      :value: None



   .. py:attribute:: strokeColor
      :type:  str | None
      :value: None



   .. py:attribute:: align
      :type:  str | None
      :value: None



   .. py:attribute:: vadjust
      :type:  int | None
      :value: None



   .. py:attribute:: multi
      :type:  bool | None
      :value: None



   .. py:attribute:: bold
      :type:  FontStyleOptions | None
      :value: None



   .. py:attribute:: ital
      :type:  FontStyleOptions | None
      :value: None



   .. py:attribute:: mono
      :type:  FontStyleOptions | None
      :value: None



.. py:class:: NodeOptions

   Bases: :py:obj:`ToDictMixin`


   Complete node styling and behavior options.


   .. py:attribute:: borderWidth
      :type:  int | None
      :value: None



   .. py:attribute:: borderWidthSelected
      :type:  int | None
      :value: None



   .. py:attribute:: brokenImage
      :type:  str | None
      :value: None



   .. py:attribute:: chosen
      :type:  ChosenNodeOptions | None
      :value: None



   .. py:attribute:: clusterNodeProperties
      :type:  ClusterNodeProperties | None
      :value: None



   .. py:attribute:: color
      :type:  str | NodeColorOptions | None
      :value: None



   .. py:attribute:: font
      :type:  NodeFontOptions | None
      :value: None



   .. py:attribute:: group
      :type:  str | None
      :value: None



   .. py:attribute:: hidden
      :type:  bool | None
      :value: None



   .. py:attribute:: icon
      :type:  str | None
      :value: None



   .. py:attribute:: iconFontFace
      :type:  str | None
      :value: None



   .. py:attribute:: iconSize
      :type:  int | None
      :value: None



   .. py:attribute:: image
      :type:  str | None
      :value: None



   .. py:attribute:: imagePadding
      :type:  int | None
      :value: None



   .. py:attribute:: label
      :type:  str | None
      :value: None



   .. py:attribute:: labelHighlightBold
      :type:  bool | None
      :value: None



   .. py:attribute:: level
      :type:  int | None
      :value: None



   .. py:attribute:: margin
      :type:  dict[str, int] | None
      :value: None



   .. py:attribute:: mass
      :type:  float | None
      :value: None



   .. py:attribute:: physics
      :type:  bool | None
      :value: None



   .. py:attribute:: scaling
      :type:  NodeScalingOptions | None
      :value: None



   .. py:attribute:: shadow
      :type:  ShadowOptions | None
      :value: None



   .. py:attribute:: shape
      :type:  NodeShape | None
      :value: None



   .. py:attribute:: shapeProperties
      :type:  ShapeProperties | None
      :value: None



   .. py:attribute:: size
      :type:  int | float | None
      :value: None



   .. py:attribute:: title
      :type:  str | None
      :value: None



   .. py:attribute:: value
      :type:  int | float | None
      :value: None



   .. py:attribute:: widthConstraint
      :type:  bool | int | WidthConstraintOptions | None
      :value: None



   .. py:attribute:: x
      :type:  float | None
      :value: None



   .. py:attribute:: y
      :type:  float | None
      :value: None



.. py:class:: EdgeOptions

   Bases: :py:obj:`ToDictMixin`


   Complete edge styling and behavior options.


   .. py:attribute:: arrows
      :type:  str | ArrowOptions | None
      :value: None



   .. py:attribute:: arrowStrikethrough
      :type:  bool | None
      :value: None



   .. py:attribute:: chosen
      :type:  ChosenEdgeOptions | None
      :value: None



   .. py:attribute:: color
      :type:  str | EdgeColorOptions | None
      :value: None



   .. py:attribute:: dashes
      :type:  bool | list[int] | None
      :value: None



   .. py:attribute:: font
      :type:  FontOptions | None
      :value: None



   .. py:attribute:: from_
      :type:  str | int | None
      :value: None



   .. py:attribute:: hidden
      :type:  bool | None
      :value: None



   .. py:attribute:: hoverWidth
      :type:  int | float | None
      :value: None



   .. py:attribute:: label
      :type:  str | None
      :value: None



   .. py:attribute:: label_highlight_bold
      :type:  bool | None
      :value: None



   .. py:attribute:: length
      :type:  float | None
      :value: None



   .. py:attribute:: physics
      :type:  bool | None
      :value: None



   .. py:attribute:: scaling
      :type:  EdgeScalingOptions | None
      :value: None



   .. py:attribute:: selectionWidth
      :type:  int | float | None
      :value: None



   .. py:attribute:: selfReferenceSize
      :type:  int | None
      :value: None



   .. py:attribute:: shadow
      :type:  ShadowOptions | None
      :value: None



   .. py:attribute:: smooth
      :type:  bool | SmoothOptions | None
      :value: None



   .. py:attribute:: title
      :type:  str | None
      :value: None



   .. py:attribute:: to
      :type:  str | int | None
      :value: None



   .. py:attribute:: value
      :type:  int | float | None
      :value: None



   .. py:attribute:: width
      :type:  int | float | None
      :value: None



   .. py:attribute:: widthConstraint
      :type:  bool | int | WidthConstraintOptions | None
      :value: None



.. py:class:: Node

   Represents a node in the network graph.

   .. attribute:: id

      Unique ID for the node, automatically generated by default

      :type: int | str

   .. attribute:: label

      Text label displayed on the node

      :type: str

   .. attribute:: options

      Optional Node-specific styling and behavior options

      :type: NodeOptions | None

   .. attribute:: title

      Optional tooltip content (plain text or HTML)

      :type: str | None

   .. attribute:: cluster_group

      Optional cluster group name for expandable clustering (enables
      clustering when set)

      :type: str | None


   .. py:attribute:: id
      :type:  int | str
      :value: ''



   .. py:attribute:: label
      :type:  str
      :value: ''



   .. py:attribute:: options
      :type:  NodeOptions | None
      :value: None



   .. py:attribute:: title
      :type:  str | None
      :value: None



   .. py:attribute:: cluster_group
      :type:  str | None
      :value: None



   .. py:method:: __post_init__()

      Validate tooltip behavior after initialization.



   .. py:method:: toDict() -> dict[str, JsonType]

      Convert node to dictionary for JSON serialization.



.. py:class:: SmoothOptions

   Bases: :py:obj:`ToDictMixin`


   Smooth options for edges.


   .. py:attribute:: type
      :type:  EdgeSmoothType | None
      :value: None



   .. py:attribute:: forceDirection
      :type:  str | None
      :value: None



   .. py:attribute:: roundness
      :type:  float | None
      :value: None



.. py:class:: FSM(name: str)

   Bases: :py:obj:`Karana.Core.Base`


   A class to implement finite state machines.

   The finite state machine is implemented as a graph that connects
   FSMStates with FSMTransitions.


   .. py:method:: create(name: str) -> FSM
      :staticmethod:


      Create a new instance of FSM.

      :param name: The name of the FSM.

      :returns: A pointer to the newly created instance of FSM.



   .. py:method:: getCurrentState() -> FSMState

      Get the current state.

      :returns: The current FSMState.



   .. py:method:: getState(name: str) -> FSMState

      Get the state with the provided name.

      :param name: The name of the state to retrieve.

      :returns: The FSMState with the provided name.



   .. py:method:: getStates() -> list[FSMState]

      Get a list of all the FSMStates in this FSM.

      :returns: A list of all the FSMStates in this FSM.



   .. py:method:: getTraceFSM() -> bool

      Get whether this FSM is printing trace messages or not.

      :returns: true if trace messages are being printed, false otherwise.



   .. py:method:: getTransition(parent_state: str, child_state: str) -> FSMTransition

      Get the transition that connects the two states with the provided
      names.

      :param parent_state: The name of the parent of the edge.
      :param child_state: The name of the child of the edge.

      :returns: The transition that connects the parent and child states with the
                names provided.



   .. py:method:: getVars() -> FSMVars


   .. py:method:: setCurrentState(state_name: str) -> None
                  setCurrentState(state: FSMState) -> None

      Set the current state of this FSM to the state with the provided name.

      :param name: The name of the state to set the FSM to.



   .. py:method:: setTraceFSM(arg0: bool) -> None

      Set whether this FSM prints trace messages or not.

      :param trace_fsm: true to set the FSM to print trace messages, false to
                        stop printing trace messages.



   .. py:method:: update() -> None

      Update the FSM.

      This updates the current state using the should_transition_fns of the
      FSMTransitions for the current state.



   .. py:property:: on_state_transition_fns
      :type: _FSMTransitionCallbackRegistry


      These functions will run whenever we transition to a new state


   .. py:method:: createFSMGraphVis(port: int = 0, network_options: Karana.KUtils.visjs.NetworkOptions = NetworkOptions()) -> Karana.KUtils.visjs.FSMGraphServer

      Create a visjs graph for this FSM.

      This also registers a method to update the graph as the FSM updates.

      :param port: The port to run the server on.
      :type port: int
      :param network_options: The network options for the graph.
      :type network_options: NetworkOptions

      :returns: The visjs GraphServer for this FSM.
      :rtype: FSMGraphServer



.. py:class:: FSMTransition(parent_state: FSMState, child_state: FSMState, transition_fn: collections.abc.Callable[[], bool])

   Bases: :py:obj:`Karana.Core.Base`


   An edge in the graph that makes up an FSM.


   .. py:method:: create(parent_state: FSMState, child_state: FSMState, transition_fn: collections.abc.Callable[[], bool]) -> FSMTransition
      :staticmethod:


      Create a new instance of FSMTransition.

      :param parent_state: The parent FSMState of the edge.
      :param child_state: The child FSMState of the edge.
      :param should_transition_fn: The function that indicates whether this
                                   state should transition or not. This should
                                   return true when it is time to transition,
                                   and false when it is not. The FSM.update
                                   method checks these functions to decide when
                                   to transition.

      :returns: A pointer to the newly created instance of FSMTransition.



   .. py:method:: getChildState() -> FSMState

      Get the child state for this edge.

      :returns: The child state for this edge.



   .. py:method:: getParentState() -> FSMState

      Get the parent state for this edge.

      :returns: The parent state for this edge.



   .. py:property:: on_transition_fns
      :type: Karana.Core.VoidCallbackRegistry


      Functions that execute when transitioning on this edge


   .. py:property:: should_transition_fn
      :type: collections.abc.Callable[[], bool]


      Function that indicates if we should transition. true for yes and
      false for no.


.. py:class:: FSMGraphServer(fsm: Karana.KUtils.FSM, *, port: int = 0, network_options: Karana.KUtils.visjs._datatypes.NetworkOptions = NetworkOptions())

   Bases: :py:obj:`Karana.KUtils.visjs._server.GraphServer`


   Specialized GraphServer for FSM viewing.

   Given an FSM, this automatically generates a graph. The class methods provide
   access to do common tasks such as manually change the color of a node or edge.


   .. py:attribute:: nodes
      :type:  dict[str, Karana.KUtils.visjs._datatypes.Node]


   .. py:attribute:: edges
      :type:  dict[str, Karana.KUtils.visjs._datatypes.Edge]


