public static LinkedListCoupling Uncompress(IIntCoupling coupled, List<List<int>> classes, double[] multiplicators) { int n = multiplicators.Length; LinkedListCoupling res = new LinkedListCoupling(n); ICollection<int> coupling_i; for (int k = 0; k < coupled.Length; ++k) { coupling_i = coupled[k]; foreach (int l in coupling_i) { foreach (int i in classes[k]) foreach (int j in classes[l]) if (!coupled[l].Contains(k)) res.Add(new Couple(i, j)); else if (k < l) res.Add(new PartialCouple(i, j)); } } Console.WriteLine("({0})\tCompressed couples uncompressed.\n", System.DateTime.Now); foreach (List<int> cl in classes) for (int i = 0; i < cl.Count; ++i) for (int j = i + 1; j < cl.Count; ++j) res.Add(new FullCouple(cl[i], cl[j], multiplicators[cl[j]], multiplicators[cl[i]])); Console.WriteLine("({0})\tFully coupled pairs added.\n", System.DateTime.Now); return res; }
public ICoupling ToCoupling() { LinkedListCoupling res = new LinkedListCoupling(n); ICollection<int> coupled; for (int i = 0; i < n; ++i) if (this.max[i]) { coupled = this.coupled[i]; foreach (int j in coupled) if (this.max[j]) { if (!maxima[j][i]) { if (i < j) res.Add(new PartialCouple(i, j)); } else res.Add(new Couple(i, j)); } } return res; }