private static void GetParticipants(PVNode pvnode, IDictionary<string, ISet<SemanticVersion>> participants) { foreach (PNode child in pvnode.Children) { GetParticipants(child, participants); } }
private static void GetParticipants(PVNode pvnode, string id, IDictionary<string, ISet<SemanticVersion>> participants) { ISet<SemanticVersion> versions; if (!participants.TryGetValue(id, out versions)) { versions = new HashSet<SemanticVersion>(); participants.Add(id, versions); } versions.Add(pvnode.Version); foreach (PNode child in pvnode.Children) { GetParticipants(child, participants); } }
public static List<PNode> FindIndependentTrees(PNode original) { List<Subtree> subtrees = new List<Subtree>(); PVNode parent = original.Children.First(); foreach (PNode pnode in parent.Children) { //Console.Write("{0}: ", pnode.Id); HashSet<string> participants = new HashSet<string>(); participants.Add(pnode.Id); GetParticipants(pnode, participants); bool newSubtreeNeeded = true; foreach (Subtree subtree in subtrees) { if (subtree.HasOverlap(participants)) { subtree.Roots.Add(pnode); newSubtreeNeeded = false; break; } } if (newSubtreeNeeded) { Subtree newSubtree = new Subtree(); newSubtree.Roots.Add(pnode); foreach (string s in participants) { newSubtree.Participants.Add(s); } subtrees.Add(newSubtree); } //foreach (string participant in participants) //{ // Console.Write("{0} ", participant); //} //Console.WriteLine(); } List<PNode> result = new List<PNode>(); foreach (Subtree subtree in subtrees) { PNode newRoot = new PNode("$"); PVNode newRootVersion = new PVNode(new SemanticVersion(0)); newRoot.Children.Add(newRootVersion); foreach (PNode newRootChild in subtree.Roots) { newRootVersion.AddChild(newRootChild); } result.Add(newRoot); } return result; }
public static void GetParticipants(PVNode pvnode, HashSet<string> participants) { foreach (PNode child in pvnode.Children) { GetParticipants(child, participants); } }