ConceptLattice extends CompleteLattice<Concept> { public Concept insert(final Concept concept) { Vertex added = super.addIntent(concept, top); List queue = new ArrayList(); added.setProperty(COLOR, ++color); queue.add(added); while (!queue.isEmpty()) { Vertex visiting = (Vertex) queue.remove(0); Concept visitingConcept = visiting.getProperty(LABEL); visitingConcept.extent().or(concept.extent()); for (Edge edge : visiting.getEdges(Direction.BOTH)) { Vertex target = edge.getVertex(Direction.OUT); if ((int) target.getProperty(COLOR) != color) { if (filter(visiting, target)) { target.setProperty(COLOR, color); queue.add(target); } } } } return added.getProperty(LABEL); } ConceptLattice(final Graph graph, long numBits); Concept insert(final Concept concept); @Override final Concept join(final Concept left, final Concept right);  }
@Test public void testInsert() { Concept top = (Concept) lattice.top(); Concept bottom = (Concept) lattice.bottom(); assertEquals(top.intent(), bits(0, 1, 2, 3, 4, 5, 6)); assertEquals(top.extent(), bits()); assertEquals(bottom.intent(), bits()); assertEquals(bottom.extent(), bits(0, 1, 2, 3, 4, 5)); assertEquals(lattice.size(), 12); }