  Given a set $F$ of words, one associates to each word $w$ in $F$ an
undirected graph, called its extension graph, and which describes the possible
extensions of $w$ on the left and on the right. We investigate the family of
sets of words defined by the property of the extension graph of each word in
the set to be acyclic or connected or a tree. We prove that in a uniformly
recurrent tree set, the sets of first return words are bases of the free group
on the alphabet. Concerning acyclic sets, we prove as a main result that a set
$F$ is acyclic if and only if any bifix code included in $F$ is a basis of the
subgroup that it generates.
