@Override public Number getValue(Element element, Graph gr) { return gr.getDegree((Node) element); }
protected int calculateDegree(Graph graph, Node n) { return graph.getDegree(n); }
private double[] fillDegreeCount(Graph graph, CommunityStructure theStructure, int[] comStructure, double[] nodeDegrees, boolean weighted) { double[] degreeCount = new double[theStructure.communities.size()]; for (Node node : graph.getNodes()) { int index = theStructure.map.get(node); if (weighted) { degreeCount[comStructure[index]] += nodeDegrees[index]; } else { degreeCount[comStructure[index]] += graph.getDegree(node); } } return degreeCount; }
@Override public boolean evaluate(Graph graph, Node node) { int degree = graph.getDegree(node); return range.isInRange(degree); }
@Override public Number[] getValues(Graph graph) { List<Integer> values = new ArrayList<>(graph.getNodeCount()); for (Node n : graph.getNodes()) { int degree = graph.getDegree(n); values.add(degree); } return values.toArray(new Number[0]); }
@Override protected void refresh() { if (graph.getNodeCount() > 0) { int minV = Integer.MAX_VALUE; int maxV = Integer.MIN_VALUE; for (Node n : graph.getNodes()) { int degree = graph.getDegree(n); minV = Math.min(degree, minV); maxV = Math.max(degree, maxV); } min = minV; max = maxV; } } }
private double updateValueForNode(Graph graph, Node node, double[] pagerankValues, double[] weights, HashMap<Node, Integer> indicies, boolean directed, boolean useWeights, double r, double prob, Map<Node, Set<Node>> inNeighborsPerNode, final Object2DoubleOpenHashMap<Node> inWeightPerNeighbor) { double res = r; double sumNeighbors = 0; for (Node neighbor : inNeighborsPerNode.get(node)) { int neigh_index = indicies.get(neighbor); if (useWeights) { double weight = inWeightPerNeighbor.getDouble(neighbor) / weights[neigh_index]; sumNeighbors += pagerankValues[neigh_index] * weight; } else { int outDegree; if (directed) { outDegree = ((DirectedGraph) graph).getOutDegree(neighbor); } else { outDegree = graph.getDegree(neighbor); } sumNeighbors += (pagerankValues[neigh_index] / outDegree); } } res += prob * sumNeighbors; return res; }
@Override public Graph filter(Graph graph) { int removed = 0; do { removed = 0; for (Node n : graph.getNodes().toArray()) { if (graph.getDegree(n) < k) { graph.removeNode(n); removed++; } } } while (removed > 0); return graph; }
private double calculateR(Graph graph, double[] pagerankValues, HashMap<Node, Integer> indicies, boolean directed, double prob) { int N = graph.getNodeCount(); double r = (1.0 - prob) / N;//Initialize to damping factor //Calculate dangling nodes (nodes without out edges) contribution to all other nodes. //Necessary for all nodes page rank values sum to be 1 NodeIterable nodesIterable = graph.getNodes(); double danglingNodesRankContrib = 0; for (Node s : graph.getNodes()) { int s_index = indicies.get(s); int outDegree; if (directed) { outDegree = ((DirectedGraph) graph).getOutDegree(s); } else { outDegree = graph.getDegree(s); } if (outDegree == 0) { danglingNodesRankContrib += pagerankValues[s_index]; } if (isCanceled) { nodesIterable.doBreak(); break; } } danglingNodesRankContrib *= prob / N; r += danglingNodesRankContrib; return r; }
@Override public void initAlgo() { AbstractLayout.ensureSafeLayoutNodePositions(graphModel); speed = 1.; speedEfficiency = 1.; graph = graphModel.getGraphVisible(); graph.readLock(); try { Node[] nodes = graph.getNodes().toArray(); // Initialise layout data for (Node n : nodes) { if (n.getLayoutData() == null || !(n.getLayoutData() instanceof ForceAtlas2LayoutData)) { ForceAtlas2LayoutData nLayout = new ForceAtlas2LayoutData(); n.setLayoutData(nLayout); } ForceAtlas2LayoutData nLayout = n.getLayoutData(); nLayout.mass = 1 + graph.getDegree(n); nLayout.old_dx = 0; nLayout.old_dy = 0; nLayout.dx = 0; nLayout.dy = 0; } pool = Executors.newFixedThreadPool(threadCount); currentThreadCount = threadCount; } finally { graph.readUnlockAll(); } }
nLayout.mass = 1 + graph.getDegree(n); nLayout.old_dx = nLayout.dx; nLayout.old_dy = nLayout.dy;
for (Node n2 : nodes) { if (n1 != n2) { ForceVectorUtils.fcBiRepulsor_noCollide(n1, n2, getRepulsionStrength() * (1 + graph.getDegree(n1)) * (1 + graph.getDegree(n2))); for (Node n2 : nodes) { if (n1 != n2) { ForceVectorUtils.fcBiRepulsor(n1, n2, getRepulsionStrength() * (1 + graph.getDegree(n1)) * (1 + graph.getDegree(n2))); double bonus = (nf.isFixed() || nt.isFixed()) ? (100) : (1); bonus *= getEdgeWeight(e, isDynamicWeight, interval); ForceVectorUtils.fcBiAttractor_noCollide(nf, nt, bonus * getAttractionStrength() / (1 + graph.getDegree(nf))); double bonus = (nf.isFixed() || nt.isFixed()) ? (100) : (1); bonus *= getEdgeWeight(e, isDynamicWeight, interval); ForceVectorUtils.fcBiAttractor(nf, nt, bonus * getAttractionStrength() / (1 + graph.getDegree(nf)));
int degree = graph.getDegree(n);