Advertisement
Guest User

Untitled

a guest
Nov 28th, 2014
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. internal static List<T> BreadthFirstExpansion<T>(T root, Func<T,List<T>> getChildren) {
  2. List<T> list = new List<T>();
  3. list.Add(root);
  4. foreach(T entry in list) {
  5. List<T> children = getChildren(entry);
  6. if(children!=null) {
  7. foreach (T child in children)
  8. {
  9. if (!list.Contains(child)) list.Add(child);
  10. }
  11. }
  12. }
  13. return list;
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement