Starting from the list:
{f[q1, q2], f[q3, q4], g[q1], g[q2, q3, q4], d[k1 - q1], d[k2 - q2 - q3 -q4]}
I would like to get the result:
{f[q1, q2] -> g[q1], f[q1, q2] -> g[q2, q3, q4], f[q3, q4] -> g[q2, q3, q4], f[q3, q4] -> g[q2, q3, q4], g[q1] -> k1, g[q2, q3, q4] -> k2}
by applying following two rules: first for all $q_i$ variables match $f[]$ to $g[]$ that contain the same $q_i$. If $f[]$ and $g[]$ contain more then one $q_i$ that is the same, then repeat the rule for each of such $q_i$, as in case of
f[q3, q4] -> g[q2, q3, q4]
Second rule should mach $g[]$ to a given $k_i$ that are again related by the corresponding $q_j$ in $d[]$ element. In case of multiple $q_j$ relating $g[]$ to a given $k_i$ only one rule will suffice, as in case of
g[q2, q3, q4] -> k2
How do I make a function that would produce such a list of rules for a given input list?
Note: Element $d[...]$ in the input list can be thought of as a delta function setting the external momenta.
Eventually I want to use the obtained rules to make a GraphPlot
that corresponds to the Feynman diagram. Repeated rules then correspond to loops in a diagram.