History and network states¶
History is implemented directly by Network; there is no separate
NetworkHistory class. Mutating decorated methods save deep node/edge
snapshots as NetworkState objects. Undo, redo, checkout, and subsequent
mutations form a branching tree.
Network history methods¶
Network ¶
A molecular interaction network.
The `Network` object is the central organizing component of the `neko`
module. It is the subject of all operations implemented here, including
topological algorithms, graph analysis, network visualization and
integration of database knowledge.
Args: initial_nodes: A list of initial nodes to be added to the network. sif_file: A SIF (Simple Interaction Format) file to load the network from. resources: A pandas DataFrame containing the resources database.
Methods:
Source code in neko/core/network.py
Attributes¶
Methods:¶
save_state ¶
Persist the current network snapshot and return its state id.
Source code in neko/core/network.py
set_max_history ¶
Set the maximum number of stored history states (None disables pruning).
Source code in neko/core/network.py
set_history_tracking ¶
suspend_history ¶
Temporarily suspend automatic state capture within the context.
Source code in neko/core/network.py
list_states ¶
Return a creation-ordered list of state metadata.
checkout ¶
Restore the network to a previously saved state.
Source code in neko/core/network.py
restore_state ¶
Backward compatible wrapper around :meth:checkout.
Source code in neko/core/network.py
undo ¶
Move to the parent state if available.
Source code in neko/core/network.py
redo ¶
Move to a child state. If more than one child exists, a specific state id is required.
Source code in neko/core/network.py
compare_states ¶
Compare two states identified by their ids.
Source code in neko/core/network.py
describe_history ¶
Pretty-print the branching history tree.
Source code in neko/core/network.py
describe_states ¶
history_graph ¶
Return a networkx DiGraph representing the state transitions.
history_digraph ¶
Return a Graphviz digraph for the history.
history_html ¶
Return an HTML snippet embedding the history graph.
Source code in neko/core/network.py
Snapshot value object¶
NetworkState ¶
NetworkState(nodes: DataFrame, edges: DataFrame, metadata: Optional[Dict[str, Any]] = None, state_id: Optional[int] = None, parent_ids: Optional[List[int]] = None)
Immutable snapshot of a network, with parent/child bookkeeping.
Source code in neko/core/network_state.py
Rendering helpers¶
build_history_graph ¶
Return a directed graph of the network state history.
Source code in neko/_visual/history.py
history_digraph ¶
Render history as a Graphviz Digraph.
Source code in neko/_visual/history.py
history_html ¶
history_html(network: 'Network', include_metadata: bool = True, div_class: str = 'neko-history-graph') -> str
Return an HTML snippet embedding the history graph as SVG.