change weight compute
This commit is contained in:
@@ -533,6 +533,18 @@ public class VendorsGraph extends ConnectibleGraph<Vendor> {
|
||||
return edge.getInstance(fuel, balance);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getWeight() {
|
||||
if (weight == null){
|
||||
Edge<Vendor> edge = getEdge();
|
||||
Optional<Traversal<Vendor>> head = getHead();
|
||||
weight = (head.isPresent() ? ((VendorsTraversalEntry)head.get()).getWeight() : 0) + (edge != null ? edge.getWeight() : 0);
|
||||
if (edge != null){
|
||||
weight = weight / (1+Math.floorDiv(profile.getLands() - this.size(),this.size()));
|
||||
}
|
||||
}
|
||||
return weight;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -334,7 +334,7 @@ public class Crawler<T> {
|
||||
while (!cur.isRoot()){
|
||||
Edge<T> edge = cur.getEdge();
|
||||
Edge<T> oEdge = oCur.getEdge();
|
||||
cmp = Double.compare(oEdge.weight, edge.weight);
|
||||
cmp = oEdge.compareTo(edge);
|
||||
if (cmp != 0) return cmp;
|
||||
cur = (CostTraversal<T>) cur.getHead().get();
|
||||
oCur = (CostTraversal<T>) oCur.getHead().get();
|
||||
@@ -568,7 +568,7 @@ public class Crawler<T> {
|
||||
}
|
||||
|
||||
protected class CostTraversalEntry extends TraversalEntry implements CostTraversal<T>, Comparable<CostTraversalEntry>{
|
||||
private Double weight;
|
||||
protected Double weight;
|
||||
|
||||
protected CostTraversalEntry(Vertex<T> vertex) {
|
||||
super(vertex);
|
||||
|
||||
Reference in New Issue
Block a user