org.graphstream.algorithm
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 Euclidian 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
Euclidian 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.
Method Summary |
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. |
AStar.DistanceCosts
public AStar.DistanceCosts()
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 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 is next is
not directly connected to parent by an edge.
Copyright © 2011. All Rights Reserved.