180 likes | 323 Views
Isomorphism Checking in GROOVE. Arend Rensink, University of Twente. 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
E N D
Isomorphism Checking in GROOVE Arend Rensink, University of Twente Isomorphism Checking in GROOVE
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” Isomorphism Checking in GROOVE
a a a a a b b b b b b b b b a a a a a b Examples • Which of these graphs are isomorphic? • 13; all others are distinct • Which of these graphs are bisimilar?(roughly: can mutually simulate one another) • 135; all others are distinct • Which have non-trivial symmetries? • 1, 3, 4 and 5 1 2 3 4 5 Isomorphism Checking in GROOVE
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 Isomorphism Checking in GROOVE
a a a a a b b b b b b b b b a a a a a b 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 c=4 c=4 c=4 c=4 c=4 Isomorphism Checking in GROOVE
a a a a a b b b b b b b b b a a a a a b 1 1 1 1 1 1 1 1 1 1 1 2 0 1 1 2 2 2 2 2 2 2 2 2 1 1 1 1 1 2 0 1 1 0 2 1 1 1 1 2 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)) hash: a 1, b 2 Isomorphism Checking in GROOVE
1 1 1 1 1 1 1 1 1 1 1 2 0 1 1 2 2 2 2 2 2 2 2 2 1 1 1 1 1 2 0 1 1 0 2 1 1 1 1 2 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}> c1=12 c1=12 c1=12 <{1},{1,2}> c1=12 <{0,1,2},{1,2}> c1=12 <{1},{1,2}> <{0,2},{1,2}> <{1},{1,2}> Isomorphism Checking in GROOVE
a a b b b a a b Inspiration: bisimilarity • Relation G over nodes + edges • Largest symmetrical relation such that • src(e1) n2 implies e1 e2 for some e2with 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) Bisimilar graphs • Equally coloured nodes • Equally labelled edges Isomorphism Checking in GROOVE
a a b b b a a b Bisimilarity co-inductively • Algorithm: G = ii given • Sequence of relations with i+1i • 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+1is 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| • First iteration: • All nodes, equally labelled edges • Second iteration: • Equally coloured nodes • Equally labelled edges • Third iteration: convergence Isomorphism Checking in GROOVE
The algorithm (1) • Iterated construction of certificates • Inspired by bisimilarity characterisation • Sequence of mappings (cNi,cEi)i • Starting point: simple case like before • Next steps: use end nodes/incident edges • n i n2 implies cNi(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 Isomorphism Checking in GROOVE
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 cNi is injective (|N/i|=|N|),G H iff { (n,cNi(n)) | nNG } yields an iso • Otherwise, more complex extended iso test • If G H, it is a false positive: add G to S Isomorphism Checking in GROOVE
Definition of element certificates • Node mapping: cNi(n) = • 1 if i = 0 • cNi-1(v) + 2 n=src(e) ciE(e) + n=tgt(e) ciE(e) • Edge mapping: cEi(e) = • hash(lab(e)) if i = 0 • newCert(cEi-1(e),lab(e),cNi(src(e)),cNi(tgt(e))) • newCert determines “quality”: • Should reduce imprecision/confusion • Should be “maximally injective” • Derived graph certificate • c(G) = nN cVi(n) + eE cEi(e) Isomorphism Checking in GROOVE
a a a a a b b b b b b b b b a a a a a b 190 57 59 232 190 85 43 57 59 17 1 17 1 190 17 1 19 1 17 1 193 5 1 1 6 5 1 6 1 57 5 1 6 59 1 7 1 4 1 193 233 5 1 6 1 193 233 190 18 2 18 2 193 18 2 20 2 18 2 59 57 59 57 18 2 21 2 193 18 2 20 2 17 1 190 43 85 5 1 6 1 232 193 6 1 1 5 7 1 4 1 57 5 1 59 6 1 4 1 7 1 17 1 19 1 190 17 1 19 1 18 2 Example newCert(old,lab,src,tgt) := old + 2 src + tgt |N/| = 1 |N/| = 2c = 998 |N/| = 2 |N/| = 4c = 97 |N/| = 1 |N/| = 1 |N/| = 2 |N/| = 2c = 998 |N/| = 1 |N/| = 2 |N/| = 2c = 1186 |N/| = 2 |N/| = 1 |N/| = 2c = 998 Isomorphism Checking in GROOVE
Implementation int[] tmp = new int[vSize]; // temporary node certificates int partSize = 1, oldPartSize; // partition size // initialise the certificates for (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 endpoints tmp[src[e]] += eCert[e]; tmp[tgt[e]] += 2*eCert[e]; } // calculate new node certificates and determine partition size IntSet certSet = new IntSet(); oldPartSize = partSize; for (int v = 0; v < vSize; v++) { // copy the temporary node certificates to the real ones vCert[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 Isomorphism Checking in GROOVE
190 57 59 232 190 85 43 57 59 17 190 193 5 6 57 59 193 233 193 233 190 18 193 59 57 59 57 21 193 190 43 85 232 193 7 4 57 59 19 190 Example (2) • S0 = empty: c1 = 998 not in c(S0), 1 is fresh • S1 = {1}: c2=97 not in c(S1), 2 is fresh • S2 = {1,2}: c3 = 998 = c1 in c(s2), |N/| |N|;31 after extended iso test, 3not fresh • S3 = {1,2}: c4 = 1186 not in c(S3), 4 is fresh • S4 = {1,2,4}: c5 = 998 = c1 in c(s4), |N/| |N|; (51) after extended iso test, 5 is fresh 1 2 3 4 5 c1 = 998 c2 = 97 c3 = 998 c4 = 1186 c5 = 998 Isomorphism Checking in GROOVE
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 Isomorphism Checking in GROOVE
Results Isomorphism Checking in GROOVE
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 Isomorphism Checking in GROOVE