public List <CB> Parents() { List <CB> allParents = new List <CB> { this }; if (Parent != null) { foreach (CB parent in Parent.Parents()) { allParents.Add(parent); } } return(allParents); }
static int MinimalTransfers(CB Source, CB Destination) { List <CB> SourceParents = Source.Parents(); List <CB> DestinationParents = Destination.Parents(); int counter1 = 0; int counter2; foreach (CB stellar1 in SourceParents) { counter2 = 0; foreach (CB stellar2 in DestinationParents) { if (stellar1 == stellar2) { return(counter1 + counter2 - 2); } counter2++; } counter1++; } return(-1); }