public FilteredNodeIterator(Graph g, Filter<Node> filter) { this(g.<T>getNodeIterator(), filter); }
public FilteredNodeIterator(Graph g, Filter<Node> filter) { this(g.<T>getNodeIterator(), filter); }
protected TreeIterator() { nodeIt = graph.getNodeIterator(); findNextEdge(); }
protected TreeIterator() { nodeIt = graph.getNodeIterator(); findNextEdge(); }
protected void removeMarks() { Iterator<? extends Node> nodes = graph.getNodeIterator(); while (nodes.hasNext()) { Node node = nodes.next(); if (countAttribute == null) node.removeAttribute(countAttribute); } }
protected void remapMarks() { if (countAttribute != null && connectedComponentsMap != null) { Iterator<? extends Node> nodes = graph.getNodeIterator(); while (nodes.hasNext()) { Node v = nodes.next(); int id = connectedComponentsMap.get(v); v.addAttribute(countAttribute, id - 1); } } }
/** * Sort all nodes by their "passes" attribute and return the array of sorted * nodes. * * @return An array with all nodes of the graph sorted by their number of * entity pass. */ public ArrayList<Node> findTheMostUsedNodes() { ArrayList<Node> nodes = new ArrayList<Node>(context.graph.getNodeCount()); Iterator<? extends Node> i = context.graph.getNodeIterator(); while (i.hasNext()) { nodes.add(i.next()); } Collections.sort(nodes, new Comparator<Node>() { public int compare(Node e1, Node e2) { int n1 = (int) e1.getNumber(context.passesAttribute); int n2 = (int) e2.getNumber(context.passesAttribute); return (n1 - n2); } }); return nodes; } // Graph listener
@Override public void compute() { started = true; components.clear(); componentsMap.clear(); Iterator<? extends Node> nodes = graph.getNodeIterator(); while (nodes.hasNext()) { Node n = nodes.next(); if (!componentsMap.containsKey(n)) { ConnectedComponent cc = new ConnectedComponent(); computeConnectedComponent(cc, n, null); components.add(cc); } } }
/** * Sort all nodes by their "passes" attribute and return the array of sorted * nodes. * * @return An array with all nodes of the graph sorted by their number of * entity pass. */ public ArrayList<Node> findTheMostUsedNodes() { ArrayList<Node> nodes = new ArrayList<Node>(context.graph.getNodeCount()); Iterator<? extends Node> i = context.graph.getNodeIterator(); while (i.hasNext()) { nodes.add(i.next()); } Collections.sort(nodes, new Comparator<Node>() { public int compare(Node e1, Node e2) { int n1 = (int) e1.getNumber(context.passesAttribute); int n2 = (int) e2.getNumber(context.passesAttribute); return (n1 - n2); } }); return nodes; } // Graph listener
public void compute() { connectedComponents = 0; started = true; ids.clear(); ids.add(""); // The dummy first identifier (since zero is a special // value). components.add(new ConnectedComponent(0)); connectedComponentsMap = new HashMap<Node, Integer>(); // Initialize the size count structure connectedComponentsSize = new HashMap<Integer, Integer>(); Iterator<? extends Node> nodes = graph.getNodeIterator(); while (nodes.hasNext()) { connectedComponentsMap.put(nodes.next(), 0); } nodes = graph.getNodeIterator(); while (nodes.hasNext()) { Node v = nodes.next(); if (connectedComponentsMap.get(v) == 0) { connectedComponents++; int newIdentifier = addIdentifier(); int size = computeConnectedComponent(v, newIdentifier, null); if (size > 0) components.add(new ConnectedComponent(newIdentifier)); // Initial size count of all connected components connectedComponentsSize.put(newIdentifier, size); } } remapMarks(); }