/// <summary> /// Perform a walk in the given RingSet, starting at a given Ring and /// recursively searching for other Rings connected to this ring. By doing /// this it finds all rings in the RingSet connected to the start ring, /// putting them in newRs, and removing them from rs. /// </summary> /// <param name="rs">The RingSet to be searched</param> /// <param name="ring">The ring to start with</param> /// <param name="newRs">The RingSet containing all Rings connected to ring</param> /// <returns>newRs The RingSet containing all Rings connected to ring</returns> private static IRingSet WalkRingSystem(IRingSet rs, IRing ring, IRingSet newRs) { IRing tempRing; var tempRings = rs.GetConnectedRings(ring); rs.Remove(ring); foreach (var container in tempRings) { tempRing = (IRing)container; if (!newRs.Contains(tempRing)) { newRs.Add(tempRing); newRs.Add(WalkRingSystem(rs, tempRing, newRs)); } } return(newRs); }