Skip to contents

List coalitions that an element appears in.


elementLookup(powerRelation, element)



A PowerRelation object created by PowerRelation() or as.PowerRelation()


an element in powerRelation$elements


List of tuples, each of size 2. First value of a tuple indicates the equivalence class index, the second value the index inside that equivalence class with the coalition containing the element. Returns NULL if the element does not exist.


This function calls powerRelation$elementLookup(element). The returned list contains tuples containing the index to find the corresponding coalitions in powerRelation$eqs.

If elementLookup(powerRelation, 2) returns list(c(1,1), c(1,2), c(3,1)), we can determine that the element 2 appears twice in equivalence class 1 and once in equivalence class 3. The specific coalition then can be accessed with powerRelation$eqs[[i]][[j]], where i is the equivalence class index and j is the coalition in that equivalence class containing the element.

See also

Other lookup functions: coalitionsAreIndifferent(), equivalenceClassIndex()


pr <- as.PowerRelation("12 > 2 ~ 1")

l <- elementLookup(pr, 1)
#> [[1]]
#> [1] 1 1
#> [[2]]
#> [1] 2 2
# (1,1), (2,2)

sapply(l, function(tuple) 1 %in% pr$eqs[[tuple[1]]][[tuple[2]]]) |> all() |> stopifnot()

# if element does not exist, it returns NULL
elementLookup(pr, 3) |> is.null() |> stopifnot()