According to Wikipedia, tree and forest definitions are as follows:
Tree: Connected, non-closed, undirected graph
Forest: Undirected Graph with No Closed Paths
The special shape of the forest is trees, so all trees are forests.A complete binary tree is of course a forest.
Here are a few examples: x is a clause and - and | is a branch.
x --- x
|
x--- x--- x
|
x--- x
This is a tree and also a forest.
x --- x
| |
x--- x--- x
|
x--- x
This is not a tree or a forest because it has a closed path.
x --- x x
| |
x---x---x---x---x
|
x--- x
This is not a tree but a forest because it is not concatenated.
(If you look at the two connected graphs individually, they are Tree/Forest)
x --- x x
| | |
x---x---x---x---x
|
x--- x
This is not a tree or a forest because it has closed paths and is not connected.
(If you look at the graph on the right, it's Tree/Forest)
x --- x x
| |
x---x---x---x---x----x
|
x--- x
This is a tree and also a forest.
© 2024 OneMinuteCode. All rights reserved.