I have a list (of lists) and like to identify elements that have the same "structure"! Here is a minimal example:
example = { {{m1,m2},{m2,m4}} , {{m1,m2},{m1,m4}} }
This list has two elements {{m1,m2},{m2,m4}}
and {{m1,m2},{m1,m4}}
(which both are lists again). Now, in the problem I am working on each element is associated to a product of Kronecker deltas according to
{{m1,m2},{m2,m4}}
-> delta(m1,m2) delta(m2,m4)
with delta(i,j) the Kronecker delta. In that sense, {{m1,m2},{m2,m4}}
and {{m1,m2},{m1,m4}}
are mathematically identical (have the "same structure").
Question: How can I write a Mathematica code that identifies these elements as the same and returns me a new list, where each element with the same structure appears only once together with its "multiplicity" in the original list?
My (failed) solution: I thought I could work with graphs and associate graphs G1
and G2
to {{m1,m2},{m2,m4}}
and {{m1,m2},{m1,m4}}
, respectively, with corresponding edges as indicated by the pairs. Then, G1
and G2
literally look the same, yet when I try
`Tally[{G1,G2}]'
I do not get {G1,2}
, but {{G1,1},{G2,1}}
. So somehow Mathematica is unable to identify graphs with the "same structure" as the same.
How can I solve the problem? Any hint is greatly appreciated! Many thanks!