Does an algorithm exist that transforms any connected graph, cyclic or not, into tree form?
In a general graph, the number of edges can go up to $\mathcal{O}(n^2)$ (where n is the number of verticies). But in a tree, that number is always $n-1$.

Then, we understand that its impossible to convert a graph to a tree preserving syntax without increasing the memory for each node by a linear factor, or increasing the number of nodes significantly.

Let us define a unique number for every node (in any way you like).

The algorithm now will be:


Let $\mathcal{T}$ be the tree from the BFS algorithm on the graph (starting from node 1, for uniqueness)
For every edge $e=(i,j)$ in the graph, that is not in $\mathcal{T}$ already, w.l.o.g assume $i\le j$, and add a new node with value $j$ to $\mathcal{T}$, and a connection between it and the (original) node $i$ in the tree.


Note that in the new tree, there will be a lot of nodes that have the same number.

To reconstruct the original graph, we will do the following:


Create a node for every unique number in $\mathcal{T}$.
Add an edge $(i,j)$ if there is a node with number $i$ that has an edge to some node with value $j$