This class implements the data structure and methods for concept lattices.
fcaR::ConceptSet -> ConceptLattice
new()Create a new ConceptLattice object.
ConceptLattice$new(extents, intents, objects, attributes, I = NULL)extents(dgCMatrix) The extents of all concepts
intents(dgCMatrix) The intents of all concepts
objects(character vector) Names of the objects in the formal context
attributes(character vector) Names of the attributes in the formal context
I(dgCMatrix) The matrix of the formal context
A new ConceptLattice object.
plot()Plot the concept lattice
ConceptLattice$plot(
object_names = TRUE,
to_latex = FALSE,
method = c("sugiyama", "force"),
mode = NULL,
...
)object_names(logical) Deprecated. Use mode instead. If TRUE (default), implies mode = "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 class tikz_code that 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).
If to_latex is FALSE, it returns (invisibly) the ggplot2 object representing the graph.
If to_latex is TRUE, it returns a tikz_code object containing the LaTeX code.
sublattice()Sublattice
ConceptLattice$sublattice(...)...See Details.
As argument, one can provide both integer indices or Concepts, separated by commas. The corresponding concepts are used to generate a sublattice.
The generated sublattice as a new ConceptLattice object.
top()Top of a Lattice
ConceptLattice$top()The top of the Concept Lattice
fc <- FormalContext$new(planets)
fc$find_concepts()
fc$concepts$top()
bottom()Bottom of a Lattice
ConceptLattice$bottom()The bottom of the Concept Lattice
fc <- FormalContext$new(planets)
fc$find_concepts()
fc$concepts$bottom()
join_irreducibles()Join-irreducible Elements
ConceptLattice$join_irreducibles()The join-irreducible elements in the concept lattice.
meet_irreducibles()Meet-irreducible Elements
ConceptLattice$meet_irreducibles()The meet-irreducible elements in the concept lattice.
decompose()Decompose a concept as the supremum of meet-irreducible concepts
ConceptLattice$decompose(C)CA list of Concepts
A list, each field is the set of meet-irreducible elements whose supremum is the corresponding element in C.
supremum()Supremum of Concepts
ConceptLattice$supremum(...)...See Details.
As argument, one can provide both integer indices or Concepts, separated by commas. The corresponding concepts are used to compute their supremum in the lattice.
The supremum of the list of concepts.
infimum()Infimum of Concepts
ConceptLattice$infimum(...)...See Details.
As argument, one can provide both integer indices or Concepts, separated by commas. The corresponding concepts are used to compute their infimum in the lattice.
The infimum of the list of concepts.
subconcepts()Subconcepts of a Concept
ConceptLattice$subconcepts(C)C(numeric or SparseConcept) The concept to which determine all its subconcepts.
A list with the subconcepts.
superconcepts()Superconcepts of a Concept
ConceptLattice$superconcepts(C)C(numeric or SparseConcept) The concept to which determine all its superconcepts.
A list with the superconcepts.
lower_neighbours()Lower Neighbours of a Concept
ConceptLattice$lower_neighbours(C)C(SparseConcept) The concept to which find its lower neighbours
A list with the lower neighbours of C.
upper_neighbours()Upper Neighbours of a Concept
ConceptLattice$upper_neighbours(C)C(SparseConcept) The concept to which find its upper neighbours
A list with the upper neighbours of C.
stability()Computes the stability of each concept.
ConceptLattice$stability()A numeric vector with the stability of each concept.
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.
ConceptLattice$separation()A numeric vector with the separation of each concept.
I(Optional) The original incidence matrix. If NULL, it tries to access it from the parent FormalContext if linked.
A numeric vector with the density of each concept.
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.
ConceptLattice$is_distributive()Logical.
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.
ConceptLattice$is_modular()Logical.
is_semimodular()Check if the lattice is upper semimodular. A lattice is upper semimodular if for every \(x, y\): if \(x\) covers \(x \wedge y\), then \(x \vee y\) covers \(y\).
ConceptLattice$is_semimodular()Logical.
is_atomic()Check if the lattice is atomic. A lattice is atomic if for every element \(x > \bot\), there exists an atom \(a\) such that \(a \le x\). Atoms are elements that cover the bottom element.
ConceptLattice$is_atomic()Logical.
set_state()Internal method to set state from JSON import
ConceptLattice$set_state(state)stateList of internal state variables
to_json()Export the concept lattice to JSON
ConceptLattice$to_json(file = NULL, return_list = FALSE)file(character) The path of the file to save the JSON to.
return_list(logical) If TRUE, returns the list representation instead of the JSON string.
A JSON string representing the concept lattice, or a list if return_list is TRUE.
clone()The objects of this class are cloneable with this method.
ConceptLattice$clone(deep = FALSE)deepWhether to make a deep clone.
# 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()
fc_planets$concepts$meet_irreducibles()
# Get concept support
fc_planets$concepts$support()
## ------------------------------------------------
## Method `ConceptLattice$top`
## ------------------------------------------------
fc <- FormalContext$new(planets)
fc$find_concepts()
fc$concepts$top()
## ------------------------------------------------
## Method `ConceptLattice$bottom`
## ------------------------------------------------
fc <- FormalContext$new(planets)
fc$find_concepts()
fc$concepts$bottom()
Run the code above in your browser using DataLab