Archived
0

change weight compute

This commit is contained in:
iMoHax
2015-07-15 15:16:25 +03:00
parent 49d2126878
commit 929b0c2b26
2 changed files with 14 additions and 2 deletions

View File

@@ -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;
}
}

View File

@@ -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);