def from_spanning_matroid(matroid: tuple[set[T], list[set[T]]]) -> Callable[[set[T]], int]:
    """Construct a nulity function from a matroid defined by spanning sets.

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

    Returns:
        Callable[[set[T]], int]: The nulity function of a given matroid.
    """
    E, _ = matroid
    return from_independent_matroid((E, independent_sets.from_spanning_matroid(matroid)))
Exemple #2
0
def from_spanning_matroid(matroid: tuple[set[T], list[set[T]]]) -> list[set[T]]:
    """Construct dependent sets from a matroid defined by spanning sets.

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

    Returns:
        list[set[T]]: The dependent sets of a matroid.
    """
    E, _ = matroid
    return from_independent_matroid((E, independent_sets.from_spanning_matroid(matroid)))
Exemple #3
0
def test_from_spanning_matroid(spanning_matroid, expected):
    Is1 = from_spanning_matroid(spanning_matroid)
    Is2 = expected
    assert all(map(lambda I1: I1 in Is2, Is1)) and all(map(lambda I2: I2 in Is1, Is2))
Exemple #4
0
 def independent_sets(self) -> list[set[T]]:
     return independent_sets.from_spanning_matroid((self.ground_set, self.spanning_sets))