private Edge getLeavingEdge(String toNodeId) { Collection<Edge> edges = graph.getNode(toNodeId).getLeavingEdgeSet(); if (edges.size() == 1) return edges.iterator().next(); else { for (Edge e : edges) { if (e.getId().startsWith("shipment")) { continue; } return e; } } return null; }
private void removeNodeAndBelongingEdges(String nodeId, VehicleRoute fromRoute) { Node node = graph.getNode(nodeId); markRemoved(node); Edge entering = getEnteringEdge(nodeId); removeEdge(entering.getId()); if (node.getLeavingEdgeSet().isEmpty()) { if (fromRoute.getVehicle().isReturnToDepot()) throw new IllegalStateException("leaving edge is missing"); return; } Edge leaving = getLeavingEdge(nodeId); removeEdge((leaving.getId())); Node from = entering.getNode0(); Node to = leaving.getNode1(); if (!fromRoute.getActivities().isEmpty()) { addEdge(makeEdgeId(from, to), from.getId(), to.getId()); } }
removeEdge(enteringFromNode.getId()); removeEdge(enteringToNode.getId()); if (graph.getNode(toNodeId).getLeavingEdgeSet().isEmpty()) { if (fromRoute.getVehicle().isReturnToDepot()) throw new IllegalStateException("leaving edge is missing");
// let n be the clicked node... Iterator<Node> it = n.getBreadthFirstIterator(true); while(it.hasNext()){ Node m = it.next(); for(Edge e : m.getLeavingEdgeSet()) { e.setAttribute("ui.hide"); } if(n != m) { m.setAttribute("ui.hide"); } }
private Edge getLeavingEdge(String toNodeId) { Collection<Edge> edges = graph.getNode(toNodeId).getLeavingEdgeSet(); if (edges.size() == 1) return edges.iterator().next(); else { for (Edge e : edges) { if (e.getId().startsWith("shipment")) { continue; } return e; } } return null; }
/** * Compute the weighted leaving degree of a given node. For each * leaving edge the value contained by the 'weightAttribute' is * considered. If the edge does not have such an attribute, the value * 'defaultWeightValue' is used instead. Loop edges are counted once * if directed, but twice if undirected. The 'weightAttribute' must * contain a number or the default value is used. * @param node The node to consider. * @param weightAttribute The name of the attribute to look on edges, it must be a number. * @param defaultWeightValue The default weight value to use if edges do not have the 'weightAttribute'. * @return The leaving weighted degree. */ public static double leavingWeightedDegree(Node node, String weightAttribute, double defaultWeightValue) { double wdegree = 0; for(Edge edge:node.getLeavingEdgeSet()) { if(edge.hasNumber(weightAttribute)) { wdegree += edge.getNumber(weightAttribute); } else { wdegree += defaultWeightValue; } } return wdegree; }
/** * Compute the weighted leaving degree of a given node. For each * leaving edge the value contained by the 'weightAttribute' is * considered. If the edge does not have such an attribute, the value * 'defaultWeightValue' is used instead. Loop edges are counted once * if directed, but twice if undirected. The 'weightAttribute' must * contain a number or the default value is used. * @param node The node to consider. * @param weightAttribute The name of the attribute to look on edges, it must be a number. * @param defaultWeightValue The default weight value to use if edges do not have the 'weightAttribute'. * @return The leaving weighted degree. */ public static double leavingWeightedDegree(Node node, String weightAttribute, double defaultWeightValue) { double wdegree = 0; for(Edge edge:node.getLeavingEdgeSet()) { if(edge.hasNumber(weightAttribute)) { wdegree += edge.getNumber(weightAttribute); } else { wdegree += defaultWeightValue; } } return wdegree; }
/** * Create the new information and put in it all the paths between this * node and all its direct neighbours. * * @param node * The node to start from. * @param weightAttributeName * The key used to retrieve the weight attributes of edges. * This attribute but store a value that inherit Number. * @param directed * If false, the edge orientation is not taken into account. */ public APSPInfo(Node node, String weightAttributeName, boolean directed) { double weight = 1; Iterable<? extends Edge> edges = node.getLeavingEdgeSet(); source = node; if (!directed) edges = node.getEdgeSet(); for (Edge edge : edges) { Node other = edge.getOpposite(node); if (edge.hasAttribute(weightAttributeName)) weight = edge.getNumber(weightAttributeName); targets.put(other.getId(), new TargetPath(other, weight, null)); } }
/** * Create the new information and put in it all the paths between this * node and all its direct neighbours. * * @param node * The node to start from. * @param weightAttributeName * The key used to retrieve the weight attributes of edges. * This attribute but store a value that inherit Number. * @param directed * If false, the edge orientation is not taken into account. */ public APSPInfo(Node node, String weightAttributeName, boolean directed) { double weight = 1; Iterable<? extends Edge> edges = node.getLeavingEdgeSet(); source = node; if (!directed) edges = node.getEdgeSet(); for (Edge edge : edges) { Node other = edge.getOpposite(node); if (edge.hasAttribute(weightAttributeName)) weight = edge.getNumber(weightAttributeName); targets.put(other.getId(), new TargetPath(other, weight, null)); } }
private void removeNodeAndBelongingEdges(String nodeId, VehicleRoute fromRoute) { Node node = graph.getNode(nodeId); markRemoved(node); Edge entering = getEnteringEdge(nodeId); removeEdge(entering.getId()); if (node.getLeavingEdgeSet().isEmpty()) { if (fromRoute.getVehicle().isReturnToDepot()) throw new IllegalStateException("leaving edge is missing"); return; } Edge leaving = getLeavingEdge(nodeId); removeEdge((leaving.getId())); Node from = entering.getNode0(); Node to = leaving.getNode1(); if (!fromRoute.getActivities().isEmpty()) { addEdge(makeEdgeId(from, to), from.getId(), to.getId()); } }
removeEdge(enteringFromNode.getId()); removeEdge(enteringToNode.getId()); if (graph.getNode(toNodeId).getLeavingEdgeSet().isEmpty()) { if (fromRoute.getVehicle().isReturnToDepot()) throw new IllegalStateException("leaving edge is missing");