added cycle_free algorithm