A practical algorithm for the computation of the genus