Ejemplo n.º 1
0
def from_open_matroid(matroid: tuple[set[T], list[set[T]]]) -> Callable[[set[T]], int]:
    """Construct a nulity function from a matroid defined by open sets.

    Args:
        matroid (tuple[set[T], list[set[T]]]): A matroid defined by open sets.

    Returns:
        Callable[[set[T]], int]: The nulity function of a matroid.
    """
    E, _ = matroid
    return from_independent_matroid((E, independent_sets.from_open_matroid(matroid)))
Ejemplo n.º 2
0
def from_open_matroid(matroid: tuple[set[T], list[set[T]]]) -> list[set[T]]:
    """Construct dependent sets from a matroid defined by open sets.

    Args:
        matroid (tuple[set[T], list[set[T]]]): A matroid defined by open sets.

    Returns:
        list[set[T]]: The dependent sets of a matroid.
    """
    E, _ = matroid
    return from_independent_matroid((E, independent_sets.from_open_matroid(matroid)))
Ejemplo n.º 3
0
def test_from_open_matroid(open_matroid, expected):
    Is1 = from_open_matroid(open_matroid)
    Is2 = expected
    assert all(map(lambda I1: I1 in Is2, Is1)) and all(map(lambda I2: I2 in Is1, Is2))
Ejemplo n.º 4
0
 def independent_sets(self) -> list[set[T]]:
     return independent_sets.from_open_matroid(
         (self.ground_set, self.open_sets))