from phasic import Graph, with_ipv # ALWAYS import phasic first
import sys
import numpy as np
from vscodenb import set_vscode_theme
set_vscode_theme()Visualizing state space
@with_ipv([1, 1])
def mesh(state, max_val=2):
transitions = []
for i in range(state.size):
if state[i] <= max_val:
child = state.copy()
child[i] += 1
trans = [child, state.sum()]
transitions.append(trans)
return transitions
graph = Graph(mesh)
graph.plot()Change node separation from the default of 1:
Also change the separation of nodes with different rank from the default of 1:
Plot node rank top to bottom (TB) rather than default left to right (LR):
Width of edges, size of font, unicolor, and size of figure:
graph.plot(size=(7, 5),
fontsize=20, rainbow=False, label_fmt=False, taillabel=True,
rate_fmt=lambda rate: f'''< <table bgcolor="white" border="0"><tr><td>{rate}</td></tr></table> >''',
edge_attr=dict(penwidth=3, labelfontcolor='blue', labeldistance=3, labelangle=0),
node_attr=dict(shape='circle', fillcolor='white', penwidth=2.5, fixedsize=True, width=1)
)