Ten-player Hearts held on against a stubborn Dundee to claim a narrow win to maintain their lead in the Scottish Premiership title race.