Implementation of the submodular relaxation algorithms