7. Tree and Forest

Introduction

A tree is a special type of undirected graph that is connected and acyclic, meaning it has no cycles or loops.

A forest is a collection of trees, i.e. a graph that is acyclic but not necessarily connected.

Note that a tree is still a forest, but a forest is not necessarily a tree.

Exercise

  1. 1.

    Try to edit the graph so that it is a tree

  2. 2.

    Try to make it a forest with 3 trees

  3. 3.

    Try to make a cycle in the graph, is the graph still a forest?

  • has Cycle: false
  • is Tree: false
  • is Forest: true (4 trees)