public IList <DirectedEdge> [] PathTo(int v) { verticesToCover = new IndexedPriorityQueue <DirectedEdge>(graph.VerticesCount); verticesToCover.Add(v, new DirectedEdge(0, 0, 0.0)); distTo[v] = 0; while (!verticesToCover.IsEmpty()) { var v1 = verticesToCover.DeleteMin(); var adjacentEdgeList = graph.Adj(v1.Key); foreach (var edge in adjacentEdgeList) { //if(marked[edge.To]) continue; if (distTo[edge.To] > (distTo[v1.Key] + edge.Weight)) { distTo[edge.To] = distTo[v1.Key] + edge.Weight; marked[edge.To] = true; hasPath[edge.To] = true; verticesToCover.Add(edge.To, edge); foreach (var item in listOfEdges[v1.Key]) { listOfEdges[edge.To].Add(item); } if (!listOfEdges[edge.To].Contains(edge)) { listOfEdges[edge.To].Add(edge); } } } } return(listOfEdges); }
private void FlushExpiredDeletes() { while (_pastDeletes.Count > 0) { KeyValuePair <long, DateTime> kvp = _pastDeletes.FindMinItemAndIndex(); if (kvp.Value <= DateTime.Now) { // m_log.WarnFormat("[REST COMMS]: Expiring deleted object nonce ID nonce ID {0}", kvp.Key); _pastDeletes.DeleteMin(); } else { break; } } }
/// <summary> /// Checks for kinematics that have not been updated in KINEMATIC_TRANSITION_TIME - WINDOW and /// changes them to statics if appropriate /// </summary> public void CheckForExipiredKinematics() { ulong currentTickCount = Util.GetLongTickCount(); while (_trackedObjects.Count > 0) { var lastUpdatedOn = _trackedObjects.FindMinItemAndIndex(); if (currentTickCount > lastUpdatedOn.Value && currentTickCount - lastUpdatedOn.Value > KINEMATIC_TRANSITION_WINDOW) { _trackedObjects.DeleteMin(); this.TransitionKinematic(lastUpdatedOn.Key); } else { break; } } }
public void Run() { //var iterator = graph.GetIterator(0).GetIterator().ToArray().Select(x => x as Edge).ToList(); //iterator.Sort(); var first = new Edge(0, 0, 0); minHeap.Add(0, first); while (!minHeap.IsEmpty()) { var min = minHeap.DeleteMin(); Console.WriteLine("Adding edge " + min); listOfEdges.Add(min.Value); Run(min.Key); } foreach (var edge in listOfEdges) { Console.Write(edge + " > "); } }