List of usage examples for org.apache.commons.collections CollectionUtils containsAny
public static boolean containsAny(final Collection coll1, final Collection coll2)
true
iff at least one element is in both collections. From source file:test.edu.uci.ics.jung.algorithms.cluster.TestWeakComponentClusterer.java
public void testComponentHasIsolate() { Graph graph = getGraph();//from w w w .ja v a 2 s . c o m GraphUtils.addVertices(graph, 5); Indexer id = Indexer.getIndexer(graph); GraphUtils.addEdge(graph, (Vertex) id.getVertex(0), (Vertex) id.getVertex(1)); GraphUtils.addEdge(graph, (Vertex) id.getVertex(0), (Vertex) id.getVertex(2)); GraphUtils.addEdge(graph, (Vertex) id.getVertex(2), (Vertex) id.getVertex(3)); WeakComponentClusterer wcSearch = new WeakComponentClusterer(); ClusterSet componentList = wcSearch.extract(graph); Assert.assertEquals(componentList.size(), 2); Set z = componentList.getCluster(0); Set z1 = componentList.getCluster(1); assertFalse(CollectionUtils.containsAny(z, z1)); assertEquals(graph.getVertices(), new HashSet(CollectionUtils.union(z, z1))); }
From source file:test.edu.uci.ics.jung.algorithms.cluster.TestWeakComponentClusterer.java
public void testComponentAllIsolates() { Graph graph = getGraph();/* www. j ava2 s . co m*/ GraphUtils.addVertices(graph, 2); WeakComponentClusterer wcSearch = new WeakComponentClusterer(); ClusterSet componentList = wcSearch.extract(graph); Assert.assertEquals(componentList.size(), 2); Set z = componentList.getCluster(0); Set z1 = componentList.getCluster(1); assertFalse(CollectionUtils.containsAny(z, z1)); assertEquals(graph.getVertices(), new HashSet(CollectionUtils.union(z, z1))); }
From source file:test.edu.uci.ics.jung.algorithms.cluster.TestWeakComponentClusterer.java
public void testExtractTwoComponents() { Graph graph = getGraph();// w w w. jav a 2s. c om GraphUtils.addVertices(graph, 5); Indexer id = Indexer.getIndexer(graph); GraphUtils.addEdge(graph, (Vertex) id.getVertex(0), (Vertex) id.getVertex(1)); GraphUtils.addEdge(graph, (Vertex) id.getVertex(0), (Vertex) id.getVertex(2)); GraphUtils.addEdge(graph, (Vertex) id.getVertex(3), (Vertex) id.getVertex(4)); WeakComponentClusterer wcSearch = new WeakComponentClusterer(); ClusterSet componentList = wcSearch.extract(graph); Assert.assertEquals(componentList.size(), 2); Set z = componentList.getCluster(0); Set z1 = componentList.getCluster(1); assertFalse(CollectionUtils.containsAny(z, z1)); assertEquals(graph.getVertices(), new HashSet(CollectionUtils.union(z, z1))); }
From source file:ubic.gemma.analysis.expression.coexpression.links.AbstractMatrixRowPairAnalysis.java
/** * Determine if the probes at this location in the matrix assay any of the same gene(s) * /*w ww .j a v a 2s . com*/ * @param i * @param j * @return true if the probes hit the same gene; false otherwise. */ private boolean crossHybridizes(int i, int j) { if (this.dataMatrix == null) return false; // can happen in tests. ExpressionDataMatrixRowElement itemA = this.dataMatrix.getRowElement(i); ExpressionDataMatrixRowElement itemB = this.dataMatrix.getRowElement(j); Collection<Gene> genesA = this.flatProbe2GeneMap.get(itemA.getDesignElement()); Collection<Gene> genesB = this.flatProbe2GeneMap.get(itemB.getDesignElement()); return CollectionUtils.containsAny(genesA, genesB); }
From source file:ubic.gemma.core.analysis.expression.coexpression.links.AbstractMatrixRowPairAnalysis.java
/** * Determine if the probes at this location in the matrix assay any of the same gene(s). This has nothing to do with * whether the probes are specific, though non-specific probes (which hit more than one gene) are more likely to be * affected by this./* w ww. ja v a2 s . c o m*/ * * @return true if the probes hit the same gene; false otherwise. If the probes hit more than one gene, and any of * the genes are in common, the result is 'true'. */ private boolean crossHybridizes(int i, int j) { if (this.dataMatrix == null) return false; // can happen in tests. ExpressionDataMatrixRowElement itemA = this.dataMatrix.getRowElement(i); ExpressionDataMatrixRowElement itemB = this.dataMatrix.getRowElement(j); Collection<Gene> genesA = this.probeToGeneMap.get(itemA.getDesignElement()); Collection<Gene> genesB = this.probeToGeneMap.get(itemB.getDesignElement()); return CollectionUtils.containsAny(genesA, genesB); }