fca :: ConceptLattice :: defaultinit
# Concept Lattice
#
# Formal concepts are partially ordered with regard to inclusion of their extents
# or (which is equivalent) inverse inclusion of their intent.
class ConceptLattice[O: Object, A: Object]
super POSet[FormalConcept[O, A]]
# Build `self` from a set of formal `concepts`.
init from_concepts(concepts: Set[FormalConcept[O, A]]) do
for c in concepts do
add_node c
end
for c1 in concepts do
for c2 in concepts do
if c1 == c2 then continue
if not is_lower_neighbour(c1, c2, concepts) then continue
add_edge(c2, c1)
end
end
end
# Is `sub` the greatest lower bound of `sup` considering all `concepts`?
fun is_lower_neighbour(sub, sup: FormalConcept[O, A], concepts: Set[FormalConcept[O, A]]): Bool
do
if sub == sup then return false
if not sub.is_subconcept(sup) then return false
for concept in concepts do
if sub == concept then continue
if sup == concept then continue
if not sub.is_subconcept(concept) then continue
if not concept.is_subconcept(sup) then continue
return false
end
return true
end
end
lib/fca/fca.nit:218,1--253,3