public int compare(NodeImpl n1, NodeImpl n2) { int v1 = n1.out().length; int v2 = n2.out().length; if (v1 == v2) { return 0; } else if (v1 > v2) { return -1; } else { return 1; } }
private Set<NodeImpl> neighborhood(NodeImpl node, boolean onlyOut) { Set<NodeImpl> n = new HashSet<NodeImpl>(); NodeImpl[] OUT = node.out(); for (NodeImpl out : OUT) { n.add(out); } if (!onlyOut) { NodeImpl[] IN = node.in(); for (NodeImpl in : IN) { n.add(in); } } return n; }
private int edgesInNeighborhood(Set<NodeImpl> n) { int edges = 0; Iterator<NodeImpl> iter = n.iterator(); while (iter.hasNext()) { NodeImpl current = iter.next(); NodeImpl[] OUT = current.out(); for (NodeImpl out : OUT) { if (n.contains(out)) { edges++; } } } return edges; }