/** * Create an edge from 2 existing nodes. If the cost is 0.0 then calculate the cost based on the * physical distance between the nodes. <br> * * @param from 'from' node * @param to 'to' node * @param cost traversal cost */ public GraphEdge(GraphNode from, GraphNode to, double cost) { this.from = from; this.to = to; if (cost == 0.0f) { cost = Math.sqrt( (to.x() - from.x()) * (to.x() - from.x()) + (to.y() - from.y()) * (to.y() - from.y()) + (to.z() - from.z()) * (to.z() - from.z())); } this.cost = cost; }