/// <summary> /// Given a collection of incidence matrices this function chooses the one which has least number of modified models /// </summary> /// <param name="IMSet"></param> /// <param name="IMf"></param> /// <returns></returns> private static int LeastModified(IncidenceMatrix[] IMSet, IncidenceMatrix IMf) { var IndexAndReversals = IMSet.Select((m, i) => new { Index = i, NReversed = IMf.Compare(m) }); return(IndexAndReversals.OrderBy(m => m.NReversed).First().Index); }