public bool Equals(Triple other) { if (ReferenceEquals(null, other)) return false; if (ReferenceEquals(this, other)) return true; return source == other.source && destination == other.destination; }
/// <summary> /// Process the gender of the non-tree edges /// </summary> /// <param name="parentString"></param> /// <param name="indiString"></param> /// <param name="Gender"></param> /// <returns></returns> public static String ProcessGender(String parentString, String indiString, int Gender) { String R = ""; //The delimiter to represent different gender char GenderSymbol = (Gender == 1 ? Utils.DelimiterMale : Utils.DelimiterFemale); //If this is the first time that one individual get non-tree edges //from its parent if (indiString == null) { List<Triple> temp = SplitString(parentString); foreach (Triple t in temp) { R += GenderSymbol + t.source + GenderSymbol + t.destination; } return R; } else //this is not the first time //therefore we have to merge the non-tree edges from its parents properly { HashSet<Triple> result = new HashSet<Triple>(); List<Triple> parent = SplitString(parentString); List<Triple> indi = SplitString(indiString); //First add the non-tree edges of the current individual to the result set foreach (Triple t in indi) { result.Add(t); } //Second, try to merge the non-tree edges from the parent foreach (Triple t in parent) { //if the result set already contains the current non-tree edge //we have to update the gender to indicate that this non-tree edge //is from both parents if (result.Contains(t)) { result.Remove(t); t.Gender = Utils.DelimiterBoth; result.Add(t); } else //otherwise we simply add it to the result set { Triple tempT = new Triple(t.source, t.destination, GenderSymbol); result.Add(tempT); } } //output the result set as a string foreach (Triple t in result) { R += t.Gender + t.source + t.Gender + t.destination; } return R; } }