protected double getNodeY(Node n) { if (n.hasAttribute(XYZ_ATTR)) return ((Number) (n.getArray(XYZ_ATTR)[1])).doubleValue(); if (n.hasAttribute("y")) return n.getNumber("y"); return Double.NaN; }
protected double getNodeX(Node n) { if (n.hasAttribute(XYZ_ATTR)) return ((Number) (n.getArray(XYZ_ATTR)[0])).doubleValue(); if (n.hasAttribute("x")) return n.getNumber("x"); return Double.NaN; }
protected double getNodeX(Node n) { if (n.hasAttribute(XYZ_ATTR)) return ((Number) (n.getArray(XYZ_ATTR)[0])).doubleValue(); if (n.hasAttribute("x")) return n.getNumber("x"); return Double.NaN; }
protected double getNodeY(Node n) { if (n.hasAttribute(XYZ_ATTR)) return ((Number) (n.getArray(XYZ_ATTR)[1])).doubleValue(); if (n.hasAttribute("y")) return n.getNumber("y"); return Double.NaN; }
/** * Is the given node tabu ? * @param node The node to test. * @return true if the node is tabu. */ protected boolean tabu(Node node) { if (node.hasAttribute("tabu")) return true; if (context.entityMemory > 0) { if (memory == null) memory = new LinkedList<Node>(); int n = memory.size(); for (int i = 0; i < n; i++) { if (node == memory.get(i)) return true; } } return false; } }
/** * Is the given node tabu ? * @param node The node to test. * @return true if the node is tabu. */ protected boolean tabu(Node node) { if (node.hasAttribute("tabu")) return true; if (context.entityMemory > 0) { if (memory == null) memory = new LinkedList<Node>(); int n = memory.size(); for (int i = 0; i < n; i++) { if (node == memory.get(i)) return true; } } return false; } }
/** * Like {@link #nodePosition(Graph,String,double[])} but use an existing node * as argument. * * @param node * The node to consider. * @param xyz * An array of at least three cells. */ public static void nodePosition(Node node, double xyz[]) { if (xyz.length < 3) return; if (node.hasAttribute("xyz") || node.hasAttribute("xy")) { Object o = node.getAttribute("xyz"); if (o == null) o = node.getAttribute("xy"); if (o != null) { positionFromObject(o, xyz); } } else if (node.hasAttribute("x")) { xyz[0] = (double) node.getNumber("x"); if (node.hasAttribute("y")) xyz[1] = (double) node.getNumber("y"); if (node.hasAttribute("z")) xyz[2] = (double) node.getNumber("z"); } }
private void outputNode(Node n) { String label; String style = getNodeStyle(n); label = n.hasAttribute("label") ? (String) n.getLabel("label") : (n .hasAttribute("ui.label") ? (String) n.getLabel("ui.label") : ""); out.printf(l, "\t\\node[%s] at (%s) {%s};%n", style, formatId(n.getId()), label); }
private void outputNode(Node n) { String label; String style = getNodeStyle(n); label = n.hasAttribute("label") ? (String) n.getLabel("label") : (n .hasAttribute("ui.label") ? (String) n.getLabel("ui.label") : ""); out.printf(l, "\t\\node[%s] at (%s) {%s};%n", style, formatId(n.getId()), label); }
protected void setBox(Box box, Node node) { if (node.hasAttribute("box")) getBox(node).remove(node); box.add(node); node.setAttribute("box", box); if (!node.hasAttribute("children")) node.addAttribute("children", new Box(node, 1)); getChildrenBox(node).level = box.level + 1; }
protected void setBox(Box box, Node node) { if (node.hasAttribute("box")) getBox(node).remove(node); box.add(node); node.setAttribute("box", box); if (!node.hasAttribute("children")) node.addAttribute("children", new Box(node, 1)); getChildrenBox(node).level = box.level + 1; }
private static double getX(Node n) { if (n.hasNumber("x")) return n.getNumber("x"); if (n.hasArray("xy")) { Object[] xy = n.getArray("xy"); if (xy != null && xy.length > 0 && xy[0] instanceof Number) return ((Number) xy[0]).doubleValue(); } if (n.hasArray("xyz")) { Object[] xyz = n.getArray("xyz"); if (xyz != null && xyz.length > 0 && xyz[0] instanceof Number) return ((Number) xyz[0]).doubleValue(); } System.err.printf("[WARNING] no x attribute for node \"%s\" %s\n", n.getId(), n.hasAttribute("xyz")); return Math.random(); }
private static double getX(Node n) { if (n.hasNumber("x")) return n.getNumber("x"); if (n.hasArray("xy")) { Object[] xy = n.getArray("xy"); if (xy != null && xy.length > 0 && xy[0] instanceof Number) return ((Number) xy[0]).doubleValue(); } if (n.hasArray("xyz")) { Object[] xyz = n.getArray("xyz"); if (xyz != null && xyz.length > 0 && xyz[0] instanceof Number) return ((Number) xyz[0]).doubleValue(); } System.err.printf("[WARNING] no x attribute for node \"%s\" %s\n", n.getId(), n.hasAttribute("xyz")); return Math.random(); }
/** * Compute the scores for all relevant communities for the selected node * using epidemic label propagation paradigm. * * @param u * The node for which the scores computation is performed * @complexity O(DELTA) where DELTA is is the average node degree in the * network */ protected void communityScores(Node u) { /* * Reset the scores for each communities */ communityScores = new HashMap<Object, Double>(); /* * Iterate over the nodes that this node "hears" */ for (Edge e : u.getEnteringEdgeSet()) { Node v = e.getOpposite(u); /* * Update the count for this community */ if (v.hasAttribute(marker)) if (communityScores.get(v.getAttribute(marker)) == null) communityScores.put(v.getAttribute(marker), 1.0); else communityScores.put(v.getAttribute(marker), communityScores.get(v.getAttribute(marker)) + 1.0); } }
@Override public void computeNode(Node node) { /* * Save the node community to previous */ if (node.hasAttribute(marker)) node.setAttribute(marker + ".previous", node.getAttribute(marker)); /* * Perform same assignment as in asynchronous mode difference is in the * redefinition of the communityScores() method */ super.computeNode(node); /* * Save the iteration at which the node was last updated */ node.setAttribute(marker + ".step", iteration); }
protected void publishPositions() { for (Node n : internalGraph) { if (n.hasAttribute("changed")) { n.removeAttribute("changed"); sendNodeAttributeChanged(sourceId, n.getId(), "xyz", null, new double[] { n.getNumber("x"), n.getNumber("y"), 0 }); } } }
protected void publishPositions() { for (Node n : internalGraph) { if (n.hasAttribute("changed")) { n.removeAttribute("changed"); sendNodeAttributeChanged(sourceId, n.getId(), "xyz", null, new double[] { n.getNumber("x"), n.getNumber("y"), 0 }); } } }
@Override public void computeNode(Node node) { /* * Save the node community to previous */ if (node.hasAttribute(marker)) node.setAttribute(marker + ".previous", node.getAttribute(marker)); /* * Perform same assignment as in asynchronous mode difference is in the * redefinition of the communityScores() method */ super.computeNode(node); /* * Save the iteration at which the node was last updated */ node.setAttribute(marker + ".step", iteration); }
protected void mouseButtonPress(MouseEvent event) { view.requestFocus(); // Unselect all. if (!event.isShiftDown()) { if (types.contains(InteractiveElement.NODE)) { for (Node node : graph) { if (node.hasAttribute("ui.selected")) node.removeAttribute("ui.selected"); } } if (types.contains(InteractiveElement.SPRITE)) { for (GraphicSprite sprite : graph.spriteSet()) { if (sprite.hasAttribute("ui.selected")) sprite.removeAttribute("ui.selected"); } } if (types.contains(InteractiveElement.EDGE)) { for (Edge edge : graph.getEdgeSet()) { if (edge.hasAttribute("ui.selected")) edge.removeAttribute("ui.selected"); } } } }
protected void mouseButtonPress(MouseEvent event) { view.requestFocus(); // Unselect all. if (!event.isShiftDown()) { for (Node node : graph) { if (node.hasAttribute("ui.selected")) node.removeAttribute("ui.selected"); } for (GraphicSprite sprite : graph.spriteSet()) { if (sprite.hasAttribute("ui.selected")) sprite.removeAttribute("ui.selected"); } } }