@Override public boolean init(Graph graph) { return graph.getNodeCount() != 0; }
public void initStartValues(Graph graph) { N = graph.getNodeCount(); K = (int) Math.sqrt(N); nodeClustering = new double[N]; network = new ArrayWrapper[N]; triangles = new int[N]; }
private double updateValues(Graph graph, double[] tempValues, double[] centralityValues, double max) { double sumChanged = 0.; int N = graph.getNodeCount(); for (int k = 0; k < N; k++) { if (max != 0) { sumChanged += Math.abs(centralityValues[k] - (tempValues[k] / max)); centralityValues[k] = tempValues[k] / max; } else { centralityValues[k] = 0.0; } if (isCanceled) { return sumChanged; } } return sumChanged; }
private void saveCalculatedValues(Graph graph, Column attributeColumn, HashMap<Integer, Node> indicies, double[] eigCenrtalities) { int N = graph.getNodeCount(); for (int i = 0; i < N; i++) { Node s = indicies.get(i); s.setAttribute(attributeColumn, eigCenrtalities[i]); } }
private void calculateCorrection(Graph graph, HashMap<Node, Integer> indicies, double[] nodeBetweenness, boolean directed, boolean normalized) { int n = graph.getNodeCount(); for (Node s : graph.getNodes()) { int s_index = indicies.get(s); if (!directed) { nodeBetweenness[s_index] /= 2; } if (normalized) { nodeBetweenness[s_index] /= directed ? (n - 1) * (n - 2) : (n - 1) * (n - 2) / 2; } } }
public double calculateDensity(Graph graph, boolean isGraphDirected) { double result; double edgesCount = graph.getEdgeCount(); double nodesCount = graph.getNodeCount(); double multiplier = 1; if (!isGraphDirected) { multiplier = 2; } result = (multiplier * edgesCount) / (nodesCount * nodesCount - nodesCount); return result; }
@Override public boolean init(Graph graph) { return !(graph.getNodeCount() == 0 || !(graph.isDirected())); }
@Override public boolean init(Graph graph) { return !(graph.getNodeCount() == 0 || !(graph.isDirected())); }
@Override public int getNodesCount() { Graph graph = getCurrentGraph(); return graph.getNodeCount(); }
@Override public boolean init(Graph graph) { return !(graph.getNodeCount() == 0 || !(graph.isDirected())); }
@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; } } }
public void execute(Graph graph) { isCanceled = false; graph.readLock(); try { structure = new Modularity.CommunityStructure(graph); int[] comStructure = new int[graph.getNodeCount()]; if (graph.getNodeCount() > 0) {//Fixes issue #713 Modularity Calculation Throws Exception On Empty Graph HashMap<String, Double> computedModularityMetrics = computeModularity(graph, structure, comStructure, resolution, isRandomized, useWeight); modularity = computedModularityMetrics.get("modularity"); modularityResolution = computedModularityMetrics.get("modularityResolution"); } else { modularity = 0; modularityResolution = 0; } saveValues(comStructure, graph, structure); } finally { graph.readUnlock(); } }
@Override public boolean init(Graph graph) { if (AttributeUtils.isNodeColumn(column)) { if (graph.getNodeCount() == 0) { return false; } } else if (AttributeUtils.isEdgeColumn(column)) { if (graph.getEdgeCount() == 0) { return false; } } return true; }
@Override public boolean init(Graph graph) { if (AttributeUtils.isNodeColumn(column)) { if (graph.getNodeCount() == 0) { return false; } } else if (AttributeUtils.isEdgeColumn(column)) { if (graph.getEdgeCount() == 0) { return false; } } return true; }
@Override public boolean init(Graph graph) { if (AttributeUtils.isNodeColumn(column)) { if (graph.getNodeCount() == 0) { return false; } } else if (AttributeUtils.isEdgeColumn(column)) { if (graph.getEdgeCount() == 0) { return false; } } return true; }
public double calculateEigenvectorCentrality(Graph graph, double[] eigCentralities, HashMap<Integer, Node> indicies, HashMap<Node, Integer> invIndicies, boolean directed, int numIterations) { int N = graph.getNodeCount(); double sumChanged = 0.; double[] tmp = new double[N]; for (int s = 0; s < numIterations; s++) { double max = computeMaxValueAndTempValues(graph, indicies, invIndicies, tmp, eigCentralities, directed); sumChanged = updateValues(graph, tmp, eigCentralities, max); if (isCanceled) { return sumChanged; } Progress.progress(progress); } return sumChanged; }
@Override public void loop(GraphView window, Interval interval) { Graph graph = graphModel.getGraph(window); int count = graph.getNodeCount(); graphModel.getGraphVisible().setAttribute(NB_NODES, count, interval.getLow()); graphModel.getGraphVisible().setAttribute(NB_NODES, count, interval.getHigh()); counts.put(interval.getLow(), count); counts.put(interval.getHigh(), count); }
public void execute(Graph graph) { initializeAttributeColunms(graph.getModel()); graph.readLock(); try { int N = graph.getNodeCount(); authority = new double[N]; hubs = new double[N]; Map<Node, Integer> indices = createIndicesMap(graph); calculateHits(graph, hubs, authority, indices, !useUndirected, epsilon); saveCalculatedValues(indices, authority, hubs); } finally { graph.readUnlockAll(); } }
@Override public Item[] getItems(Graph graph) { Item[] items = new NodeItem[graph.getNodeCount()]; int i = 0; for (Node n : graph.getNodes()) { NodeItem nodeItem = new NodeItem(n); nodeItem.setData(NodeItem.X, n.x()); nodeItem.setData(NodeItem.Y, -n.y()); nodeItem.setData(NodeItem.Z, n.z()); nodeItem.setData(NodeItem.SIZE, n.size() * 2f); nodeItem.setData(NodeItem.COLOR, n.getColor()); items[i++] = nodeItem; } return items; }