Class AStar.DistanceCosts

java.lang.Object
org.graphstream.algorithm.AStar.DistanceCosts
All Implemented Interfaces:
AStar.Costs
Enclosing class:
AStar

public static class AStar.DistanceCosts
extends Object
implements AStar.Costs
An implementation of the Costs interface that assume that the weight of edges is an Euclidean distance in 2D or 3D. No weight attribute is used. Instead, for the G value, the edge weights are used. For the H value the Euclidean distance in 2D or 3D between the current node and the target node is used. For this Costs implementation to work, the graph nodes must have a position (either individual "x", "y" and "z" attribute, or "xy" attribute or even "xyz" attributes. If there are only "x" and "y" or "xy" attribute this works in 2D, else the third coordinate is taken into account.
  • Constructor Summary

    Constructors 
    Constructor Description
    DistanceCosts()  
  • Method Summary

    Modifier and Type Method Description
    double cost​(org.graphstream.graph.Node parent, org.graphstream.graph.Edge edge, org.graphstream.graph.Node next)
    Cost of displacement from parent to next.
    double heuristic​(org.graphstream.graph.Node node, org.graphstream.graph.Node target)
    Estimate cost from the given node to the target node.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • heuristic

      public double heuristic​(org.graphstream.graph.Node node, org.graphstream.graph.Node target)
      Description copied from interface: AStar.Costs
      Estimate cost from the given node to the target node.
      Specified by:
      heuristic in interface AStar.Costs
      Parameters:
      node - A node.
      target - The target node.
      Returns:
      The estimated cost between a node and a target node.
    • cost

      public double cost​(org.graphstream.graph.Node parent, org.graphstream.graph.Edge edge, org.graphstream.graph.Node next)
      Description copied from interface: AStar.Costs
      Cost of displacement from parent to next. The next node must be directly connected to parent, or -1 is returned.
      Specified by:
      cost in interface AStar.Costs
      Parameters:
      parent - The node we come from.
      edge - The definition of an heuristic. The heuristic is in charge of evaluating The edge used between the two nodes (in case this is a multi-graph).
      next - The node we go to.
      Returns:
      The real cost of moving from parent to next, or -1 if next is not directly connected to parent by an edge.