isomorphism checking in groove
DESCRIPTION
Isomorphism Checking in GROOVE. Arend Rensink, University of Twente. Basics. Universe of labels Lab Graphs: tuples G = Finite set of nodes N Finite set of edges E Source and target mappings src,tgt: E N Edge labelling lab: E Lab - PowerPoint PPT PresentationTRANSCRIPT
GRABATS 2006, Natal, Brazil Isomorphism Checking in GROOVE 1
Isomorphism Checking in GROOVE
Arend Rensink, University of Twente
GRABATS 2006, Natal, Brazil Isomorphism Checking in GROOVE 2
Basics
• Universe of labels Lab• Graphs: tuples G = <N,E,src,tgt,lab>– Finite set of nodes N– Finite set of edges E– Source and target mappings src,tgt: E N– Edge labelling lab: E Lab
• Isomorphism between G and H (G H):– Mapping f: G H– Bijective node and edge components fN, fE – Structure-preserving: fNsrcG = srcHfE etc– G and H are “essentially the same”
GRABATS 2006, Natal, Brazil Isomorphism Checking in GROOVE 3
Examples
• Which of these graphs are isomorphic?– 1 3; all others are distinct
• Which of these graphs are bisimilar?(roughly: can mutually simulate one another)– 1 3 5; all others are distinct
• Which have non-trivial symmetries?– 1, 3, 4 and 5
a
a
bb
a
a
bb
a
a
bb
a
a
bb
a
ab
b
1 2 3 4 5
GRABATS 2006, Natal, Brazil Isomorphism Checking in GROOVE 4
Complexity
• Traditional isomorphism question– For given graphs G and H, is G H?– In NP; unknown to be either in P or NP-hard– Essential concept: graph certificate– Existing algorithms use partition refinement
• Extended isomorphism question– For given graph G and set of graphs S,
find H S such that G H, if it exists– More general: above case given by S = {H}– Graph certificates also help in this problem
GRABATS 2006, Natal, Brazil Isomorphism Checking in GROOVE 5
Graph certificates (1)
• Graph cerficate mapping– Universe Cert of certificates; e.g., Nat– Mapping c: Graph Cert– Invariance: G H implies c(G) = c(H)– Example: c: G |EG|
• Use 1: conservative approximation of iso– c(G) c(H) implies (G H)
• Use 2: hash value in set of graphs S
a
a
bb
a
a
bb
a
a
bb
a
a
bb
a
ab
bc=4 c=4 c=4 c=4 c=4
GRABATS 2006, Natal, Brazil Isomorphism Checking in GROOVE 6
a
a
bb
a
a
bb
a
a
bb
a
a
bb
a
ab
b
Graph certificates (2)
• Refinement: element certificate mapping– Mappings cN: Graph Node Cert
cE: Graph Edge Cert– Invariance: isomorphism f: G H implies
cN(G) = cN(H) fN and cE(G) = cE(H) fE
– Example: cN(G): n |tgtG-1(n)|,
cE(G): e hash(labG(e))1
1
22
1 1
11
1
1
222 0
20
1
1
22
1 1
11
1
1
22
1 1
02
1
12
2
1 1
11
hash: a 1, b 2
GRABATS 2006, Natal, Brazil Isomorphism Checking in GROOVE 7
Graph Certificates (3)
• Use 1: Predict isomorphism– f: G H implies fN cN
-1(H) cN(G) fE cE
-1(H) cE(G)
• Use 2: Define graph certificate mapping– c1(G) = nN cV(G,n) + eE cE(G,e)
– c2(G) = <{cV(G,n)|n N},{cE(G,e)|e E}>1
1
22
1 1
11
1
1
222 0
20
1
1
22
1 1
11
1
1
22
1 1
02
1
12
2
1 1
11
<{1},{1,2}>c1=12 c1=12 c1=12 c1=12<{0,1,2},{1,2}><{1},{1,2}><{0,2},{1,2}><{1},{1,2}>c1=12
GRABATS 2006, Natal, Brazil Isomorphism Checking in GROOVE 8
Inspiration: bisimilarity
• Relation G over nodes + edges– Largest symmetrical relation such that
• src(e1) n2 implies e1 e2 for some e2
with src(e2)=n2 and lab(e2)=lab(e1) • vice versa for target nodes
– Weaker than isomorphism: • f: G H an iso implies n GH fN(n) and e GH fE(e)
a
a
bb
a
ab
b
Bisimilar graphs• Equally coloured nodes • Equally labelled edges
GRABATS 2006, Natal, Brazil Isomorphism Checking in GROOVE 9
Bisimilarity co-inductively
• Algorithm: G = i i given– Sequence of relations with i+1 i
• 0 = (NGNG) { (e1,e2) EGEG | lab(e1)=lab(e2) }• e1 i+1 e2 if src(e1) i src(e2) and tgt(e1) i tgt(e2)• n1 i+1 n2 if i+1 is a total relation between src-1(n1)
and src-1(n2) as well as between tgt-1(n1) and tgt-1(n2)– Sequence converges for finite graphs– Average complexity: |G| log |G|
a
a
bb
a
ab
b
First iteration:• All nodes, equally labelled edgesSecond iteration:• Equally coloured nodes• Equally labelled edgesThird iteration: convergence
GRABATS 2006, Natal, Brazil Isomorphism Checking in GROOVE 10
The algorithm (1)
• Iterated construction of certificates– Inspired by bisimilarity characterisation
• Sequence of mappings (cNi,cE
i)i– Starting point: simple case like before– Next steps: use end nodes/incident edges– n i n2 implies cN
i(n1)=cNi(n2), also for edges
– Not vice versa: certificates not precise• Convergence: use partition size |N/i|– Partition size may grow due to imprecision– Stop when |N/i| |N/i-1|
• Derived graph certificate as hash key
GRABATS 2006, Natal, Brazil Isomorphism Checking in GROOVE 11
The algorithm (2)
• Recall “extended isomorphism question”– For given graph G and set of graphs S,
find H S such that G H, if it exists
• If c(G) is fresh, no such H exists• If c(H) = c(G), test for G H– Test for equality (equal node and edge sets)– If cN
i is injective (|N/i|=|N|),G H iff { (n,cN
i(n)) | nNG } yields an iso – Otherwise, more complex extended iso test– If G H, it is a false positive: add G to S
GRABATS 2006, Natal, Brazil Isomorphism Checking in GROOVE 12
Definition of element certificates• Node mapping: cN
i(n) = – 1 if i = 0– cN
i-1(v) + 2 n=src(e) ciE(e) + n=tgt(e) ci
E(e)
• Edge mapping: cEi(e) =
– hash(lab(e)) if i = 0– newCert(cE
i-1(e),lab(e),cNi(src(e)),cN
i(tgt(e)))
• newCert determines “quality”:– Should reduce imprecision/confusion– Should be “maximally injective”
• Derived graph certificate– c(G) = nN cV
i(n) + eE cEi(e)
GRABATS 2006, Natal, Brazil Isomorphism Checking in GROOVE 13
Example
newCert(old,lab,src,tgt) := old + 2 src + tgt
a
a
bb
a
a
bb
a
a
bb
a
a
bb
a
ab
b
1
1
22
1 1
11
1
1
221 1
11
1
1
22
1 1
11
1
1
22
1 1
11
1
12
2
1 1
11
17
17
1818
5 6
56
190
190
193193
57 59
5759
17
17
1818
5 6
65
190
190
193193
57 59
5957
|N/| = 1
17
19
1821
5 6
47
19
19
2020
7 4
74
232
232
23323385 43
8543
17
1718
18
5 6
65
190
190193
193
57 59
5759
|N/| = 1 |N/| = 1 |N/| = 1 |N/| = 1|N/| = 2 |N/| = 2c = 998
|N/| = 2 |N/| = 2c = 998
|N/| = 2 |N/| = 2c = 1186
|N/| = 2 |N/| = 2c = 998
|N/| = 4c = 97
GRABATS 2006, Natal, Brazil Isomorphism Checking in GROOVE 14
Implementation
int[] tmp = new int[vSize]; // temporary node certificatesint partSize = 1, oldPartSize; // partition size// initialise the certificatesfor (int e = 0; e < eSize; e++) eCert[e] = hash(lab[e]);for (int v = 0; v < vSize; v++) vCert[v] = 1;do { // calculate the new edge certificates
for (int e = 0; e < eSize; e++) {eCert[e] = newCert(eCert[e], lab[e], vCert[src[e]], vCert[tgt[e]]);// propagate to the endpointstmp[src[e]] += eCert[e]; tmp[tgt[e]] += 2*eCert[e];
}// calculate new node certificates and determine partition sizeIntSet certSet = new IntSet();oldPartSize = partSize; for (int v = 0; v < vSize; v++) {
// copy the temporary node certificates to the real onesvCert[v] = tmp[v]; tmp[v] = 0;certSet.add(vCert[v]);
}partSize = certSet.size();
} while (partSize > oldPartSize); // continue while the number of cells still grows
new edge certification function
special set to count ints
GRABATS 2006, Natal, Brazil Isomorphism Checking in GROOVE 15
Example (2)
1. S0 = empty: c1 = 998 not in c(S0), 1 is fresh
2. S1 = {1}: c2=97 not in c(S1), 2 is fresh
3. S2 = {1,2}: c3 = 998 = c1 in c(s2), |N/| |N|;3 1 after extended iso test, 3 not fresh
4. S3 = {1,2}: c4 = 1186 not in c(S3), 4 is fresh
5. S4 = {1,2,4}: c5 = 998 = c1 in c(s4), |N/| |N|; (5 1) after extended iso test, 5 is fresh
190
190
193193
57 59
5759
190
190
193193
57 59
5957
17
19
1821
5 6
47
232
232
23323385 43
8543
190
190193
193
57 59
5759
c1 = 998 c3 = 998 c4 = 1186 c5 = 998 c2 = 97
1 32 4 5
GRABATS 2006, Natal, Brazil Isomorphism Checking in GROOVE 16
Experiments
• Mutex algorithm [Heckel]– Small states (graphs up to 6 nodes)– “Unpredictable” symmetries
• Dining philosophers– n-fold symmetry; here n = 12– No node creation/deletion
• Concurrent append– Symmetry mainly due to confluence– List length 8, 4 concurrent methods
• Gossiping girls– Huge amount of symmetry; here for 8 girls– No node creation/deletion
GRABATS 2006, Natal, Brazil Isomorphism Checking in GROOVE 17
Results
GRABATS 2006, Natal, Brazil Isomorphism Checking in GROOVE 18
Conclusion
• Experience: performance acceptable– Large fraction of total exploration time– Pays off for problems with many symmetries– Certificates are very good predictor for iso
• Related work: McKay (Nauty)– Based on the same principles– Idea: in case of non-injective element certificates,
break symmetry and observe effects– Not straightforward to reuse
• Future work: avoid the iso check!– Take confluence into account– Optionally switch off isomorphism checking