public double getElementCount() { return g.getNodeCount(); } }
/** * This method computes the mean degree of the graph. */ public double meanDegree() { return 2.0 * internalGraph.getEdgeCount() / (double) internalGraph.getNodeCount(); }
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; }
/** * This method computes the mean degree of the graph. */ public double meanDegree() { return 2.0 * internalGraph.getEdgeCount() / (double) internalGraph.getNodeCount(); }
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 nodeAdded(String sourceId, long timeId, String nodeId) { // the initial rank of the new node will be 0 graph.getNode(nodeId).addAttribute(rankAttribute, graph.getNodeCount() == 1 ? 1.0 : 0.0); upToDate = false; }
public void nodeAdded(String sourceId, long timeId, String nodeId) { // the initial rank of the new node will be 0 graph.getNode(nodeId).addAttribute(rankAttribute, graph.getNodeCount() == 1 ? 1.0 : 0.0); upToDate = false; }
@SuppressWarnings("unchecked") public DepthFirstIterator(Node startNode, boolean directed) { this.directed = directed; graph = startNode.getGraph(); int n = graph.getNodeCount(); parent = new Node[n]; iterator = new Iterator[n]; depth = new int[n]; int s = startNode.getIndex(); for (int i = 0; i < n; i++) depth[i] = i == s ? 0 : -1; next = startNode; }
public BreadthFirstIterator(Node startNode, boolean directed) { this.directed = directed; graph = startNode.getGraph(); int n = graph.getNodeCount(); queue = new Node[n]; depth = new int[n]; int s = startNode.getIndex(); for (int i = 0; i < n; i++) depth[i] = i == s ? 0 : -1; queue[0] = startNode; qHead = 0; qTail = 1; }
@Override public void init(Graph theGraph) { sortedNodes = new Node[theGraph.getNodeCount()]; if (algorithm == SortAlgorithm.KAHN) { graph = Graphs.clone(theGraph); sourceNodes = calculateSourceNodes(); } else { graph = theGraph; } }
public BreadthFirstIterator(Node startNode, boolean directed) { this.directed = directed; graph = startNode.getGraph(); int n = graph.getNodeCount(); queue = new Node[n]; depth = new int[n]; int s = startNode.getIndex(); for (int i = 0; i < n; i++) depth[i] = i == s ? 0 : -1; queue[0] = startNode; qHead = 0; qTail = 1; }
public void compute() { if (graph == null) throw new NotInitializedException(this); int count = graph.getNodeCount(); if (data == null || data.length != count) data = new double[count]; computeCentrality(); copyValuesTo(centralityAttribute, normalize); }
public void compute() { if (graph == null) throw new NotInitializedException(this); int count = graph.getNodeCount(); if (data == null || data.length != count) data = new double[count]; computeCentrality(); copyValuesTo(centralityAttribute, normalize); }
private void computeDFS() { if (graph == null) { throw new NotInitializedException(this); } int[] marks = new int[graph.getNodeCount()]; for (int i = 0; i < marks.length; i++) { if (marks[i] == MARK_UNMARKED) { visitNode(graph.getNode(i), marks); } } }
public void compute() { double min, max, avg; min = Double.MAX_VALUE; max = Double.MIN_VALUE; avg = 0; for (Node n : g) { min = Math.min(min, n.getDegree()); max = Math.max(max, n.getDegree()); avg += n.getDegree(); } avg /= g.getNodeCount(); addValue(g.getStep(), min, avg, max); }
public void compute() { double min, max, avg; min = Double.MAX_VALUE; max = Double.MIN_VALUE; avg = 0; for (Node n : g) { min = Math.min(min, n.getDegree()); max = Math.max(max, n.getDegree()); avg += n.getDegree(); } avg /= g.getNodeCount(); addValue(g.getStep(), min, avg, max); }
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; }
public void compute() { if (graph == null) throw new NotInitializedException(this); int m = graph.getNodeCount(); RealMatrix a = new Array2DRowRealMatrix(m, m); Edge e; for (int idx1 = 0; idx1 < m; idx1++) for (int idx2 = 0; idx2 < m; idx2++) { e = graph.getNode(idx1).getEdgeToward(idx2); a.setEntry(idx1, idx2, e != null ? 1 : 0); } decomposition = new EigenDecomposition(a, 0); }
public void compute() { if (graph == null) throw new NotInitializedException(this); int m = graph.getNodeCount(); RealMatrix a = new Array2DRowRealMatrix(m, m); Edge e; for (int idx1 = 0; idx1 < m; idx1++) for (int idx2 = 0; idx2 < m; idx2++) { e = graph.getNode(idx1).getEdgeToward(idx2); a.setEntry(idx1, idx2, e != null ? 1 : 0); } decomposition = new EigenDecomposition(a, 0); }