public T add (T node, float value) { node.value = value; return add(node); }
public T remove (T node) { return remove(node.index); }
int maxSearchDistance = this.maxSearchDistance; openList.clear(); addToOpenList(getAlgoData(startNode)); getAlgoData(targetNode); while (maxDepth < maxSearchDistance && openList.size != 0) { AStarAlgoData lastData = currentData; currentData = openList.pop(); currentData.open = false; distance = currentData.depth; if (nextStepCost < neighborData.cost) { if (neighborData.open) { openList.remove(neighborData); neighborData.open = false;
protected boolean search (N startNode, N endNode, Heuristic<N> heuristic) { initSearch(startNode, endNode, heuristic); // Iterate through processing each node do { // Retrieve the node with smallest estimated total cost from the open list current = openList.pop(); current.category = CLOSED; // Terminate if we reached the goal node if (current.node == endNode) return true; visitChildren(endNode, heuristic); } while (openList.size > 0); // We've run out of nodes without finding the goal, so there's no solution return false; }
protected void initSearch (N startNode, N endNode, Heuristic<N> heuristic) { if (metrics != null) metrics.reset(); // Increment the search id if (++searchId < 0) searchId = 1; // Initialize the open list openList.clear(); // Initialize the record for the start node and add it to the open list NodeRecord<N> startRecord = getNodeRecord(startNode); startRecord.node = startNode; startRecord.connection = null; startRecord.costSoFar = 0; addToOpenList(startRecord, heuristic.estimate(startNode, endNode)); current = null; }
private T remove (int index) { Node[] nodes = this.nodes; Node removed = nodes[index]; nodes[index] = nodes[--size]; nodes[size] = null; if (size > 0 && index < size) down(index); return (T)removed; }
public T add (T node) { // Expand if necessary. if (size == nodes.length) { Node[] newNodes = new Node[size << 1]; System.arraycopy(nodes, 0, newNodes, 0, size); nodes = newNodes; } // Insert at end and bubble up. node.index = size; nodes[size] = node; up(size++); return node; }
@SuppressWarnings("unchecked") public IndexedAStarPathFinder (IndexedGraph<N> graph, boolean calculateMetrics) { this.graph = graph; this.nodeRecords = (NodeRecord<N>[])new NodeRecord[graph.getNodeCount()]; this.openList = new BinaryHeap<NodeRecord<N>>(); if (calculateMetrics) this.metrics = new Metrics(); }
current = openList.pop(); current.category = CLOSED;
protected void initSearch (N startNode, N endNode, Heuristic<N> heuristic) { if (metrics != null) metrics.reset(); // Increment the search id if (++searchId < 0) searchId = 1; // Initialize the open list openList.clear(); // Initialize the record for the start node and add it to the open list NodeRecord<N> startRecord = getNodeRecord(startNode); startRecord.node = startNode; startRecord.connection = null; startRecord.costSoFar = 0; addToOpenList(startRecord, heuristic.estimate(startNode, endNode)); current = null; }
private T remove (int index) { Node[] nodes = this.nodes; Node removed = nodes[index]; nodes[index] = nodes[--size]; nodes[size] = null; if (size > 0 && index < size) down(index); return (T)removed; }
public T add (T node) { // Expand if necessary. if (size == nodes.length) { Node[] newNodes = new Node[size << 1]; System.arraycopy(nodes, 0, newNodes, 0, size); nodes = newNodes; } // Insert at end and bubble up. node.index = size; nodes[size] = node; up(size++); return node; }
@SuppressWarnings("unchecked") public IndexedAStarPathFinder (IndexedGraph<N> graph, boolean calculateMetrics) { this.graph = graph; this.nodeRecords = (NodeRecord<N>[])new NodeRecord[graph.getNodeCount()]; this.openList = new BinaryHeap<NodeRecord<N>>(); if (calculateMetrics) this.metrics = new Metrics(); }
public T remove (T node) { return remove(node.index); }
public T add (T node, float value) { node.value = value; return add(node); }
protected boolean search (N startNode, N endNode, Heuristic<N> heuristic) { initSearch(startNode, endNode, heuristic); // Iterate through processing each node do { // Retrieve the node with smallest estimated total cost from the open list current = openList.pop(); current.category = CLOSED; // Terminate if we reached the goal node if (current.node == endNode) return true; visitChildren(endNode, heuristic); } while (openList.size > 0); // We've run out of nodes without finding the goal, so there's no solution return false; }
private T remove (int index) { Node[] nodes = this.nodes; Node removed = nodes[index]; nodes[index] = nodes[--size]; nodes[size] = null; if (size > 0 && index < size) down(index); return (T)removed; }
public T add (T node) { // Expand if necessary. if (size == nodes.length) { Node[] newNodes = new Node[size << 1]; System.arraycopy(nodes, 0, newNodes, 0, size); nodes = newNodes; } // Insert at end and bubble up. node.index = size; nodes[size] = node; up(size++); return node; }