boofun.visualization.decision_tree_export

Decision Tree Export Utilities.

This module provides utilities for exporting Boolean function decision trees to various formats including: - Text/ASCII representation - Graphviz DOT format - JSON structure - LaTeX/TikZ code

Functions

build_decision_tree(f[, max_depth])

Build a decision tree for a Boolean function.

export_decision_tree_dot(f[, var_names, ...])

Export decision tree as Graphviz DOT format.

export_decision_tree_json(f[, var_names, ...])

Export decision tree as JSON structure.

export_decision_tree_text(f[, var_names, ...])

Export decision tree as ASCII text.

export_decision_tree_tikz(f[, var_names, ...])

Export decision tree as LaTeX TikZ code.

Classes

DecisionTreeExporter(f[, var_names, max_depth])

Class for exporting decision trees in multiple formats.

DecisionTreeNode([variable, value, low, ...])

Represents a node in a decision tree.

boofun.visualization.decision_tree_export.export_decision_tree_text(f: BooleanFunction, var_names: List[str] | None = None, max_depth: int | None = None) str[source]

Export decision tree as ASCII text.

Parameters:
  • f – Boolean function

  • var_names – Variable names (default: x_0, x_1, …)

  • max_depth – Maximum depth

Returns:

ASCII representation

boofun.visualization.decision_tree_export.export_decision_tree_dot(f: BooleanFunction, var_names: List[str] | None = None, max_depth: int | None = None, graph_name: str = 'DecisionTree') str[source]

Export decision tree as Graphviz DOT format.

Parameters:
  • f – Boolean function

  • var_names – Variable names

  • max_depth – Maximum depth

  • graph_name – Name for the graph

Returns:

DOT format string

boofun.visualization.decision_tree_export.export_decision_tree_json(f: BooleanFunction, var_names: List[str] | None = None, max_depth: int | None = None) Dict[str, Any][source]

Export decision tree as JSON structure.

Parameters:
  • f – Boolean function

  • var_names – Variable names

  • max_depth – Maximum depth

Returns:

JSON-serializable dictionary

boofun.visualization.decision_tree_export.export_decision_tree_tikz(f: BooleanFunction, var_names: List[str] | None = None, max_depth: int | None = None) str[source]

Export decision tree as LaTeX TikZ code.

Parameters:
  • f – Boolean function

  • var_names – Variable names

  • max_depth – Maximum depth

Returns:

TikZ code string

class boofun.visualization.decision_tree_export.DecisionTreeExporter(f: BooleanFunction, var_names: List[str] | None = None, max_depth: int | None = None)[source]

Class for exporting decision trees in multiple formats.

Provides a unified interface for exporting Boolean function decision trees to various formats.

__init__(f: BooleanFunction, var_names: List[str] | None = None, max_depth: int | None = None)[source]

Initialize exporter.

Parameters:
  • f – Boolean function

  • var_names – Variable names

  • max_depth – Maximum depth for tree

property tree: DecisionTreeNode

Get the decision tree (built lazily).

to_text() str[source]

Export to ASCII text.

to_dot(graph_name: str = 'DecisionTree') str[source]

Export to Graphviz DOT format.

to_json() Dict[str, Any][source]

Export to JSON structure.

to_tikz() str[source]

Export to LaTeX TikZ.

save_dot(filename: str) None[source]

Save DOT to file.

depth() int[source]

Get tree depth.

size() int[source]

Get number of nodes.

summary() str[source]

Get tree summary.