Residue Problem

Added residue problem to examples.py

Also state_by_node2state_by_state function from earlier work