Copyright | Copyright (C) 2021 Yoo Chung |
---|---|

License | GPL-3.0-or-later |

Maintainer | dev@chungyc.org |

Safe Haskell | Safe-Inferred |

Language | GHC2021 |

Part of Ninety-Nine Haskell Problems. Some solutions are in Solutions.P83.

# Documentation

spanningTrees :: G -> [G] Source #

Mathematically, a tree is a graph with exactly one path between any two vertexes. A spanning tree of a graph is a tree which includes all vertexes of the graph.

Write a function to construct all spanning trees of a given graph.

You can use `graph83`

as an example graph to construct spanning trees from.

### Examples

`>>>`

173`length $ spanningTrees graph83`

`>>>`

True`toG (Paths [[1,2,4,5,6,7,8],[1,3],[5,10],[7,9]]) `elem` spanningTrees graph83`

Write a function which returns whether a graph is a tree using `spanningTrees`

.

### Examples

`>>>`

False`isTree graph83`

`>>>`

True`isTree $ toG $ Paths [[1,2,3],[1,4,5]]`

isConnected :: G -> Bool Source #

Write a function which returns whether a graph is connected using `spanningTrees`

.

### Examples

`>>>`

True`isConnected graph83`

`>>>`

False`isConnected $ toG $ Lists ([1,2,3], [])`

Graph for use as an example for `spanningTrees`

.