1 等价类的定义
2 Examples
3 Partitions
4 C#源代码
using System;
namespace Legalsoft.Truffer
{
/// <summary>
/// Find equivalence classes
/// </summary>
public class EClass
{
public EClass()
{
}
public static void eclass(int[] nf, int[] lista, int[] listb)
{
int n = nf.Length;
int m = lista.Length;
for (int k = 0; k < n; k++)
{
nf[k] = k;
}
for (int l = 0; l < m; l++)
{
int j = lista[l];
while (nf[j] != j)
{
j = nf[j];
}
int k = listb[l];
while (nf[k] != k)
{
k = nf[k];
}
if (j != k)
{
nf[j] = k;
}
}
for (int j = 0; j < n; j++)
{
while (nf[j] != nf[nf[j]])
{
nf[j] = nf[nf[j]];
}
}
}
public static void eclazz(int[] nf, EquivalenceInf eq)
{
int n = nf.Length;
nf[0] = 0;
for (int jj = 1; jj < n; jj++)
{
nf[jj] = jj;
for (int kk = 0; kk < jj; kk++)
{
nf[kk] = nf[nf[kk]];
if (eq.equiv(jj + 1, kk + 1))
{
nf[nf[nf[kk]]] = jj;
}
}
}
for (int jj = 0; jj < n; jj++)
{
nf[jj] = nf[nf[jj]];
}
}
}
}