예제 #1
0
        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);
        }
예제 #2
0
 public void ScriptChanged(VM.Interpreter script)
 {
     lock (_scriptChangeLock)
     {
         _dirtyScripts[script.ItemId] = script;
         if (!_delayQueue.ContainsKey(script.ItemId))
         {
             _delayQueue.Add(script.ItemId, DateTime.Now + SAVE_INTERVAL);
             _scheduler.RequestStateData(new StateDataRequest(script.ItemId, this.StateAvailable));
         }
     }
 }
예제 #3
0
        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 + " > ");
            }
        }
예제 #4
0
        protected virtual string DoObject2Delete(Stream request, string path, string param, OSHttpRequest httpRequest, OSHttpResponse httpResponse)
        {
            if (!Util.CheckHttpAuthorization(_gridSendKey, httpRequest.Headers))
            {
                m_log.WarnFormat("[REST COMMS]: /object2/ communication from untrusted peer {0}", httpRequest.RemoteIPEndPoint.Address.ToString());
                httpResponse.StatusCode = 401;
                return("Untrusted");
            }

            //m_log.Debug(" >> " + request["http-method"] + " " + request["content-type"] + " uri=" + request["uri"]);

            long nonceID = GetNonceID(httpRequest.Headers);

            lock (_pastDeletes)
            {
                _pastDeletes.Add(nonceID, DateTime.Now + TimeSpan.FromMinutes(5));
                FlushExpiredDeletes();
            }

            UUID   objectID;
            string action;
            ulong  regionHandle;

            if (!GetParams(path, out objectID, out regionHandle, out action))
            {
                m_log.InfoFormat("[REST COMMS]: Invalid parameters for object message {0}", path);
                httpResponse.StatusCode = 400;
                return("Invalid Parameters");
            }

            // This is the meaning of PUT object
            bool result = m_localBackend.SendDeleteObject(regionHandle, objectID, nonceID);

            if (result)
            {
                httpResponse.StatusCode = 200;
            }
            else
            {
                // the ID was not found, store it to block creates (for a while)
                // m_log.WarnFormat("[REST COMMS]: Delete object not found - adding nonce ID {0} for object {1}", nonceID, objectID);
                httpResponse.StatusCode = 404;
            }

            return(result.ToString());
        }