This class implements the data structure and methods for concept lattices.
Super class
fcaR::ConceptSet -> ConceptLattice
Methods
Method new()
Create a new ConceptLattice object.
Usage
ConceptLattice$new(extents, intents, objects, attributes, I = NULL)Method plot()
Plot the concept lattice
Usage
ConceptLattice$plot(
object_names = TRUE,
to_latex = FALSE,
method = c("sugiyama", "force"),
mode = NULL,
...
)Arguments
object_names(logical) Deprecated. Use
modeinstead. IfTRUE(default), impliesmode = "reduced"or similar depending on heuristics. Kept for backward compatibility.to_latex(logical) If
TRUE, exports the plot as TikZ code (LaTeX) instead of drawing it. Returns an object of classtikz_codethat prints the LaTeX code to console.method(character) The layout algorithm to use. Options are:
"sugiyama"(default): A hierarchical layout that minimizes edge crossings and centers nodes (similar to ConExp or hasseDiagram)."force": A force-directed (spring) layout, useful for large or non-hierarchical lattices.
mode(character) The labeling mode for the nodes. If
NULL(default), a heuristic based on lattice size is used. Options are:"reduced": Standard FCA labeling. Nodes are labeled with an attribute (or object) only if they are the supreme (or infimum) of that attribute (or object)."full": Each node shows its complete extent and intent."attributes": Nodes show only their intent (attributes)."empty": Nodes are drawn as points without labels. Recommended for very large lattices (>50 concepts).
...Other parameters passed to the internal plotting function (e.g., graphical parameters for
ggraph).
Method sublattice()
Sublattice
Method top()
Top of a Lattice
Examples
fc <- FormalContext$new(planets)
fc$find_concepts()
fc$concepts$top()
Method bottom()
Bottom of a Lattice
Examples
fc <- FormalContext$new(planets)
fc$find_concepts()
fc$concepts$bottom()
Method decompose()
Decompose a concept as the supremum of meet-irreducible concepts
Method supremum()
Supremum of Concepts
Method infimum()
Infimum of Concepts
Method separation()
Computes the separation of each concept. Separation is the number of objects covered by the concept but not by any of its immediate subconcepts.
Method density()
Computes the fuzzy density of each concept.
Method check_properties()
Check algebraic properties of the lattice (Distributivity and Modularity).
Method is_distributive()
Check if the lattice is distributive. A lattice is distributive if \(x \wedge (y \vee z) = (x \wedge y) \vee (x \wedge z)\) for all elements.
Method is_modular()
Check if the lattice is modular. A lattice is modular if \(x \le z \implies x \vee (y \wedge z) = (x \vee y) \wedge z\). Distributive lattices are always modular.
Examples
# Build a formal context
fc_planets <- FormalContext$new(planets)
# Find the concepts
fc_planets$find_concepts()
# Find join- and meet- irreducible elements
fc_planets$concepts$join_irreducibles()
#> A set of 5 concepts:
#> 1: ({Uranus, Neptune}, {medium, far, moon})
#> 2: ({Jupiter, Saturn}, {large, far, moon})
#> 3: ({Mercury, Venus}, {small, near, no_moon})
#> 4: ({Earth, Mars}, {small, near, moon})
#> 5: ({Pluto}, {small, far, moon})
fc_planets$concepts$meet_irreducibles()
#> A set of 7 concepts:
#> 1: ({Uranus, Neptune}, {medium, far, moon})
#> 2: ({Jupiter, Saturn}, {large, far, moon})
#> 3: ({Mercury, Venus}, {small, near, no_moon})
#> 4: ({Mercury, Venus, Earth, Mars}, {small, near})
#> 5: ({Mercury, Venus, Earth, Mars, Pluto}, {small})
#> 6: ({Jupiter, Saturn, Uranus, Neptune, Pluto}, {far, moon})
#> 7: ({Earth, Mars, Jupiter, Saturn, Uranus, Neptune, Pluto}, {moon})
# Get concept support
fc_planets$concepts$support()
#> [1] 0.0000000 1.0000000 0.2222222 0.2222222 0.2222222 0.4444444 0.2222222
#> [8] 0.5555556 0.1111111 0.3333333 0.5555556 0.7777778
## ------------------------------------------------
## Method `ConceptLattice$top`
## ------------------------------------------------
fc <- FormalContext$new(planets)
fc$find_concepts()
fc$concepts$top()
#> ({Mercury, Venus, Earth, Mars, Jupiter, Saturn, Uranus, Neptune, Pluto}, {})
## ------------------------------------------------
## Method `ConceptLattice$bottom`
## ------------------------------------------------
fc <- FormalContext$new(planets)
fc$find_concepts()
fc$concepts$bottom()
#> ({}, {small, medium, large, near, far, moon, no_moon})