/** * The number of entity passage on the given edge. * @param edge The edge to look at. * @return The number of passes on the edge. */ public double getPasses(Edge edge) { return edge.getNumber(context.passesAttribute); }
/** * The number of entity passage on the given edge. * @param edge The edge to look at. * @return The number of passes on the edge. */ public double getPasses(Edge edge) { return edge.getNumber(context.passesAttribute); }
protected double getWeight(Edge e) { if (weightAttribute == null) return 1.0; double w = e.getNumber(weightAttribute); if (Double.isNaN(w)) return 1; return w; }
protected double getWeight(Edge e) { if (weightAttribute == null) return 1.0; double w = e.getNumber(weightAttribute); if (Double.isNaN(w)) return 1; return w; }
/** * The weight of an edge. * @param e The edge. * @return The weight of the edge. */ protected double weight(Edge e) { if (!e.hasAttribute(context.weightAttribute)) return 1.0; return e.getNumber(context.weightAttribute); } }
/** * The weight of an edge. * @param e The edge. * @return The weight of the edge. */ protected double weight(Edge e) { if (!e.hasAttribute(context.weightAttribute)) return 1.0; return e.getNumber(context.weightAttribute); } }
protected double getLength(Edge edge, Node dest) { double lenght = 0; if (element != Element.NODE) lenght += lengthAttribute == null ? 1 : edge .getNumber(lengthAttribute); if (element != Element.EDGE) lenght += lengthAttribute == null ? 1 : dest .getNumber(lengthAttribute); if (lenght < 0) throw new IllegalStateException("Edge " + edge.getId() + " has negative lenght " + lenght); return lenght; }
protected double getLength(Edge edge, Node dest) { double lenght = 0; if (element != Element.NODE) lenght += lengthAttribute == null ? 1 : edge .getNumber(lengthAttribute); if (element != Element.EDGE) lenght += lengthAttribute == null ? 1 : dest .getNumber(lengthAttribute); if (lenght < 0) throw new IllegalStateException("Edge " + edge.getId() + " has negative lenght " + lenght); return lenght; }
private void fillDistanceMapWeighted(Node[] theSortedArray) { for (Node aNode : theSortedArray) { for (Edge anEdge : aNode.getEachEnteringEdge()) { Node aSourceNode = anEdge.getSourceNode(); Node aTargetNode = anEdge.getTargetNode(); double aWeight = anEdge.getNumber(getWeightAttribute()); Double aMaxDistance = Math.max(distanceMap.get(aTargetNode), distanceMap.get(aSourceNode) + aWeight); distanceMap.put(aTargetNode, aMaxDistance); } } }
protected double c(State x, State y) { Edge e = x.node.getEdgeBetween(y.node); if (e != null) { if (e.hasNumber(COST_ATTRIBUTE)) return e.getNumber(COST_ATTRIBUTE); else return defaultEdgeWeight; } return Double.NaN; }
private void initializeAlgorithm() { for (Node aNode : graph.getEachNode()) { for (Edge anEdge : aNode.getEachEdge()) { double aWeight = anEdge.getNumber(getWeightAttribute()); if (Double.isNaN(aWeight)) { weighted = false; } } distanceMap.put(aNode, 0.0); } }
protected double c(State x, State y) { Edge e = x.node.getEdgeBetween(y.node); if (e != null) { if (e.hasNumber(COST_ATTRIBUTE)) return e.getNumber(COST_ATTRIBUTE); else return defaultEdgeWeight; } return Double.NaN; }
/** * Increment the count of the given node and edge. * @param e The edge. * @param n The node. */ protected void addPass(Edge e, Node n) { e.setAttribute(context.passesAttribute, e.getNumber(context.passesAttribute) + 1); n.setAttribute(context.passesAttribute, n.getNumber(context.passesAttribute) + 1); }
/** * Increment the count of the given node and edge. * @param e The edge. * @param n The node. */ protected void addPass(Edge e, Node n) { e.setAttribute(context.passesAttribute, e.getNumber(context.passesAttribute) + 1); n.setAttribute(context.passesAttribute, n.getNumber(context.passesAttribute) + 1); }
/** * The weight of the edge between 'from' and 'to'. * * @param from * The origin node. * @param to * The target node. * @return The weight on the edge between 'form' and 'to'. */ public double weight(Node from, Node to) { Edge edge = from.getEdgeBetween(to.getId()); if (edge != null) { if (edge.hasAttribute(weightAttributeName)) return edge.getNumber(weightAttributeName); else return 1.0; } else { return 0.0; } }
/** * Apply evaporation on each edge. */ protected void evaporate() { for(Edge edge: context.graph.getEachEdge()) { edge.setAttribute(context.passesAttribute, edge.getNumber(context.passesAttribute)*evaporation); } for(Node node: context.graph) { node.setAttribute(context.passesAttribute, node.getNumber(context.passesAttribute)*evaporation); } }
/** * Apply evaporation on each edge. */ protected void evaporate() { for(Edge edge: context.graph.getEachEdge()) { edge.setAttribute(context.passesAttribute, edge.getNumber(context.passesAttribute)*evaporation); } for(Node node: context.graph) { node.setAttribute(context.passesAttribute, node.getNumber(context.passesAttribute)*evaporation); } }
/** * Set the name of the attribute used to store the number of passes of each * entity on each edge or node. * * @param name * A string giving the passes name. */ public void setPassesAttribute(String name) { if (context.graph != null) { for (Edge e : context.graph.getEachEdge()) { e.addAttribute(name, e.getNumber(context.passesAttribute)); e.removeAttribute(context.passesAttribute); } for (Node n : context.graph) { n.addAttribute(name, n.getNumber(context.passesAttribute)); n.removeAttribute(context.passesAttribute); } } context.passesAttribute = name; }