def _calculate_from_transitions(trans_probs):
 transitions = dict()
 for (from_state, to_state) in trans_probs:
  try:
   transitions[from_state].append(to_state)
  except KeyError:
   transitions[from_state] = [to_state]
 return transitions

def _calculate_from_transitions ( trans_probs ) : transitions = dict ( ) for ( from_state , to_state ) in trans_probs : try : transitions [ from_state ] . append ( to_state ) except KeyError : transitions [ from_state ] = [ to_state ] return transitions
calculate which from transitions are allowed for each state this looks through all of the trans_probs .