Copyright | (c) Immanuel Albrecht 2020-202x |
---|---|
License | BSD-3 |
Maintainer | mail@immanuel-albrecht.de |
Stability | experimental |
Portability | POSIX |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
This module provides the Matroid typeclass.
Synopsis
- class (Ord a, Show a) => Matroid m a where
- groundset :: m a -> Set a
- showName :: m a -> String
- rk :: m a -> Set a -> Int
- indep :: m a -> Set a -> Bool
- basis :: m a -> Set a -> Set a
- cl :: m a -> Set a -> Set a
- abstract :: m a -> AMatroid a
- dual :: m a -> AMatroid a
- restriction :: m a -> Set a -> AMatroid a
- contraction :: m a -> Set a -> AMatroid a
- loops :: m a -> Set a
- coRk :: m a -> Set a -> Int
- coloops :: m a -> Set a
- wrapUp :: Matroid m a => m a -> AMatroid a
Documentation
class (Ord a, Show a) => Matroid m a where Source #
Typeclass that provides the full matroid interface.
The type parameter a
is the type of the elements of the matroid,
it is most commonly used in a (
type.Set
a)
In this typeclass, we assume that every set of matroid elements
passed to any of the routines is actually a subset of
.
Behaviour for other sets shall be considered undefined.groundset
m
In order to keep things DRY, the default implementations are fumbled through
the
instance definition below through AMatroid
awrapUp
and setting the
corresponding record value to Nothing
.
groundset :: m a -> Set a Source #
The ground set of the matroid, its elements are usually called edges. This set is finite.
showName :: m a -> String Source #
name of the matroid, may be used for show
returns the rank of the set
tests whether a given set is independent
obtains an independent subset of the input subset, which has maximal cardinality among all such subsets.
Please note that this routine returns a basis of the input subset wrt. the matroid, which is not necessarily also a basis of the matroid itself. You can obtain at least one basis of the matroid via
basis m $ groundset m
computes the closure of a given set
:: m a | matroid |
-> AMatroid a |
returns this matroid as abstract matroid object
:: m a | matroid |
-> AMatroid a |
returns the dual of this matroid as abstract matroid object
returns the restricted matroid M|X as result of the unary matroid operation *|X
returns the contracted matroid M.X as a result of the unary matroid operation *.X
:: m a | the matroid |
-> Set a |
returns the loops in the matroid
rank function of the dual matroid
:: m a | the matroid |
-> Set a |
returns the coloops in the matroid