A basic model in the study of structural rigidity is a network of rigid bars connected at their endpoints by flexible joints; this can be represented by what is called here a frame, which is a graph G realized in Euclidean space with straight-line edges. The edges act as constraints, fixing the distances between vertices. The degrees of freedom of a frame, i.e., the dimension of the space of infinitesimal motions of its vertices, is a standard measure of its flexibility. A long-standing open problem is to find a purely combinatorial algorithm for computing the generic degrees of freedom in three dimensions, Ψ(G), a number which depends on the graph alone. This paper focuses on the special case of molecular graphs and their frames, in which an additional edge is added for each edge-pair angle (i.e., the squares of graphs); such graphs are used to model atom-bond networks with bond-angle forces, which arise in the study of glasses. The main result of this paper is a recurrence relation, which, when combined with previous work by the author, yields a practical algorithm to produce both upper and lower bounds on Ψ(G). The result is stated for molecular graphs in three dimensions, but has analogs for standard graphs in two or three dimensions. The algorithm uses a generalization of ear decomposition, here called chain decomposition. The paper gives as a corollary a simple characterization of two classes of molecular graphs for which one can compute Ψ(G) exactly. The paper also gives the following theorem: if a graph is edge two-connected and has no chordless cycle of length greater than 6, the corresponding molecular graph is rigid.