| Copyright | Copyright (C) 2021 Yoo Chung |
|---|---|
| License | GPL-3.0-or-later |
| Maintainer | dev@chungyc.org |
| Safe Haskell | Safe-Inferred |
| Language | GHC2021 |
Problems.P83
Description
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
>>>length $ spanningTrees graph83173
>>>toG (Paths [[1,2,4,5,6,7,8],[1,3],[5,10],[7,9]]) `elem` spanningTrees graph83True
Write a function which returns whether a graph is a tree using spanningTrees.
Examples
>>>isTree graph83False
>>>isTree $ toG $ Paths [[1,2,3],[1,4,5]]True
isConnected :: G -> Bool Source #
Write a function which returns whether a graph is connected using spanningTrees.
Examples
>>>isConnected graph83True
>>>isConnected $ toG $ Lists ([1,2,3], [])False
Graph for use as an example for spanningTrees.