/// <summary> /// Return the vertices from the vertex in the parameters up to the root. /// </summary> /// <param name="g"> The MTG. </param> /// <param name="vertexId"> The vertex identifier. </param> /// <returns> An iterator on the ancestors of the vertexId up to the root. </returns> public IEnumerable <int> FullAncestors(mtg g, int vertexId, string restrictedTo = "NoRestriction", string edgeType = "*", int containedIn = -1) { Dictionary <int, dynamic> edgeT = g.Property("Edge_Type"); int cScale; int v = vertexId; while (v != -1) { if (edgeType != "*" && edgeT.ContainsKey(v)) { if (edgeT[v] != edgeType) { yield break; } } if (restrictedTo == "SameComplex") { if (g.Complex(v) != g.Complex(vertexId)) { yield break; } } else { if (restrictedTo == "SameAxis") { if (edgeT.ContainsKey(v)) { if (edgeT[v] == "+") { yield break; } } } } if (containedIn != -1) { cScale = (int)g.Scale((int)containedIn); if (g.ComplexAtScale(v, cScale) != containedIn) { yield break; } } yield return(v); v = (int)g.Parent(v); } }
/// <summary> /// Internal method used by MtgIterator. /// </summary> IEnumerable <int> ScaleIterator(mtg tree, int vertexId, int complexId, Dictionary <int, bool> visited) { if (vertexId != -1 && !visited.ContainsKey(vertexId) && (tree.ComplexAtScale(vertexId, (int)tree.Scale(complexId)) == complexId)) { foreach (int v in ScaleIterator(tree, (int)tree.Complex(vertexId), complexId, visited)) { yield return(v); } visited.Add(vertexId, true); yield return(vertexId); } }