When should we construct trees, graphs to analyse an algorithm?
There's no hard-and-fast rule.  Use them if they are useful; don't if they are not.  As a broad guideline:

Graphs are often useful when you have relationships between a pair of items.

Trees are often useful when you have a hierarchical relationship.