@Override public void informInsertionStarts(Collection<VehicleRoute> vehicleRoutes, Collection<Job> unassignedJobs) { if (!record()) return; fileSink.stepBegins(graph.getId(), 0, RECREATE); } }
@Override public void informInsertionEnds(Collection<VehicleRoute> vehicleRoutes) { if (!record()) return; fileSink.stepBegins(graph.getId(), 0, CLEAR_SOLUTION); removeRoutes(vehicleRoutes); }
@Override public void informAlgorithmEnds(VehicleRoutingProblem problem, Collection<VehicleRoutingProblemSolution> solutions) { VehicleRoutingProblemSolution solution = Solutions.bestOf(solutions); fileSink.stepBegins(graph.getId(), 0, BEFORE_RUIN_RENDER_SOLUTION); addRoutes(solution.getRoutes()); finish(); }
/** * Get the style of a given graph. * * @param graph * The node to search for. * @return The graph style. */ public StyleGroup getStyleFor(Graph graph) { String gid = byGraphIdGroups.get(graph.getId()); return groups.get(gid); }
/** * Get the style of a given graph. * * @param graph * The node to search for. * @return The graph style. */ public StyleGroup getStyleFor(Graph graph) { String gid = byGraphIdGroups.get(graph.getId()); return groups.get(gid); }
@Override public String toString() { return String.format("GraphListeners of %s.%s", g.getClass().getSimpleName(), g.getId()); } }
@Override public String toString() { return String.format("GraphListeners of %s.%s", g.getClass() .getSimpleName(), g.getId()); } }
private static String toString(Graph g) { StringBuilder buffer = new StringBuilder(); buffer.append("id=\"").append(g.getId()).append("\" node={"); for (Node n : g) buffer.append("\"").append(n.getId()).append("\", "); buffer.append("}, edges={"); for (Edge e : g.getEachEdge()) buffer.append("\"").append(e.getId()).append("\":\"") .append(e.getSourceNode().getId()).append("\"--\"") .append(e.getTargetNode().getId()).append("\", "); buffer.append("}"); return buffer.toString(); } }
private static String toString(Graph g) { StringBuilder buffer = new StringBuilder(); buffer.append("id=\"").append(g.getId()).append("\" node={"); for (Node n : g) buffer.append("\"").append(n.getId()).append("\", "); buffer.append("}, edges={"); for (Edge e : g.getEachEdge()) buffer.append("\"").append(e.getId()).append("\":\"") .append(e.getSourceNode().getId()).append("\"--\"") .append(e.getTargetNode().getId()).append("\", "); buffer.append("}"); return buffer.toString(); } }
public GraphListeners(Graph g) { super(g.getId()); this.sinkTime = new SinkTime(); this.sourceTime.setSinkTime(sinkTime); this.passYourWay = false; this.passYourWayAE = false; this.dnSourceId = null; this.dnTimeId = Long.MIN_VALUE; this.g = g; }
@Override public void informInsertionStarts(Collection<VehicleRoute> vehicleRoutes, Collection<Job> unassignedJobs) { if (!record()) return; fileSink.stepBegins(graph.getId(), 0, RECREATE); } }
public GraphListeners(Graph g) { super(g.getId()); this.sinkTime = new SinkTime(); this.sourceTime.setSinkTime(sinkTime); this.passYourWay = false; this.g = g; }
@Override public void informInsertionEnds(Collection<VehicleRoute> vehicleRoutes) { if (!record()) return; fileSink.stepBegins(graph.getId(), 0, CLEAR_SOLUTION); removeRoutes(vehicleRoutes); }
@Override public void informAlgorithmEnds(VehicleRoutingProblem problem, Collection<VehicleRoutingProblemSolution> solutions) { VehicleRoutingProblemSolution solution = Solutions.bestOf(solutions); fileSink.stepBegins(graph.getId(), 0, BEFORE_RUIN_RENDER_SOLUTION); addRoutes(solution.getRoutes()); finish(); }
/** * Like {@link #ThreadProxyPipe(Graph,Sink,boolean)}, but allows to share * the message box with another message processor. This can be needed to * share the same message stack, when message order is important. * * @param inputGraph * The graph we listen at. * @param replayGraph * If false, and if the input graph already contains element they * are not replayed. * @param sharedMBox * The message box used to send and receive graph messages across * the thread boundary. */ public ThreadProxyPipeOld(Graph inputGraph, Sink firstListener, boolean replayGraph, MBox sharedMBox) { this.events = sharedMBox; this.from = inputGraph.getId(); this.input = inputGraph; if (firstListener != null) addSink(firstListener); if (replayGraph) replayGraph(inputGraph); input.addSink(this); ((MBoxStandalone) this.events).addListener(this); }
@Override protected void exportGraph(Graph graph) { String graphId = graph.getId(); long timeId = 0; for (String key : graph.getAttributeKeySet()) graphAttributeAdded(graphId, timeId++, key, graph.getAttribute(key)); for (Node node : graph) { String nodeId = node.getId(); out.printf("\t\"%s\" %s;%n", nodeId, outputAttributes(node)); } for (Edge edge : graph.getEachEdge()) { String fromNodeId = edge.getNode0().getId(); String toNodeId = edge.getNode1().getId(); String attr = outputAttributes(edge); if (digraph) { out.printf("\t\"%s\" -> \"%s\"", fromNodeId, toNodeId); if (!edge.isDirected()) out.printf(" -> \"%s\"", fromNodeId); } else out.printf("\t\"%s\" -- \"%s\"", fromNodeId, toNodeId); out.printf(" %s;%n", attr); } }
@Override protected void exportGraph(Graph graph) { String graphId = graph.getId(); long timeId = 0; for (String key : graph.getAttributeKeySet()) graphAttributeAdded(graphId, timeId++, key, graph.getAttribute(key)); for (Node node : graph) { String nodeId = node.getId(); out.printf("\t\"%s\" %s;%n", nodeId, outputAttributes(node)); } for (Edge edge : graph.getEachEdge()) { String fromNodeId = edge.getNode0().getId(); String toNodeId = edge.getNode1().getId(); String attr = outputAttributes(edge); if (digraph) { out.printf("\t\"%s\" -> \"%s\"", fromNodeId, toNodeId); if (!edge.isDirected()) out.printf(" -> \"%s\"", fromNodeId); } else out.printf("\t\"%s\" -- \"%s\"", fromNodeId, toNodeId); out.printf(" %s;%n", attr); } }
/** * Compute coordinates of nodes using a layout algorithm. * * @param g * the graph * @param layout * layout algorithm to use for computing coordinates * @param stab * stabilization limit */ public static void computeLayout(Graph g, Layout layout, double stab) { GraphReplay r = new GraphReplay(g.getId()); stab = Math.min(stab, 1); layout.addAttributeSink(g); r.addSink(layout); r.replay(g); r.removeSink(layout); layout.shake(); layout.compute(); do layout.compute(); while (layout.getStabilization() < stab); layout.removeAttributeSink(g); }