Python implementation of string junction calculations.