public boolean initialize ( ) { AddressBean addressBean =getActiveAddressBean ( ); // TODO: negative values? timer = new Timer( addressBean.getPredicateValueAsInt( CLOCK_PERIOD_KEY ,DEFAULT_CLOCK_PERIODS) , this ); maximumDelay = addressBean.getPredicateValueAsInt(MAX_DELAY_KEY, DEFAULT_MAX_DELAY); if(maximumDelay > 0){ streamElementBuffer = SynchronizedBuffer.decorate(new UnboundedFifoBuffer()); delayPostingElements = true; if(timer.getDelay() < maximumDelay) logger.warn("Maximum delay is greater than element production interval. Running for a long time may lead to an OutOfMemoryException" ); } return true; }
/** * Extracts the weak components from a graph. * @param aGraph the graph whose weak components are to be extracted * @return the list of weak components */ public ClusterSet extract(ArchetypeGraph aGraph) { ClusterSet clusterSet = new VertexClusterSet(aGraph); HashSet unvisitedVertices = new HashSet(); for (Iterator vIt=aGraph.getVertices().iterator(); vIt.hasNext();) { unvisitedVertices.add(vIt.next()); } while (!unvisitedVertices.isEmpty()) { Set weakComponentSet = new HashSet(); ArchetypeVertex root = (ArchetypeVertex) unvisitedVertices.iterator().next(); unvisitedVertices.remove(root); weakComponentSet.add(root); Buffer queue = new UnboundedFifoBuffer(); queue.add(root); while (!queue.isEmpty()) { ArchetypeVertex currentVertex = (ArchetypeVertex) queue.remove(); Set neighbors = currentVertex.getNeighbors(); for (Iterator nIt = neighbors.iterator(); nIt.hasNext();) { ArchetypeVertex neighbor = (ArchetypeVertex) nIt.next(); if (unvisitedVertices.contains(neighbor)) { queue.add(neighbor); unvisitedVertices.remove(neighbor); weakComponentSet.add(neighbor); } } } clusterSet.addCluster(weakComponentSet); } return clusterSet; }