public int getInDegree() { int d; elementLock.lock(); d = wrappedElement.getInDegree(); elementLock.unlock(); return d; }
public int getInDegree() { int d; elementLock.lock(); d = wrappedElement.getInDegree(); elementLock.unlock(); return d; }
public Collection<Edge> getEnteringEdgeSet() { ArrayList<Edge> l; Iterator<Edge> it; elementLock.lock(); sg.elementLock.lock(); l = new ArrayList<Edge>(wrappedElement.getInDegree()); it = wrappedElement.getEachEnteringEdge().iterator(); while (it.hasNext()) l.add(sg.getEdge(it.next().getIndex())); sg.elementLock.unlock(); elementLock.unlock(); return l; }
public Collection<Edge> getEnteringEdgeSet() { ArrayList<Edge> l; Iterator<Edge> it; elementLock.lock(); sg.elementLock.lock(); l = new ArrayList<Edge>(wrappedElement.getInDegree()); it = wrappedElement.getEachEnteringEdge().iterator(); while (it.hasNext()) l.add(sg.getEdge(it.next().getIndex())); sg.elementLock.unlock(); elementLock.unlock(); return l; }
/** * calculates the source nodes * @return set of source nodes */ private Set<Node> calculateSourceNodes() { Set<Node> aSourceNodeSet = new HashSet<>(); for (Node aNode : graph.getEachNode()) { if (aNode.getInDegree() == 0) { aSourceNodeSet.add(aNode); } } if (aSourceNodeSet.isEmpty()) { throw new GraphHasCycleException(); } return aSourceNodeSet; }
/** * Choose an edge at random from the entering edges connected to the given * node. * * @param random * The random number generator to use. * @return An edge chosen at random, null if the node has no entering edges. * @complexity O(1). */ public static Edge randomInEdge(Node node, Random random) { int n = node.getInDegree(); if (n > 0) { return node.getEnteringEdge(random.nextInt(n)); // int r = random.nextInt(n); // int i = 0; // // for (Edge edge : node.getEnteringEdgeSet()) { // if (r == i) // return edge; // i++; // } } return null; }
/** * Choose an edge at random from the entering edges connected to the given * node. * * @param random * The random number generator to use. * @return An edge chosen at random, null if the node has no entering edges. * @complexity O(1). */ public static Edge randomInEdge(Node node, Random random) { int n = node.getInDegree(); if (n > 0) { return node.getEnteringEdge(random.nextInt(n)); // int r = random.nextInt(n); // int i = 0; // // for (Edge edge : node.getEnteringEdgeSet()) { // if (r == i) // return edge; // i++; // } } return null; }
protected void computeCentrality() { int count = graph.getNodeCount(); switch (mode) { case INOUT: for (int idx = 0; idx < count; idx++) data[idx] = graph.getNode(idx).getDegree(); break; case IN: for (int idx = 0; idx < count; idx++) data[idx] = graph.getNode(idx).getInDegree(); break; case OUT: for (int idx = 0; idx < count; idx++) data[idx] = graph.getNode(idx).getOutDegree(); break; } }
protected void computeCentrality() { int count = graph.getNodeCount(); switch (mode) { case INOUT: for (int idx = 0; idx < count; idx++) data[idx] = graph.getNode(idx).getDegree(); break; case IN: for (int idx = 0; idx < count; idx++) data[idx] = graph.getNode(idx).getInDegree(); break; case OUT: for (int idx = 0; idx < count; idx++) data[idx] = graph.getNode(idx).getOutDegree(); break; } }
protected void iteration() { double dampingTerm = (1 - dampingFactor) / graph.getNodeCount(); newRanks.clear(); double danglingRank = 0; for (int i = 0; i < graph.getNodeCount(); i++) { Node node = graph.getNode(i); double sum = 0; for (int j = 0; j < node.getInDegree(); j++) { Node other = node.getEnteringEdge(j).getOpposite(node); sum += other.getNumber(rankAttribute) / other.getOutDegree(); } newRanks.add(dampingTerm + dampingFactor * sum); if (node.getOutDegree() == 0) danglingRank += node.getNumber(rankAttribute); } danglingRank *= dampingFactor / graph.getNodeCount(); normDiff = 0; for (int i = 0; i < graph.getNodeCount(); i++) { Node node = graph.getNode(i); double currentRank = node.getNumber(rankAttribute); double newRank = newRanks.get(i) + danglingRank; normDiff += Math.abs(newRank - currentRank); node.addAttribute(rankAttribute, newRank); } iterationCount++; }
protected void iteration() { double dampingTerm = (1 - dampingFactor) / graph.getNodeCount(); newRanks.clear(); double danglingRank = 0; for (int i = 0; i < graph.getNodeCount(); i++) { Node node = graph.getNode(i); double sum = 0; for (int j = 0; j < node.getInDegree(); j++) { Node other = node.getEnteringEdge(j).getOpposite(node); sum += other.getNumber(rankAttribute) / other.getOutDegree(); } newRanks.add(dampingTerm + dampingFactor * sum); if (node.getOutDegree() == 0) danglingRank += node.getNumber(rankAttribute); } danglingRank *= dampingFactor / graph.getNodeCount(); normDiff = 0; for (int i = 0; i < graph.getNodeCount(); i++) { Node node = graph.getNode(i); double currentRank = node.getNumber(rankAttribute); double newRank = newRanks.get(i) + danglingRank; normDiff += Math.abs(newRank - currentRank); node.addAttribute(rankAttribute, newRank); } iterationCount++; }
* Math.pow(v.getInDegree(), m);
* Math.pow(v.getInDegree(), m);