netlist_carpentry.vis.dynamic.ipycytoscape
¶
Wrapper module for ipycytoscape, handling the creation of graph objects for Jupyter notebooks.
Classes:
-
GraphDataDict–Format of a dictionary containing graph data.
-
CytoscapeGraph–Interactive cytoscape graph visualization for Jupyter notebooks using ipycytoscape.
GraphDataDict
¶
Bases: TypedDict
Format of a dictionary containing graph data.
Attributes:
CytoscapeGraph
¶
Bases: BaseModel
Interactive cytoscape graph visualization for Jupyter notebooks using ipycytoscape.
Methods:
-
apply_config–Applies the given CytoscapeConfig to this instance's CytoscapeWidget.
-
update_format–Reads the current format definitions, translates them into css and applies them as stylesheet to the CytoscapeWidget.
-
format_node–Apply a given format to a given node.
-
format_nodes–Applies the given format to all nodes that match the given predicate.
-
format_in_out–Applies the given
in_formatto all input nodes andout_formatto all output nodes. -
get_node_map–Returns a dictionary with node names mapped to
ipycytoscape.Nodeobjects. -
get_node–Returns the node object for the given node identifier.
-
get_node_element–Returns the circuit object for the given node name.
-
get_edge_map–Returns a dictionary with wire names mapped to
ipycytoscape.Edgeobjects. -
get_edge–Returns the edge object for the given wire name.
-
toggle_label–Toggles the label of the given node id or object.
-
show–Create and return an ipycytoscape widget for display in Jupyter notebooks.
Attributes:
-
module_graph(ModuleGraph) –The ModuleGraph (i.e. the source graph) represented in this Cytoscape graph.
-
formats(Formats) –Contains all format definitons for this Cytoscape graph, along with a mapping of nodes to formats, and labels.
-
output(Output) –The output widget that handles output triggered by widget interaction.
-
cyto(CytoscapeWidget) –The CytoscapeWidget that contains the graph and properties.
-
info_box(HTML) –The info box widget containing data about the selected node.
module_graph
instance-attribute
¶
module_graph: ModuleGraph
The ModuleGraph (i.e. the source graph) represented in this Cytoscape graph.
formats
class-attribute
instance-attribute
¶
Contains all format definitons for this Cytoscape graph, along with a mapping of nodes to formats, and labels.
output
property
¶
The output widget that handles output triggered by widget interaction.
apply_config
¶
apply_config(cfg: CytoscapeConfig) -> None
Applies the given CytoscapeConfig to this instance's CytoscapeWidget.
The CytoscapeConfig defines environment values like 'min_zoom'/'max_zoom'
or 'panning_enabled' that handle how the rendered widget behaves.
Unset values (i.e. values that are None) are ignored, and the previous settings are kept.
Parameters:
-
(cfg¶CytoscapeConfig) –The config object with the parameter values to set. Unset parameters (i.e. parameters that are
None) are ignored, and the previous settings are kept.
update_format
¶
Reads the current format definitions, translates them into css and applies them as stylesheet to the CytoscapeWidget.
format_node
¶
format_node(node_id: str, format_name: str) -> None
Apply a given format to a given node.
The node must exist in the module graph, otherwise an ObjectNotFoundError is raised.
Parameters:
-
(node_id¶str) –The node id of the node to format. Must exist in the module graph
-
(format_name¶str) –The name of the format.
format_name='foo'will apply the format'foo', which in css conforms to the class'.foo'.
Raises:
-
ObjectNotFoundError–If no node with the given id exists in the module graph.
format_nodes
¶
format_nodes(
predicate: Callable[[str, GraphDataDict], bool], format_name: str
) -> None
Applies the given format to all nodes that match the given predicate.
The predicate is a callable (lambda or function) that takes two parameters, being the node name (string) and the node data (dictionary), while returning either True or False. If the condition is True for a given node, the given format is applied to this node.
Parameters:
-
(predicate¶Callable[[str, GraphDataDict], bool]) –A callable (lambda or function) that takes two parameters, being the node name (string) and the node data (dictionary), while returning either True or False.
-
(format_name¶str) –The format name to apply to all nodes that match the given condition.
format_in_out
¶
Applies the given in_format to all input nodes and out_format to all output nodes.
Parameters:
get_node_map
¶
Returns a dictionary with node names mapped to ipycytoscape.Node objects.
get_node
¶
Returns the node object for the given node identifier.
Parameters:
Raises:
-
ObjectNotFoundError–If no node with the given identifier exists.
Returns:
-
Node(Node) –An ipycytoscape Node object whose identifier matches the given identifier.
get_node_element
¶
Returns the circuit object for the given node name.
Parameters:
-
(node_id¶str) –The node name for which the circuit object (Instance or Module Port) should be retrieved.
Raises:
-
ObjectNotFoundError–If no node with the given name exists.
Returns:
get_edge_map
¶
Returns a dictionary with wire names mapped to ipycytoscape.Edge objects.
get_edge
¶
Returns the edge object for the given wire name.
Parameters:
Raises:
-
ObjectNotFoundError–If no edge with the given wire name exists.
Returns:
-
Edge(Edge) –An ipycytoscape Edge object whose identifier matches the given wire name.
toggle_label
¶
Toggles the label of the given node id or object.
If the name of the node is currently shown, it will switch to the type of the node. If the type of the node is currently shown, it will switch to the name of the node instead.
Parameters: