BNMPy.vis

BNMPy.vis.is_entire_rule_negated(rule)[source]

Check if the entire rule is a single negated expression like !(A | B).

Returns True for rules like:
  • !(A | B)

  • !(A & B & C)

  • ! (A | B)

Returns False for rules like:
  • !(A) | B (negation is only partial)

  • A & !B (negation is on individual variable)

  • !A (no parentheses)

BNMPy.vis.read_logic_rules(source)[source]

Reads logic rules from a file path or from a string containing rules.

Args:

source (str): Path to the file or the string containing logic rules.

Returns:

dict: Mapping from variable names to their logic rules.

BNMPy.vis.extract_logic_rules_from_network(network)[source]

Extract logic rules from a BooleanNetwork or PBN object using stored equations.

Args:

network: BooleanNetwork or ProbabilisticBN object

Returns:

dict: Mapping from variable names to their logic rules (for BN) or list of rules (for PBN) dict: Mapping from edges to probabilities (for PBN) or empty dict (for BN)

BNMPy.vis.build_igraph_pbn(logic_rules, edge_probabilities)[source]

Build igraph for PBN with multiple rules per node.

BNMPy.vis.build_igraph(logic_rules)[source]

Build igraph for BN with single rule per node.

BNMPy.vis.create_matplotlib_visualization(logic_rules, removed_nodes=None, removed_edges=None, measured_nodes=None, perturbed_nodes=None, color_node=None)[source]

Create a matplotlib-based visualization for Jupyter notebooks.

Args:

color_node (str): If provided, all nodes will use this color (overrides default coloring)

BNMPy.vis.vis_network(source, output_html='network_graph.html', interactive=False, removed_nodes=None, removed_edges=None, measured_nodes=None, perturbed_nodes=None, color_node=None, color_edge=None, physics=True)[source]

Visualize the logic graph using PyVis and igraph.

Args:
source: Logic rules (dict), file path (str), network string (str),

BooleanNetwork object, or ProbabilisticBN object

output_html (str): Output HTML file name. interactive (bool): If True, return the network visualization in interactive html file removed_nodes (set): Set of node names that were removed (shown in grey) removed_edges (set): Set of edge tuples that were removed (shown in grey) measured_nodes (set): Set of node names that are measured (shown in orange) perturbed_nodes (set): Set of node names that are perturbed (shown in red) color_node (str): If provided, all nodes will use this color (e.g., ‘lightblue’, ‘#FF5733’) color_edge (str): If provided, all edges will use this color. If None, edges are colored

by regulation type (blue for inhibition, red for activation)

physics (bool): If True, enable physics simulation

BNMPy.vis.vis_compression(original_network, compressed_network, compression_info, output_html='compression_comparison.html', interactive=False)[source]

Visualize the original network with removed/collapsed nodes highlighted.

Args:

original_network: Original BooleanNetwork or ProbabilisticBN compressed_network: Compressed network (not used for visualization) compression_info: Dictionary with compression information output_html (str): Output HTML file name interactive (bool): If True, return network visualization in interactive html file

BNMPy.vis.vis_extension(original_network, extended_network, output_html='network+KG.html', interactive=True, color_node='lightblue', color_edge=None, extension_color_node='#E1F2D0', extension_color_edge=None, physics=True)[source]

Visualize the network with KG (Knowledge Graph) extension, highlighting new nodes and edges.

Args:

original_network: Original BooleanNetwork or ProbabilisticBN extended_network: Extended network with additional nodes/edges output_html (str): Output HTML file name interactive (bool): If True, return network visualization in interactive html file color_node (str): Color for nodes from the original network (e.g., ‘lightblue’, ‘#FF5733’).

If None, nodes are colored by type (input/output/intermediate)

color_edge (str): Color for edges from the original network. If None, edges are colored

by regulation type (blue for inhibition, red for activation)

extension_color_node (str): Color for new nodes present only in KG (e.g., ‘#E1F2D0’) extension_color_edge (str): Color for new edges present only in KG. If None, edges are

colored by regulation type (blue for inhibition, red for activation)

physics (bool): If True, enable physics simulation

BNMPy.vis.create_matplotlib_extension_visualization(logic_rules, new_nodes, new_edges, color_node='lightblue', extension_color_node='#E1F2D0', extension_color_edge=None)[source]

Create a matplotlib-based visualization for extension comparison.

Args:

logic_rules: Dictionary of logic rules new_nodes: Set of new node names from KG extension new_edges: Set of new edge tuples from KG extension color_node (str): Color for nodes from the original network extension_color_node (str): Color for new nodes from KG extension_color_edge (str): Color for new edges from KG. If None, uses default color