module Algebra.Graph.NonEmpty.AdjacencyMap (
AdjacencyMap, toNonEmpty, fromNonEmpty,
vertex, edge, overlay, connect, vertices1, edges1, overlays1, connects1,
isSubgraphOf,
hasVertex, hasEdge, vertexCount, edgeCount, vertexList1, edgeList,
vertexSet, edgeSet, preSet, postSet,
path1, circuit1, clique1, biclique1, star, stars1, tree,
removeVertex1, removeEdge, replaceVertex, mergeVertices, transpose, gmap,
induce1, induceJust1,
closure, reflexiveClosure, symmetricClosure, transitiveClosure,
consistent
) where
import Prelude hiding (reverse)
import Control.DeepSeq
import Data.Coerce
import Data.List ((\\))
import Data.List.NonEmpty (NonEmpty (..), nonEmpty, toList, reverse)
import Data.Maybe
import Data.Set (Set)
import Data.String
import Data.Tree
import GHC.Generics
import qualified Algebra.Graph.AdjacencyMap as AM
import qualified Data.Set as Set
newtype AdjacencyMap a = NAM { forall a. AdjacencyMap a -> AdjacencyMap a
am :: AM.AdjacencyMap a }
deriving (AdjacencyMap a -> AdjacencyMap a -> Bool
forall a. Eq a => AdjacencyMap a -> AdjacencyMap a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AdjacencyMap a -> AdjacencyMap a -> Bool
$c/= :: forall a. Eq a => AdjacencyMap a -> AdjacencyMap a -> Bool
== :: AdjacencyMap a -> AdjacencyMap a -> Bool
$c== :: forall a. Eq a => AdjacencyMap a -> AdjacencyMap a -> Bool
Eq, forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall a x. Rep (AdjacencyMap a) x -> AdjacencyMap a
forall a x. AdjacencyMap a -> Rep (AdjacencyMap a) x
$cto :: forall a x. Rep (AdjacencyMap a) x -> AdjacencyMap a
$cfrom :: forall a x. AdjacencyMap a -> Rep (AdjacencyMap a) x
Generic, String -> AdjacencyMap a
forall a. IsString a => String -> AdjacencyMap a
forall a. (String -> a) -> IsString a
fromString :: String -> AdjacencyMap a
$cfromString :: forall a. IsString a => String -> AdjacencyMap a
IsString, AdjacencyMap a -> ()
forall a. NFData a => AdjacencyMap a -> ()
forall a. (a -> ()) -> NFData a
rnf :: AdjacencyMap a -> ()
$crnf :: forall a. NFData a => AdjacencyMap a -> ()
NFData, AdjacencyMap a -> AdjacencyMap a -> Bool
AdjacencyMap a -> AdjacencyMap a -> Ordering
AdjacencyMap a -> AdjacencyMap a -> AdjacencyMap a
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
forall {a}. Ord a => Eq (AdjacencyMap a)
forall a. Ord a => AdjacencyMap a -> AdjacencyMap a -> Bool
forall a. Ord a => AdjacencyMap a -> AdjacencyMap a -> Ordering
forall a.
Ord a =>
AdjacencyMap a -> AdjacencyMap a -> AdjacencyMap a
min :: AdjacencyMap a -> AdjacencyMap a -> AdjacencyMap a
$cmin :: forall a.
Ord a =>
AdjacencyMap a -> AdjacencyMap a -> AdjacencyMap a
max :: AdjacencyMap a -> AdjacencyMap a -> AdjacencyMap a
$cmax :: forall a.
Ord a =>
AdjacencyMap a -> AdjacencyMap a -> AdjacencyMap a
>= :: AdjacencyMap a -> AdjacencyMap a -> Bool
$c>= :: forall a. Ord a => AdjacencyMap a -> AdjacencyMap a -> Bool
> :: AdjacencyMap a -> AdjacencyMap a -> Bool
$c> :: forall a. Ord a => AdjacencyMap a -> AdjacencyMap a -> Bool
<= :: AdjacencyMap a -> AdjacencyMap a -> Bool
$c<= :: forall a. Ord a => AdjacencyMap a -> AdjacencyMap a -> Bool
< :: AdjacencyMap a -> AdjacencyMap a -> Bool
$c< :: forall a. Ord a => AdjacencyMap a -> AdjacencyMap a -> Bool
compare :: AdjacencyMap a -> AdjacencyMap a -> Ordering
$ccompare :: forall a. Ord a => AdjacencyMap a -> AdjacencyMap a -> Ordering
Ord)
instance (Ord a, Num a) => Num (AdjacencyMap a) where
fromInteger :: Integer -> AdjacencyMap a
fromInteger = forall a. a -> AdjacencyMap a
vertex forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Num a => Integer -> a
fromInteger
+ :: AdjacencyMap a -> AdjacencyMap a -> AdjacencyMap a
(+) = forall a.
Ord a =>
AdjacencyMap a -> AdjacencyMap a -> AdjacencyMap a
overlay
* :: AdjacencyMap a -> AdjacencyMap a -> AdjacencyMap a
(*) = forall a.
Ord a =>
AdjacencyMap a -> AdjacencyMap a -> AdjacencyMap a
connect
signum :: AdjacencyMap a -> AdjacencyMap a
signum = forall a. HasCallStack => String -> a
error String
"NonEmpty.AdjacencyMap.signum cannot be implemented."
abs :: AdjacencyMap a -> AdjacencyMap a
abs = forall a. a -> a
id
negate :: AdjacencyMap a -> AdjacencyMap a
negate = forall a. a -> a
id
instance (Ord a, Show a) => Show (AdjacencyMap a) where
showsPrec :: Int -> AdjacencyMap a -> ShowS
showsPrec Int
p AdjacencyMap a
nam
| forall (t :: * -> *) a. Foldable t => t a -> Bool
null [a]
vs = forall a. HasCallStack => String -> a
error String
"NonEmpty.AdjacencyMap.Show: Graph is empty"
| forall (t :: * -> *) a. Foldable t => t a -> Bool
null [(a, a)]
es = Bool -> ShowS -> ShowS
showParen (Int
p forall a. Ord a => a -> a -> Bool
> Int
10) forall a b. (a -> b) -> a -> b
$ forall {a}. Show a => [a] -> ShowS
vshow [a]
vs
| [a]
vs forall a. Eq a => a -> a -> Bool
== [a]
used = Bool -> ShowS -> ShowS
showParen (Int
p forall a. Ord a => a -> a -> Bool
> Int
10) forall a b. (a -> b) -> a -> b
$ forall {a} {a}. (Show a, Show a) => [(a, a)] -> ShowS
eshow [(a, a)]
es
| Bool
otherwise = Bool -> ShowS -> ShowS
showParen (Int
p forall a. Ord a => a -> a -> Bool
> Int
10) forall a b. (a -> b) -> a -> b
$
String -> ShowS
showString String
"overlay (" forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall {a}. Show a => [a] -> ShowS
vshow ([a]
vs forall a. Eq a => [a] -> [a] -> [a]
\\ [a]
used) forall b c a. (b -> c) -> (a -> b) -> a -> c
.
String -> ShowS
showString String
") (" forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall {a} {a}. (Show a, Show a) => [(a, a)] -> ShowS
eshow [(a, a)]
es forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShowS
showString String
")"
where
vs :: [a]
vs = forall a. NonEmpty a -> [a]
toList (forall a. AdjacencyMap a -> NonEmpty a
vertexList1 AdjacencyMap a
nam)
es :: [(a, a)]
es = forall a. AdjacencyMap a -> [(a, a)]
edgeList AdjacencyMap a
nam
vshow :: [a] -> ShowS
vshow [a
x] = String -> ShowS
showString String
"vertex " forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Show a => Int -> a -> ShowS
showsPrec Int
11 a
x
vshow [a]
xs = String -> ShowS
showString String
"vertices1 " forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Show a => Int -> a -> ShowS
showsPrec Int
11 [a]
xs
eshow :: [(a, a)] -> ShowS
eshow [(a
x, a
y)] = String -> ShowS
showString String
"edge " forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Show a => Int -> a -> ShowS
showsPrec Int
11 a
x forall b c a. (b -> c) -> (a -> b) -> a -> c
.
String -> ShowS
showString String
" " forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Show a => Int -> a -> ShowS
showsPrec Int
11 a
y
eshow [(a, a)]
xs = String -> ShowS
showString String
"edges1 " forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Show a => Int -> a -> ShowS
showsPrec Int
11 [(a, a)]
xs
used :: [a]
used = forall a. Set a -> [a]
Set.toAscList forall a b. (a -> b) -> a -> b
$ forall a. Ord a => [a] -> Set a
Set.fromList forall a b. (a -> b) -> a -> b
$ forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry forall a. [a] -> [a] -> [a]
(++) forall a b. (a -> b) -> a -> b
$ forall a b. [(a, b)] -> ([a], [b])
unzip [(a, a)]
es
instance Ord a => Semigroup (AdjacencyMap a) where
<> :: AdjacencyMap a -> AdjacencyMap a -> AdjacencyMap a
(<>) = forall a.
Ord a =>
AdjacencyMap a -> AdjacencyMap a -> AdjacencyMap a
overlay
unsafeNonEmpty :: [a] -> NonEmpty a
unsafeNonEmpty :: forall a. [a] -> NonEmpty a
unsafeNonEmpty = forall a. a -> Maybe a -> a
fromMaybe (forall a. HasCallStack => String -> a
error String
msg) forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. [a] -> Maybe (NonEmpty a)
nonEmpty
where
msg :: String
msg = String
"Algebra.Graph.AdjacencyMap.unsafeNonEmpty: Graph is empty"
toNonEmpty :: AM.AdjacencyMap a -> Maybe (AdjacencyMap a)
toNonEmpty :: forall a. AdjacencyMap a -> Maybe (AdjacencyMap a)
toNonEmpty AdjacencyMap a
x | forall a. AdjacencyMap a -> Bool
AM.isEmpty AdjacencyMap a
x = forall a. Maybe a
Nothing
| Bool
otherwise = forall a. a -> Maybe a
Just (forall a. AdjacencyMap a -> AdjacencyMap a
NAM AdjacencyMap a
x)
fromNonEmpty :: AdjacencyMap a -> AM.AdjacencyMap a
fromNonEmpty :: forall a. AdjacencyMap a -> AdjacencyMap a
fromNonEmpty = forall a. AdjacencyMap a -> AdjacencyMap a
am
vertex :: a -> AdjacencyMap a
vertex :: forall a. a -> AdjacencyMap a
vertex = coerce :: forall a b. Coercible a b => a -> b
coerce forall a. a -> AdjacencyMap a
AM.vertex
{-# NOINLINE [1] vertex #-}
edge :: Ord a => a -> a -> AdjacencyMap a
edge :: forall a. Ord a => a -> a -> AdjacencyMap a
edge = coerce :: forall a b. Coercible a b => a -> b
coerce forall a. Ord a => a -> a -> AdjacencyMap a
AM.edge
overlay :: Ord a => AdjacencyMap a -> AdjacencyMap a -> AdjacencyMap a
overlay :: forall a.
Ord a =>
AdjacencyMap a -> AdjacencyMap a -> AdjacencyMap a
overlay = coerce :: forall a b. Coercible a b => a -> b
coerce forall a.
Ord a =>
AdjacencyMap a -> AdjacencyMap a -> AdjacencyMap a
AM.overlay
{-# NOINLINE [1] overlay #-}
connect :: Ord a => AdjacencyMap a -> AdjacencyMap a -> AdjacencyMap a
connect :: forall a.
Ord a =>
AdjacencyMap a -> AdjacencyMap a -> AdjacencyMap a
connect = coerce :: forall a b. Coercible a b => a -> b
coerce forall a.
Ord a =>
AdjacencyMap a -> AdjacencyMap a -> AdjacencyMap a
AM.connect
{-# NOINLINE [1] connect #-}
vertices1 :: Ord a => NonEmpty a -> AdjacencyMap a
vertices1 :: forall a. Ord a => NonEmpty a -> AdjacencyMap a
vertices1 = coerce :: forall a b. Coercible a b => a -> b
coerce forall a. Ord a => [a] -> AdjacencyMap a
AM.vertices forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. NonEmpty a -> [a]
toList
{-# NOINLINE [1] vertices1 #-}
edges1 :: Ord a => NonEmpty (a, a) -> AdjacencyMap a
edges1 :: forall a. Ord a => NonEmpty (a, a) -> AdjacencyMap a
edges1 = coerce :: forall a b. Coercible a b => a -> b
coerce forall a. Ord a => [(a, a)] -> AdjacencyMap a
AM.edges forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. NonEmpty a -> [a]
toList
overlays1 :: Ord a => NonEmpty (AdjacencyMap a) -> AdjacencyMap a
overlays1 :: forall a. Ord a => NonEmpty (AdjacencyMap a) -> AdjacencyMap a
overlays1 = coerce :: forall a b. Coercible a b => a -> b
coerce forall a. Ord a => [AdjacencyMap a] -> AdjacencyMap a
AM.overlays forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. NonEmpty a -> [a]
toList
{-# NOINLINE overlays1 #-}
connects1 :: Ord a => NonEmpty (AdjacencyMap a) -> AdjacencyMap a
connects1 :: forall a. Ord a => NonEmpty (AdjacencyMap a) -> AdjacencyMap a
connects1 = coerce :: forall a b. Coercible a b => a -> b
coerce forall a. Ord a => [AdjacencyMap a] -> AdjacencyMap a
AM.connects forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. NonEmpty a -> [a]
toList
{-# NOINLINE connects1 #-}
isSubgraphOf :: Ord a => AdjacencyMap a -> AdjacencyMap a -> Bool
isSubgraphOf :: forall a. Ord a => AdjacencyMap a -> AdjacencyMap a -> Bool
isSubgraphOf = coerce :: forall a b. Coercible a b => a -> b
coerce forall a. Ord a => AdjacencyMap a -> AdjacencyMap a -> Bool
AM.isSubgraphOf
hasVertex :: Ord a => a -> AdjacencyMap a -> Bool
hasVertex :: forall a. Ord a => a -> AdjacencyMap a -> Bool
hasVertex = coerce :: forall a b. Coercible a b => a -> b
coerce forall a. Ord a => a -> AdjacencyMap a -> Bool
AM.hasVertex
hasEdge :: Ord a => a -> a -> AdjacencyMap a -> Bool
hasEdge :: forall a. Ord a => a -> a -> AdjacencyMap a -> Bool
hasEdge = coerce :: forall a b. Coercible a b => a -> b
coerce forall a. Ord a => a -> a -> AdjacencyMap a -> Bool
AM.hasEdge
vertexCount :: AdjacencyMap a -> Int
vertexCount :: forall a. AdjacencyMap a -> Int
vertexCount = coerce :: forall a b. Coercible a b => a -> b
coerce forall a. AdjacencyMap a -> Int
AM.vertexCount
edgeCount :: AdjacencyMap a -> Int
edgeCount :: forall a. AdjacencyMap a -> Int
edgeCount = coerce :: forall a b. Coercible a b => a -> b
coerce forall a. AdjacencyMap a -> Int
AM.edgeCount
vertexList1 :: AdjacencyMap a -> NonEmpty a
vertexList1 :: forall a. AdjacencyMap a -> NonEmpty a
vertexList1 = forall a. [a] -> NonEmpty a
unsafeNonEmpty forall b c a. (b -> c) -> (a -> b) -> a -> c
. coerce :: forall a b. Coercible a b => a -> b
coerce forall a. AdjacencyMap a -> [a]
AM.vertexList
edgeList :: AdjacencyMap a -> [(a, a)]
edgeList :: forall a. AdjacencyMap a -> [(a, a)]
edgeList = coerce :: forall a b. Coercible a b => a -> b
coerce forall a. AdjacencyMap a -> [(a, a)]
AM.edgeList
vertexSet :: AdjacencyMap a -> Set a
vertexSet :: forall a. AdjacencyMap a -> Set a
vertexSet = coerce :: forall a b. Coercible a b => a -> b
coerce forall a. AdjacencyMap a -> Set a
AM.vertexSet
edgeSet :: Ord a => AdjacencyMap a -> Set (a, a)
edgeSet :: forall a. Ord a => AdjacencyMap a -> Set (a, a)
edgeSet = coerce :: forall a b. Coercible a b => a -> b
coerce forall a. Eq a => AdjacencyMap a -> Set (a, a)
AM.edgeSet
preSet :: Ord a => a -> AdjacencyMap a -> Set.Set a
preSet :: forall a. Ord a => a -> AdjacencyMap a -> Set a
preSet = coerce :: forall a b. Coercible a b => a -> b
coerce forall a. Ord a => a -> AdjacencyMap a -> Set a
AM.preSet
postSet :: Ord a => a -> AdjacencyMap a -> Set a
postSet :: forall a. Ord a => a -> AdjacencyMap a -> Set a
postSet = coerce :: forall a b. Coercible a b => a -> b
coerce forall a. Ord a => a -> AdjacencyMap a -> Set a
AM.postSet
path1 :: Ord a => NonEmpty a -> AdjacencyMap a
path1 :: forall a. Ord a => NonEmpty a -> AdjacencyMap a
path1 = coerce :: forall a b. Coercible a b => a -> b
coerce forall a. Ord a => [a] -> AdjacencyMap a
AM.path forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. NonEmpty a -> [a]
toList
circuit1 :: Ord a => NonEmpty a -> AdjacencyMap a
circuit1 :: forall a. Ord a => NonEmpty a -> AdjacencyMap a
circuit1 = coerce :: forall a b. Coercible a b => a -> b
coerce forall a. Ord a => [a] -> AdjacencyMap a
AM.circuit forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. NonEmpty a -> [a]
toList
clique1 :: Ord a => NonEmpty a -> AdjacencyMap a
clique1 :: forall a. Ord a => NonEmpty a -> AdjacencyMap a
clique1 = coerce :: forall a b. Coercible a b => a -> b
coerce forall a. Ord a => [a] -> AdjacencyMap a
AM.clique forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. NonEmpty a -> [a]
toList
{-# NOINLINE [1] clique1 #-}
biclique1 :: Ord a => NonEmpty a -> NonEmpty a -> AdjacencyMap a
biclique1 :: forall a. Ord a => NonEmpty a -> NonEmpty a -> AdjacencyMap a
biclique1 NonEmpty a
xs NonEmpty a
ys = coerce :: forall a b. Coercible a b => a -> b
coerce forall a. Ord a => [a] -> [a] -> AdjacencyMap a
AM.biclique (forall a. NonEmpty a -> [a]
toList NonEmpty a
xs) (forall a. NonEmpty a -> [a]
toList NonEmpty a
ys)
star :: Ord a => a -> [a] -> AdjacencyMap a
star :: forall a. Ord a => a -> [a] -> AdjacencyMap a
star = coerce :: forall a b. Coercible a b => a -> b
coerce forall a. Ord a => a -> [a] -> AdjacencyMap a
AM.star
{-# INLINE star #-}
stars1 :: Ord a => NonEmpty (a, [a]) -> AdjacencyMap a
stars1 :: forall a. Ord a => NonEmpty (a, [a]) -> AdjacencyMap a
stars1 = coerce :: forall a b. Coercible a b => a -> b
coerce forall a. Ord a => [(a, [a])] -> AdjacencyMap a
AM.stars forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. NonEmpty a -> [a]
toList
tree :: Ord a => Tree a -> AdjacencyMap a
tree :: forall a. Ord a => Tree a -> AdjacencyMap a
tree = coerce :: forall a b. Coercible a b => a -> b
coerce forall a. Ord a => Tree a -> AdjacencyMap a
AM.tree
removeVertex1 :: Ord a => a -> AdjacencyMap a -> Maybe (AdjacencyMap a)
removeVertex1 :: forall a. Ord a => a -> AdjacencyMap a -> Maybe (AdjacencyMap a)
removeVertex1 = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a. AdjacencyMap a -> Maybe (AdjacencyMap a)
toNonEmpty forall b c a. (b -> c) -> (a -> b) -> a -> c
. coerce :: forall a b. Coercible a b => a -> b
coerce forall a. Ord a => a -> AdjacencyMap a -> AdjacencyMap a
AM.removeVertex
removeEdge :: Ord a => a -> a -> AdjacencyMap a -> AdjacencyMap a
removeEdge :: forall a. Ord a => a -> a -> AdjacencyMap a -> AdjacencyMap a
removeEdge = coerce :: forall a b. Coercible a b => a -> b
coerce forall a. Ord a => a -> a -> AdjacencyMap a -> AdjacencyMap a
AM.removeEdge
replaceVertex :: Ord a => a -> a -> AdjacencyMap a -> AdjacencyMap a
replaceVertex :: forall a. Ord a => a -> a -> AdjacencyMap a -> AdjacencyMap a
replaceVertex = coerce :: forall a b. Coercible a b => a -> b
coerce forall a. Ord a => a -> a -> AdjacencyMap a -> AdjacencyMap a
AM.replaceVertex
mergeVertices :: Ord a => (a -> Bool) -> a -> AdjacencyMap a -> AdjacencyMap a
mergeVertices :: forall a.
Ord a =>
(a -> Bool) -> a -> AdjacencyMap a -> AdjacencyMap a
mergeVertices = coerce :: forall a b. Coercible a b => a -> b
coerce forall a.
Ord a =>
(a -> Bool) -> a -> AdjacencyMap a -> AdjacencyMap a
AM.mergeVertices
transpose :: Ord a => AdjacencyMap a -> AdjacencyMap a
transpose :: forall a. Ord a => AdjacencyMap a -> AdjacencyMap a
transpose = coerce :: forall a b. Coercible a b => a -> b
coerce forall a. Ord a => AdjacencyMap a -> AdjacencyMap a
AM.transpose
{-# NOINLINE [1] transpose #-}
{-# RULES
"transpose/vertex" forall x. transpose (vertex x) = vertex x
"transpose/overlay" forall g1 g2. transpose (overlay g1 g2) = overlay (transpose g1) (transpose g2)
"transpose/connect" forall g1 g2. transpose (connect g1 g2) = connect (transpose g2) (transpose g1)
"transpose/overlays1" forall xs. transpose (overlays1 xs) = overlays1 (fmap transpose xs)
"transpose/connects1" forall xs. transpose (connects1 xs) = connects1 (reverse (fmap transpose xs))
"transpose/vertices1" forall xs. transpose (vertices1 xs) = vertices1 xs
"transpose/clique1" forall xs. transpose (clique1 xs) = clique1 (reverse xs)
#-}
gmap :: (Ord a, Ord b) => (a -> b) -> AdjacencyMap a -> AdjacencyMap b
gmap :: forall a b.
(Ord a, Ord b) =>
(a -> b) -> AdjacencyMap a -> AdjacencyMap b
gmap = coerce :: forall a b. Coercible a b => a -> b
coerce forall a b.
(Ord a, Ord b) =>
(a -> b) -> AdjacencyMap a -> AdjacencyMap b
AM.gmap
induce1 :: (a -> Bool) -> AdjacencyMap a -> Maybe (AdjacencyMap a)
induce1 :: forall a. (a -> Bool) -> AdjacencyMap a -> Maybe (AdjacencyMap a)
induce1 = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a. AdjacencyMap a -> Maybe (AdjacencyMap a)
toNonEmpty forall b c a. (b -> c) -> (a -> b) -> a -> c
. coerce :: forall a b. Coercible a b => a -> b
coerce forall a. (a -> Bool) -> AdjacencyMap a -> AdjacencyMap a
AM.induce
induceJust1 :: Ord a => AdjacencyMap (Maybe a) -> Maybe (AdjacencyMap a)
induceJust1 :: forall a. Ord a => AdjacencyMap (Maybe a) -> Maybe (AdjacencyMap a)
induceJust1 = forall a. AdjacencyMap a -> Maybe (AdjacencyMap a)
toNonEmpty forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Ord a => AdjacencyMap (Maybe a) -> AdjacencyMap a
AM.induceJust forall b c a. (b -> c) -> (a -> b) -> a -> c
. coerce :: forall a b. Coercible a b => a -> b
coerce
closure :: Ord a => AdjacencyMap a -> AdjacencyMap a
closure :: forall a. Ord a => AdjacencyMap a -> AdjacencyMap a
closure = coerce :: forall a b. Coercible a b => a -> b
coerce forall a. Ord a => AdjacencyMap a -> AdjacencyMap a
AM.closure
reflexiveClosure :: Ord a => AdjacencyMap a -> AdjacencyMap a
reflexiveClosure :: forall a. Ord a => AdjacencyMap a -> AdjacencyMap a
reflexiveClosure = coerce :: forall a b. Coercible a b => a -> b
coerce forall a. Ord a => AdjacencyMap a -> AdjacencyMap a
AM.reflexiveClosure
symmetricClosure :: Ord a => AdjacencyMap a -> AdjacencyMap a
symmetricClosure :: forall a. Ord a => AdjacencyMap a -> AdjacencyMap a
symmetricClosure = coerce :: forall a b. Coercible a b => a -> b
coerce forall a. Ord a => AdjacencyMap a -> AdjacencyMap a
AM.symmetricClosure
transitiveClosure :: Ord a => AdjacencyMap a -> AdjacencyMap a
transitiveClosure :: forall a. Ord a => AdjacencyMap a -> AdjacencyMap a
transitiveClosure = coerce :: forall a b. Coercible a b => a -> b
coerce forall a. Ord a => AdjacencyMap a -> AdjacencyMap a
AM.transitiveClosure
consistent :: Ord a => AdjacencyMap a -> Bool
consistent :: forall a. Ord a => AdjacencyMap a -> Bool
consistent (NAM AdjacencyMap a
x) = forall a. Ord a => AdjacencyMap a -> Bool
AM.consistent AdjacencyMap a
x Bool -> Bool -> Bool
&& Bool -> Bool
not (forall a. AdjacencyMap a -> Bool
AM.isEmpty AdjacencyMap a
x)