terms = List @@ myEq[x1, x2, x3, x4]; groups = KeySort @ GroupBy[terms, Variables[Level[#, {-1}]] &, Total] > <|{} -> 5, > {x1} -> Cos[x1] + Sin[x1/2], > {x2} -> Tan[x2], > {x3} -> -Cos[x3], > {x1, x2} -> Cot[x1 x2], > {x1, x3} -> -Tan[x1/x3], > {x2, x4} -> -Tan[x2 - x4], > {x1, x2, x3} -> Sin[x1 x2 x3], > {x2, x3, x4} -> Sin[x2 + x3/x4], > {x1, x2, x3, x4} -> Cot[x1 + x2 + x3 + x4] - Sin[x1 - x2 - x3/x4]|> Graph[Join[Keys @ groups, Values @ groups], KeyValueMap[DirectedEdge] @ groups, ImageSize -> Large, VertexCoordinates -> Join @@ (Thread[{#, Rescale @ Range @ Length @ Keys @ groups}]& /@ {1, 2}), VertexLabels -> {v_ :> Placed["Name", If[MemberQ[Keys @ groups, v], Before, After]]}] [![enter image description here][1]][1] [1]: https://i.sstatic.net/7GX0P.png [2]: https://i.sstatic.net/69rnI.png