private List <string> RouteToLeafFrom(Term startTerm, int childrenIndex) { List <string> route = new List <string>(); Term t = startTerm; bool needToBookAPointToExplore = true; while (true) { //Lets book a point to futurely explore if (childrenIndex + 1 < startTerm.Children.Count && needToBookAPointToExplore) { missingToExplore te = new missingToExplore(); te.id = startTerm.Children[childrenIndex + 1]; te.nextIndexToExplore = childrenIndex + 1; toExplore.Add(te); needToBookAPointToExplore = false; } //choose the next term to explore if (t.Children.Count > 0) { t = getTermByID(t.Children[0]); route.Add(t.id); } else { break; } } return(route); }
/// <summary> /// This method returns one route having as a starting point an antry its nextIndexToExplore /// </summary> /// <param name="entry">The GO ID</param> /// <param name="startingIndex">The index of the is_a (i.e 0 stands for the first parent, 1 for the second, etc...)</param> /// <returns></returns> private List <string> RouteToRootFrom(string entry, int isAIndex) { List <string> rout = new List <string>(); List <string> endpoints = findTopMostNodes(); string cEntry = entry; rout.Add(cEntry); while (!endpoints.Contains(cEntry)) { List <string> theParents = new List <string>(); isAUPDic.TryGetValue(cEntry, out theParents); //Lets book a point to futurely explore if (isAIndex + 1 < theParents.Count) { missingToExplore te = new missingToExplore(); te.id = cEntry; te.nextIndexToExplore = isAIndex + 1; toExplore.Add(te); } cEntry = theParents[isAIndex]; if (isAIndex > 0) { isAIndex = 0; } rout.Add(cEntry); } return(rout); }