// the behavior for calculating the cost of each edge. GraphGenerator { {{ public static int InfiniteCost = Integer.MAX_VALUE; }} void calculateCost(Image im) bypassing {PathData, NodeList} to GraphNode { before IntermediateNode {{ int cost = GraphGenerator.InfiniteCost; if(!im.outsideImage(host.get_edgeloc().get_left()) && !im.outsideImage(host.get_edgeloc().get_right()) //&&host.hasOutgoinEdges() ) { // get left pixel value int leftVal = im.getPixelVal(host.get_edgeloc().get_left()); // get right pixel value int rightVal = im.getPixelVal(host.get_edgeloc().get_right()); // calculate the cost cost = im.get_maxPixelVal() - (rightVal - leftVal); host.printNode(); System.out.println("cost = " + im.get_maxPixelVal() + " - (" + rightVal + " - " + leftVal +")"); } // set the cost host.get_nodedata().set_cost(cost); }} } } GraphNode { {{ public boolean hasOutgoinEdges() { return false; } public boolean costIsInfinite() { if (nodedata.cost == GraphGenerator.InfiniteCost) return true; return false; } public boolean pathCostIsInfinite() { int cost = getPathCost(); if (cost == GraphGenerator.InfiniteCost) return true; return false; } public void setCostToInfinite() { nodedata.cost = GraphGenerator.InfiniteCost; } }} } IntermediateNode { {{ public boolean hasOutgoinEdges() { if (nodelist != null) return true; return false; } }} } SourceNode { {{ public boolean hasOutgoinEdges() { if (nodelist != null) return true; return false; } }} }