private void markPickup(String id) { graph.getNode(id).addAttribute("ui.class", "pickup"); }
private void markDelivery(String id) { graph.getNode(id).addAttribute("ui.class", "delivery"); }
private void addNode(String nodeId, Coordinate nodeCoord) { Node node = graph.addNode(nodeId); node.addAttribute("x", nodeCoord.getX()); node.addAttribute("y", nodeCoord.getY()); }
private void addVehicle(Vehicle vehicle) { String startId = makeStartId(vehicle); Node node = graph.addNode(startId); node.addAttribute("x", vehicle.getStartLocation().getCoordinate().getX()); node.addAttribute("y", vehicle.getStartLocation().getCoordinate().getY()); node.addAttribute("ui.class", "depot"); String endId = makeEndId(vehicle); if (!startId.equals(endId)) { Node endNode = graph.addNode(endId); endNode.addAttribute("x", vehicle.getEndLocation().getCoordinate().getX()); endNode.addAttribute("y", vehicle.getEndLocation().getCoordinate().getY()); endNode.addAttribute("ui.class", "depot"); } }
private void renderService(Graph g, Service service, Label label) { Node n = g.addNode(makeId(service.getId(), service.getLocation().getId())); if (label.equals(Label.ID)) n.addAttribute("ui.label", service.getId()); n.addAttribute("x", service.getLocation().getCoordinate().getX()); n.addAttribute("y", service.getLocation().getCoordinate().getY()); if (service.getType().equals("pickup")) n.setAttribute("ui.class", "pickup"); if (service.getType().equals("delivery")) n.setAttribute("ui.class", "delivery"); }
private void renderVehicle(Graph g, Vehicle vehicle, Label label) { String nodeId = makeId(vehicle.getId(), vehicle.getStartLocation().getId()); Node vehicleStart = g.addNode(nodeId); if (label.equals(Label.ID)) vehicleStart.addAttribute("ui.label", "depot"); // if(label.equals(Label.ACTIVITY)) n.addAttribute("ui.label", "start"); vehicleStart.addAttribute("x", vehicle.getStartLocation().getCoordinate().getX()); vehicleStart.addAttribute("y", vehicle.getStartLocation().getCoordinate().getY()); vehicleStart.setAttribute("ui.class", "depot"); if (!vehicle.getStartLocation().getId().equals(vehicle.getEndLocation().getId())) { Node vehicleEnd = g.addNode(makeId(vehicle.getId(), vehicle.getEndLocation().getId())); if (label.equals(Label.ID)) vehicleEnd.addAttribute("ui.label", "depot"); vehicleEnd.addAttribute("x", vehicle.getEndLocation().getCoordinate().getX()); vehicleEnd.addAttribute("y", vehicle.getEndLocation().getCoordinate().getY()); vehicleEnd.setAttribute("ui.class", "depot"); } }
private void renderShipment(Graph g, Shipment shipment, Label label, boolean renderShipments) { Node n1 = g.addNode(makeId(shipment.getId(), shipment.getPickupLocation().getId())); if (label.equals(Label.ID)) n1.addAttribute("ui.label", shipment.getId()); n1.addAttribute("x", shipment.getPickupLocation().getCoordinate().getX()); n1.addAttribute("y", shipment.getPickupLocation().getCoordinate().getY()); n1.setAttribute("ui.class", "pickup"); Node n2 = g.addNode(makeId(shipment.getId(), shipment.getDeliveryLocation().getId())); if (label.equals(Label.ID)) n2.addAttribute("ui.label", shipment.getId()); n2.addAttribute("x", shipment.getDeliveryLocation().getCoordinate().getX()); n2.addAttribute("y", shipment.getDeliveryLocation().getCoordinate().getY()); n2.setAttribute("ui.class", "delivery"); if (renderShipments) { Edge s = g.addEdge(shipment.getId(), makeId(shipment.getId(), shipment.getPickupLocation().getId()), makeId(shipment.getId(), shipment.getDeliveryLocation().getId()), true); s.addAttribute("ui.class", "shipment"); } }
// In main() ... Node a = graph.addNode("A"); a.addAttribute("xy", 0, 0); Node b = graph.addNode("B"); b.addAttribute("xy", 10, 0); Node c = graph.addNode("C"); c.addAttribute("xy", 10, 10); // ...
if (label.equals(Label.ACTIVITY) || label.equals(Label.JOB_NAME)) { Node n = g.getNode(prevIdentifier); n.addAttribute("ui.label", "start"); if (label.equals(Label.ACTIVITY)) { Node actNode = g.getNode(currIdentifier); actNode.addAttribute("ui.label", act.getName()); } else if (label.equals(Label.JOB_NAME)) { Node actNode = g.getNode(currIdentifier); actNode.addAttribute("ui.label", job.getName()); } else if (label.equals(Label.ARRIVAL_TIME)) { Node actNode = g.getNode(currIdentifier); actNode.addAttribute("ui.label", Time.parseSecondsToTime(act.getArrTime())); } else if (label.equals(Label.DEPARTURE_TIME)) { Node actNode = g.getNode(currIdentifier); actNode.addAttribute("ui.label", Time.parseSecondsToTime(act.getEndTime())); if (act instanceof PickupActivity) g.getNode(currIdentifier).addAttribute("ui.class", "pickupInRoute"); else if (act instanceof DeliveryActivity) g.getNode(currIdentifier).addAttribute("ui.class", "deliveryInRoute"); prevIdentifier = currIdentifier; vehicle_edgeId++;
/** * Generate a new original community and attribute it to a node * * @param node * The node that will originate the new community */ protected void originateCommunity(Node node) { node.addAttribute(marker, new Community()); }
protected void nodeAttributeHandling(String nodeId, String key, Object val) { if (key != null && key.matches("x|y|z") && val instanceof Float) { int i = ((int) key.charAt(0)) - (int) 'x'; if (i < dimension) internalGraph.getNode(nodeId).addAttribute(key, val); } }
@Override public void nodeAdded(String graphId, long timeId, String nodeId) { Node node = context.graph.getNode(nodeId); node.addAttribute(context.passesAttribute, 0.0); } }
protected void remapMarks() { if (countAttribute != null && connectedComponentsMap != null) { Iterator<? extends Node> nodes = graph.getNodeIterator(); while (nodes.hasNext()) { Node v = nodes.next(); int id = connectedComponentsMap.get(v); v.addAttribute(countAttribute, id - 1); } } }
@Override public void nodeAdded(String graphId, long timeId, String nodeId) { Node node = context.graph.getNode(nodeId); node.addAttribute(context.passesAttribute, 0.0); } }
private void addNode(String nodeId, Coordinate nodeCoord) { Node node = graph.addNode(nodeId); node.addAttribute("x", nodeCoord.getX()); node.addAttribute("y", nodeCoord.getY()); }
protected void equipGraph() { for (Edge e : context.graph.getEachEdge()) { e.addAttribute(context.passesAttribute, 0.0); } for (Node n : context.graph) { n.addAttribute(context.passesAttribute, 0.0); } }
public State getState(Node n) { State s = n.getAttribute(STATE_ATTRIBUTE); if (s == null) { s = new State(n); n.addAttribute(STATE_ATTRIBUTE, s); } return s; }
public void init(Graph graph) { this.graph = graph; graph.addElementSink(this); double initialRank = 1.0 / graph.getNodeCount(); for (Node node : graph) node.addAttribute(rankAttribute, initialRank); newRanks = new ArrayList<Double>(graph.getNodeCount()); upToDate = false; iterationCount = 0; }
public void nodeRemoved(String sourceId, long timeId, String nodeId) { // removed node will give equal parts of its rank to the others double part = graph.getNode(nodeId).getNumber(rankAttribute) / (graph.getNodeCount() - 1); for (Node node : graph) if (!node.getId().equals(nodeId)) node.addAttribute(rankAttribute, node.getNumber(rankAttribute) + part); upToDate = false; }
public void nodeRemoved(String sourceId, long timeId, String nodeId) { // removed node will give equal parts of its rank to the others double part = graph.getNode(nodeId).getNumber(rankAttribute) / (graph.getNodeCount() - 1); for (Node node : graph) if (!node.getId().equals(nodeId)) node.addAttribute(rankAttribute, node.getNumber(rankAttribute) + part); upToDate = false; }