public override TraversalBranch Next(TraversalContext metadata) { TraversalBranch result = null; while (result == null) { if (_current == null) { _current = _superNodes.RemoveFirst(); if (_current == null) { return(null); } } else if (_current.expanded() > 0 && _current.expanded() % _threshold == 0) { _superNodes.AddLast(_current); _current = _current.parent(); continue; } TraversalBranch next = _current.next(_expander, metadata); if (next == null) { _current = _current.parent(); continue; } _current = next; result = _current; } return(result); }
public override TraversalBranch Next(TraversalContext metadata) { // Exhaust current if not already exhausted while (true) { TraversalBranch next = Current.next(Expander, metadata); if (next == null) { break; } long endNodeId = next.EndNode().Id; Visit <P> stay = Visits[endNodeId]; D cost = outerInstance.CalculateValue(next); P newPriority = outerInstance.AddPriority(next, CurrentAggregatedValue, cost); bool newStay = stay == null; if (newStay) { stay = new Visit <P>(newPriority); Visits[endNodeId] = stay; } if (newStay || !outerInstance.interest.CanBeRuledOut(stay.VisitCount, newPriority, stay.Cost)) { if (outerInstance.interest.Comparator().Compare(newPriority, stay.Cost) < 0) { stay.Cost = newPriority; } Queue.put(next, newPriority); } } do { // Pop the top from priorityMap Entry <TraversalBranch, P> entry = Queue.pop(); if (entry != null) { Current = entry.Entity; Visit <P> stay = Visits[Current.endNode().Id]; stay.VisitCount++; if (outerInstance.interest.StillInteresting(stay.VisitCount)) { CurrentAggregatedValue = entry.Priority; return(Current); } } else { return(null); } } while (true); }
private IEnumerator <TraversalBranch> GatherSourceIterator(TraversalContext metadata) { LinkedList <TraversalBranch> queue = new LinkedList <TraversalBranch>(); queue.AddLast(_current.next(_expander, metadata)); while (true) { IList <TraversalBranch> level = GatherOneLevel(queue, metadata); if (level.Count == 0) { break; } queue.addAll(0, level); } return(queue.GetEnumerator()); }
public override TraversalBranch Next(TraversalContext metadata) { TraversalBranch result = null; while (result == null) { if (_current == null) { return(null); } TraversalBranch next = _current.next(_expander, metadata); if (next == null) { _current = _current.parent(); continue; } _current = next; result = _current; } return(result); }
public override TraversalBranch Next(TraversalContext metadata) { TraversalBranch result = null; while (result == null) { TraversalBranch next = _current.next(_expander, metadata); if (next != null) { _queue.AddLast(next); result = next; } else { _current = _queue.RemoveFirst(); if (_current == null) { return(null); } } } return(result); }