示例#1
0
        /**
         * Add a new element in the queue.
         * @param element
         */
        public void Add(E element)
        {
            elementWeightPairList.add(BinLocatePos(element.GetWeight(), isIncremental), element);

            if (limitSize > 0 && elementWeightPairList.size() > limitSize)
            {
                int sizeOfResults = elementWeightPairList.size();
                elementWeightPairList.remove(sizeOfResults - 1);
            }
        }
示例#2
0
        /**
         * Correct costs of successors of the input vertex using backward star form.
         * (FLOWER)
         *
         * @param vertex
         */
        public void CorrectCostBackward(BaseVertex vertex)
        {
            // 1. initialize the list of vertex to be updated
            var vertexList = new java.util.LinkedList <BaseVertex>();

            vertexList.add(vertex);

            // 2. update the cost of relevant precedents of the input vertex
            while (!vertexList.isEmpty())
            {
                BaseVertex curVertex       = vertexList.remove(0);
                double     costOfCurVertex = startVertexDistanceIndex[curVertex];

                ISet <BaseVertex> preVertexSet = graph.GetPrecedentVertices(curVertex);
                foreach (BaseVertex preVertex in preVertexSet)
                {
                    double costOfPreVertex = startVertexDistanceIndex.ContainsKey(preVertex) ?
                                             startVertexDistanceIndex[preVertex] : Graph.DISCONNECTED;

                    double freshCost = costOfCurVertex + graph.GetEdgeWeight(preVertex, curVertex);
                    if (costOfPreVertex > freshCost)
                    {
                        startVertexDistanceIndex.AddOrReplace(preVertex, freshCost);
                        predecessorIndex.AddOrReplace(preVertex, curVertex);
                        vertexList.add(preVertex);
                    }
                }
            }
        }
示例#3
0
        protected internal virtual void  createPrimitives(ViewGraphNode root)
        {
            LinkedList queue = new LinkedList();

            queue.add(root);
            while (!queue.isEmpty())
            {
                ViewGraphNode act = (ViewGraphNode)queue.remove(0);
                Shape         s   = null;
                if (act.Shape == null)
                {
                    s = makeShapeFromNode(act, queue);
                }
                else
                {
                    s = act.Shape;
                }
                if (act.ParentsChecked)
                {
                    continue;
                }
                act.ParentsChecked = true;
                for (Iterator it = act.Parents.iterator(); it.hasNext();)
                {
                    ViewGraphNode n  = (ViewGraphNode)it.next();
                    Shape         s1 = n.Shape;
                    if (s1 == null)
                    {
                        s1 = makeShapeFromNode(n, queue);
                    }
                    ConnectorLine line = new ConnectorLine(s1, s);
                    line.Color = System.Drawing.Color.Blue;
                    if (n.ReteNode is BaseJoin)
                    {
                        line.Color = System.Drawing.Color.Red;
                    }
                    addPrimitive(line);
                }
            }
        }
示例#4
0
 protected internal virtual void createPrimitives(ViewGraphNode root)
 {
     LinkedList queue = new LinkedList();
     queue.add(root);
     while (!queue.isEmpty())
     {
         ViewGraphNode act = (ViewGraphNode) queue.remove(0);
         Shape s = null;
         if (act.Shape == null)
         {
             s = makeShapeFromNode(act, queue);
         }
         else
         {
             s = act.Shape;
         }
         if (act.ParentsChecked)
             continue;
         act.ParentsChecked = true;
         for (Iterator it = act.Parents.iterator(); it.hasNext(); )
         {
             ViewGraphNode n = (ViewGraphNode) it.next();
             Shape s1 = n.Shape;
             if (s1 == null)
                 s1 = makeShapeFromNode(n, queue);
             ConnectorLine line = new ConnectorLine(s1, s);
             line.Color = System.Drawing.Color.Blue;
             if (n.ReteNode is BaseJoin)
                 line.Color = System.Drawing.Color.Red;
             addPrimitive(line);
         }
     }
 }