WOLFRAM NOTEBOOK

Rule Signatures

A rule signature can be specified as:
{{{multiplicity,arity},{multiplicity,arity},...}{...},...}

RuleSignatureForm

In[]:=
RuleSignatureForm[s:({{_Integer,_Integer}...}->{{_Integer,_Integer}...})]:=RSF0/@s
In[]:=
RuleSignatureForm[s_List]:=RuleSignatureForm/@s
Note reverse sorting by arity:
In[]:=
RSF0[s:{{_Integer,_Integer}...}]:=Row[Subscript[#1,#2]&@@@ReverseSortBy[s,Last]]
In[]:=
RuleSignatureForm[{{1,3}}{{4,3}}]
Out[]=
1
3
4
3
In[]:=
RuleSignatureForm[{{1,3},{2,2}}{{4,3},{5,2}}]
Out[]=
1
3
2
2
4
3
5
2
Also to be specified is the number of symbols, all of which are interchangeable.

Functions Needs\bed

RuleSignatureCount

Count the total number of distinct rules with a given signature

RuleSignatureEnumerate

Enumerate distinct rules with a given signature

RuleSignatureRandom

Generate a random rule with a given signature

AllRuleSignatures

A list of the first n possible signatures in some reasonable enumeration order

2ary Edge Enumeration [ old code ]

(Using a different notation for the signature)
In[]:=
RuleShapeToCases[lr:{_,_},s_Integer]:=Union[mincase[#,s]&/@rcases[lr,s]]
In[]:=
RuleShapeListToCases[llr_List,s_Integer]:=DeleteDuplicates[Map[Sort,Flatten[Apply[Outer[List,##,2]&,RuleShapeToCases[#,s]&/@llr],1],{2}]]
In[]:=
rcases[lr:{_,_},s_Integer]:=Apply[Rule,(Partition[#,2]&/@TakeList[#,2lr])&/@Tuples[Range[s],2Total[lr]],{1}]
Find the minimal representative based on relabeling symbols and permuting edges:
In[]:=
mincase[rule_,s_Integer]:=First[Sort[Map[Sort,(rule/.#)&/@(Thread[Range[s]#]&/@Permutations[Range[s]]),{2}]]]
This corresponds to signature:
In[]:=
{{1,2}}{{2,2}}//RuleSignatureForm
Out[]=
1
2
2
2
In[]:=
Union[RuleShapeListToCases[{{1,2}},2]]
Out[]=

Results

Counts for 2 symbols: [ should be confirmed ]
In[]:=
Grid[Table[{RuleSignatureForm[{{i,2}}{{j,2}}],Length[Union[RuleShapeListToCases[{{i,j}},2]]]},{j,4},{i,4}],FrameAll]
Out[]=

The Enumeration Setup

A typical instance of
2
2
3
2
might be:
{{1,1},{2,1}}{{2,1},{2,2},{2,2}}
The ordering inside the outer list doesn’t matter.
The ordering within each sublist does matter.
The names of the symbols don’t matter.
Formulas for the total counts would be nice, but are not essential.
Wolfram Cloud

You are using a browser not supported by the Wolfram Cloud

Supported browsers include recent versions of Chrome, Edge, Firefox and Safari.


I understand and wish to continue anyway »

You are using a browser not supported by the Wolfram Cloud. Supported browsers include recent versions of Chrome, Edge, Firefox and Safari.