<<

arXiv:1711.08222v1 [cs.DM] 22 Nov 2017 el t 3 n h t l[]hv okdo on worked have [4] al et. them. Aho for i and known [3] important is al. different are solution et. Kelly time on types polynomial done special and been These theory graph have graphs. works of many types special problem, cas general hard a a for problem is GI While time. quasi-polynomial in complexity. time enormous this of because intractable ftegah vnfrsalrvle of values smaller for Even graph. the of h smrhs rbe rva o hscs.Tealgorith The case. this for for trivial in ma different works representation problem the is giving isomorphism for neighbours selected the was [2]. immediate node o the the list to two which invariant becomes any representation neighbourh .The neighbourhood that every of of property and a list version have graph graphs modified degree a of isomorphism a type of special finding uses These list proposed and method have degree graphs The We the graphs. these graphs. these represent of between work, type to this special method In known. a a are with classes cas polyno worked of general in type have solutions the special The to some for for [1]. unknown algorithm time time is bese quasi-polynomial case The in general time. works the polynomial for in problem be The problem. ence e fi seg rsrigbjcino o.Ovosy thi Obviously, not. or bijection preserving and nodes edge takes the is solution of each it permutation H, the if and all see making G is graphs v two vertices simplest,b with checking The for problem. approach computational inefficient interesting and old in is which problem class. is complexity subgraph of problem NP-complete of set isomorphism case Graph vertex solve. special edges. on preserves a to bijection that difficult H a and but is G of easy, It Description There isomorphism: is theory. application. Graph graph problem the other isomorphism in many graph problems in open many important are very is theory ntegah h rpsdagrtmrn atrta quasi- than study. the faster in runs used graphs algorithm the proposed for time The polynomial graph. the in a erpeetdb neg e( edge an by represented be can ieaadbcnb ersne yagahcnitn nodes consisting graph a by represented be networking can networks, social v b social a and on as a people site two such example, applications, For networking. world real complex ahter,gahioopimpolmrp hoy , raph problem g isomorphism problem isomorphism graph theory, raph a ovn smrhs rbe o Special a for Problem Isomorphism Graph Solving aa 1 a hw h eea aeagrtmt esolved be to algorithm case general the shown has [1] Babai hcigwehrtoGah r smrhco o san is not or isomorphic are Graphs two whether Checking Abstract rp sapplrdt tutr n tcnb sdi many in used be can it and structure data popular a is Graph and hrba maiIsiueo nomto n Communicati and Information of Institute Ambani Dhirubhai v b O Gahioopimi nipratcmue sci- computer important an is isomorphism —Graph o,i hyaefins hnterrelationship their then friends, are they if Now, . ( n 4 ) O ie hr stenme fvrie present vertices of number the is n where time, ( v 2 v ! ) .I I. ie where time, NTRODUCTION v a v , v stenme fvertices of number the is b ewe hm Graph them. between ) v h rbe becomes problem the ne Terms Index [email protected] aba mtPatel Amit Vaibhav drin rder king mial case ood we — ut m n e e s rp , graph smrhc sn hsbuefremto h isomorphism ar the graphs method two these brute-force function that this out Using find can isomorphic. one possibilities the all osdrFg n i.2 rt-oc ehdi otyall try f to bijection graph is preserving of edge method set the Brute-force vertex find to method. 2. and proposed Fig. possibilities the and the by 1 solved be Fig. can Consider that graphs the isomorphism define ar the graphs method two these brute-force function that this out Using find can isomorphic. one possibilities the all h osblte n ofidteeg rsrigbjcinf bijection graph preserving of edge set the vertex find to and possibilities the sequence non-isomorphic. degree be same of can with graph enough number Two not isomorphism. are nodes, the properties prove Two these of graphs. But number sequence. two the degree equal these edges, practice, of have matrices they In graphs adjacency if isomorphism. isomorphic the and the is not input give or the then isomorphic isomorphic are graphs are two these whether w graphs two ie okdoteapei logvnaogwt the with along given also polynomial is for in example algorithm graphs out the of algorithm. worked discuss type A will this time. we used for are that, that isomorphism graphs After solving the study. define will this functio we similarity in first using Zager work, problem this [12]. this In on [13]. multiplicity worked color have al. of bounded et. isomorphism with color-preserving on graphs [11] worked problem colored have GI [10]. al. k-Contractible et. on multiplicity worked Luks eigenvalue worked have have bounded al. al. with et. worked et. Miller Graphs Babai have on on L. al. worked [9]. GI et. genus on have bounded bounded Filotti al. of for [8]. graphs GI et. treewidth on solving bounded Bodlaender the of graph. on graphs done a [7]. been of graphs has permutation parameters work on of GI solve lot e to A Colbourn space algorithm [6]. log an grpahs in interval found is solvin on al. problem for worked this have algorithm fact, al. an et. In algorithm Lueker [5]. found time graphs al. planner poolynomial et. on a GI Hopcraft found case. have this they for and trees on emsil graphs: Permissible osdrFg n i.2 rt-oc ehdi otyall try to is method Brute-force 2. Fig. and 1 Fig. Consider hsi ipeeapeo Ipolm ehv given have We problem. GI of example simple a is This nTcnlg adiaa,Gjrt 807India, 382007 Gujarat, Gandhinagar, Technology on I I : : G G G 1 1 1 → → and G G G G 2 G 2 1 1 sgvni h al I. Table the in given is 2 I A II. sgvni h al .Frt ewill we First, I. Table the in given is h rbe sta ehv ofind to have we that is problem The . ovre e fgraph of set vertex to ovre e fgraph of set vertex to Let LGORITHM G ( V , E ) easml,connected simple, a be G G 2 2 fe trying After . fe trying After . rom rom ns to t. g e e . . 1 TABLE I: Isomorphism: I(G1,G2)

Vertex from graph G1 Vertex from graph G2 1 G 2 F 2 3 E 4 D 5 C 6 B 3 4 7 A TABLE II: dsv(i), for all i ∈ V of the graph G1 Vertex i degree(i) dsv(i) 6 5 1 1 {(2,3)} 2 3 {(1,1),(3,2),(4,4)} 3 2 {(2,3),(4,4)} 7 4 4 {(5,1),(3,2),(6,2),(2,3)} 5 1 {(4,4)} Fig. 1: Graph G1 6 2 {(7,1),(4,4)} A B 7 1 {(6,2)}

TABLE III: list1 of the graph G1 Vertex list list list list C D elements elements elements elements 1 2 - - - 2 1 3 4 - 3 2 4 - - 4 2 3 5 6 5 4 - - - E F 6 4 7 - - 7 6 - - -

1) Preprocessing 2) Checking the input G 3) Generate UIDs 4) Map Isomorphism Fig. 2: Graph G2 A. Preprocessing We will process on both the graphs and store the results for later use. Here deg seqi is list of degree sequences of the V : Set of vertices , |V| = n neighbours of the vertex i. This step will be performed on E : Set of edges (Ordered pair of vertices), every vertex i, i ∈ V for both the graphs. For understanding, E ⊂ (V ×V), and for a given vi ∈ V and deg seq4 is shown in the Table IV. Si = {x | (x,vi) ∈ E} , ∀v j,vk ∈ S, v j 6= vk =⇒ dsv(v j) 6= Algorithm 1 dsv(vk) . Preprocessiong Where dsv(p) is the neighbourhood degree list of a 1: deg seqi ← 0 given vertex p with the vertices. For example, dsv(4) = 2: S = {x | (x,i) ∈ E} {(5,1),(3,2),(6,2),(2,3)}. It is a list of tuples, where the first 3: for each v ∈ S do element is the vertex and second is its degree. The dsv is sorted 4: deg seqi.append(dsv(v)) by the degree (the second element). 5: end for We will solve this problem using the proposed method. The input is two graphs G1 and G2 in their adjacency lists B. Checking the input form, list1,list2 respectively. The algorithm will first check that whether these graphs follow the Definition of Permissible In this module the algorithm will check whether the given Graphs. or not. Table III shows the adjacency list, list1 of the graphs fits in the above definition or not. After getting the graph G1. This algorithm consists of 3 sub modules: deg seqi, for all the i ∈ V, the algorithm sorts the elements TABLE IV: degree sequence list, deg seq4 of the graph G1 vertices. Function generate UID is called for each vertex of vertex v dsv(v) of the neighbours v of the vertex 4 graphs G1 and G2. This function takes count and the vertex i 2 {(1,1),(3,2),(4,4)} as its input. Bool array element will change its value to one, 3 {(2,3),(4,4)} if that vertex is visited. The function will be called for every 6 {(7,1),(4,4)} vertex i with initial condition set to generate UID (n, i). Now, 5 {(4,4)} we will perform this operation on the vertex 4 of Graph G1. Algorithm 2 Whether this method is applicable or not Now, we know from Table I that vertex D from graph G2 is isomorphic to the vertex 4 from graph G1. 1: Sort the lists in deg seqi by the length of the lists and then lexicographically. D. Map Isomorphism 2: Sort dsv(i) according to the order of lists in the deg seqi. After generating UIDs from both the graph G1 and G2 the true 3: result ← algorithm will try to map the UIDs of graph G1 to UIDs of 4: for each i V do p ∈ Graph G2 and will report the isomorphism I. Here, UID j is 5: for each x,y ∈ deg seqi do UID of graph p and of jth vertex. UIDp is the list of all the 6: if x=y then UIDs of all the vertex of the graph p. The map Isomorphism 7: result ← false function will be called for UID of every vertex of the graph 8: end if G1. The iso is and array which maps vertex of one graph to 9: end for the vertex of the other graph. If for all the UIDs the value of 10: end for flag is 1 and all the iso arrays give the same result then the two graphs are isomorphic and the isomorphism function is given by iso. The algorithm uses the constraint given in the of this list. In the step 1. of the Algorithm 2, lists in the Definition of Permissible Graphs., which is why the algorithm deg seqi are sorted by lexicographically (according to the revolves around the degree sequence of the vertices. second element in the tuple) and then by the length of the list. Now, we will perform this step on Vertices of the graph 1 Algorithm 4 map Isomorphism(UIDi ) G . 1 2 2 If value of the result is true then we can apply our algorithm. 1: for each UID j ∈ UID do And it can go thorough out next stage. 2: iso ←−1 3: ind ← 0 C. Generate UIDs 4: flag ← 0 1 2 Here we will introduce an encoding technique, in which we 5: if len(UIDi )= len(UID j ) then 1 will assign different ids to all the vertices. And after that we 6: while ind < len(UIDi ) do will compare this ids in both the graphs among all the vertices. 7: ind ← ind + 1 1 These unique ids (UID) are independent of the order in which 8: if iso[UIDi [ind][0]] 6= −1 and 1 2 we calculated these UIDs. THe bool array is of size |V| and iso[UIDi [ind][0]] 6= UID j [ind][0] then 9: flag ← 0 Algorithm 3 generate UID (count, i) 10: break 11: end if 1: tmp1=dsv(i)[0] 12: if UID1[ind][1] 6= UID2[ind][1] then 2: while counter > 0 do i j 13: flag ← 0 3: tmp2=[] 14: break 4: for each x ∈ tmp1 do 15: else 5: if bool[x] = 0 then 16: iso[UID1[ind][0]] ← UID2[ind][0] 6: UID.append(dsv(x)) i j 17: flag ← 1 7: tmp2.append(dsv(x)[0]) 18: end if 8: count ← count − 1 19: end while 9: else 20: if flag=1 then 10: UID.append((x,−1)) 21: break 11: end if 22: end if 12: end for 23: end if 13: UID.append((−2,−2)) 24: end for 14: end while Any vertex of a permissible graphs can not have more than it stores whether all the vertex are included or not. The array one UID. is initialized to 0 for all the elements. The count variable is initialized with total number of vertices, |V|. It will decrement Proof. The UID consist of UIDd (degrees) and UIDn (nodes). its value by one as the algorithm explores the dsv of all the • UIDn[1]= v and UIDd[1]= deg(v) . TABLE V: sorted degree sequence list, deg seqi for i ∈ Vof the graph G1

vertex i deg seqi changed remarks order of dsv(i) 1 [ {(1,1),(3,2),(4,4)}] {(2,3)} - 2 [ {(2,3)}, {(2,3),(4,4)}, {(5,1),(3,2),(6,2),(2,3)} ] {(1,1),(3,2),(4,4)} - 3 [ {(1,1),(3,2),(4,4)}, {(5,1),(3,2),(6,2),(2,3)}] {(2,3),(4,4)} - 4 [ {(4,4)}, {(2,3),(4,4)}, {(7,1),(4,4)}, {(1,1),(3,2),(4,4)}] {(5,1),(6,2),(3,2),(2,3)} changed 5 [ {(5,1),(3,2),(6,2),(2,3)}] {(4,4)} - 6 [ {(6,2)}, {(5,1),(3,2),(6,2),(2,3)}] {(7,1),(4,4)} - 7 [ {(7,1),(4,4)}] {(6,2)} -

TABLE VI: UID of vertex 4 of Graph G1 vertex 4 -2 5 6 3 2 -2 4 7 4 2 4 1 3 4 -2 4 6 4 2 4 2 3 4 -2 degree 4 -2 1 2 2 3 -2 4 1 4 3 4 1 2 4 -2 -1 2 -1 -1 -1 3 -1 -1 -2

TABLE VII: UID of vertex D of Graph G2 vertex D -2 C B E F -2 D A D F D G E D -2 D 6 D F D F E D -2 degree D -2 1 2 2 3 -2 4 1 4 3 4 1 2 4 -2 -1 2 -1 -1 -1 3 -1 -1 -2

TABLE VIII: Practical results • UIDn[2]= −2 and UIDd[2]= −2 • The next deg(v) elements will be of dsn(v). Number Total Connected Trees Planar Permissible Fraction • Between any two i and j such that, UIDn[i] = −2, of vertices graphs graphs graphs graphs UIDd[i] = −2 and UIDn[ j] = −2, UIDd[ j] = −2 and 1 1 1 1 1 1 1 (trivial) 2 2 1 1 2 1 0.5 there is no k, where i < k < j, such that UIDn[k]= −2, 3 4 2 1 4 0 0 UIDd[k]= −2: 4 11 6 2 11 1 0.0909 5 34 21 3 33 0 0 6 156 112 6 142 6 0.038 The graphs described in Definition of Permissible Graphs 7 1044 853 11 822 62 0.05938 contains non-planar graphs. 8 12346 11117 23 6966 1024 0.0829 9 274668 261080 47 79853 29285 0.1066 Proof. We will prove it by example. Consider Fig. 3, number

1 2 3 3) Generate UIDs : The maximum length of any UID is of the order of the number of O(n2). This function will be called n times, making this step run in O(n3) time. 4) Try to fit Isomorphism: For finding the isomorphism, the Algorithm 4 will compare UID of one graph with all the 4 5 6 UIDs of the other graph. This is total n×n2 comparisons. This is O(n3). The algorithm will be called n times. So, the overall complexity becomes n × n3 making the complexity O(n4). Overall, the algorithm runs in O(n4) time. 7 8 The code was written in python and c++. In the Table VIII the number of permissible graphs for number of vertices ranging Fig. 3: Graph G 3 from 1 to 9 is given. We generated these graphs using SAGE [15] and nauty [16]. For n = 9, 10.66% of the graphs lie under of vertices is 8 and number of edges is 19. The graph has a the Definition of Permissible Graphs. There are only 0.0171% triangle in it. According to Euler’s formula [14] this graph is of graphs are for n = 9. The Theorem II-D states that non-planar graph (3v − 6 <= e). Once can easily verify that there are non-planar graphs, which can also be solved by the this graph can also be solved using the proposed method. proposed method.

III. AND PRACTICAL RESULTS IV. CONCLUSION 1) The Prerprocessing step : Degree of each vertex can be The proposed algorithm solves GI problem for a special found in O(n2) and after that their degree sequence can case. Before running any slower algorithm it is better to be calculated in O(n3). Overall, this step takes O(n3) check the graphs using this algorithm. The time complexity is time. O(n4), but these bounds are loose bounds. Because generating 2) Checking the input: Time omplexity O(n4). UID and the UIDs can be done faster, if we have used fast methods to sort them using the property that every value is bounded by v, making the bounds tighter. More importantly, this is polynomial time solution for this type of graphs.This algorithm is embarrassingly parallel making it useful in practical purposes.

ACKNOWLEDGMENT The authors would like to thank Dhruv Patel for helping in writing the software in python.

REFERENCES [1] L´aszl´oBabai. Graph isomorphism in quasipolynomial time [extended abstract]. In Proceedings of the 48th Annual ACM SIGACT Symposium on Theory of Computing, pages 684–697. ACM, 2016. [2] Michael D Barrus and Elizabeth Donovan. Neighborhood degree lists of graphs. arXiv preprint arXiv:1507.08212, 2015. [3] Paul J Kelly et al. A congruence theorem for trees. Pacific J. Math, 7(1):961–968, 1957. [4] Alfred V Aho and John E Hopcroft. The design and analysis of computer algorithms. Pearson Education India, 1974. [5] John E Hopcroft and Jin-Kue Wong. Linear time algorithm for isomorphism of planar graphs (preliminary report). In Proceedings of the sixth annual ACM symposium on Theory of computing, pages 172–184. ACM, 1974. [6] George S Lueker and Kellogg S Booth. A linear time algorithm for deciding interval graph isomorphism. Journal of the ACM (JACM), 26(2):183–195, 1979. [7] Charles J Colbourn. On testing isomorphism of permutation graphs. Networks, 11(1):13–21, 1981. [8] Hans L Bodlaender. Polynomial algorithms for graph isomorphism and chromatic index on partial k-trees. Journal of Algorithms, 11(4):631– 643, 1990. [9] Ion Stefan Filotti and Jack N Mayer. A polynomial-time algorithm for determining the isomorphism of graphs of fixed genus. In Proceedings of the twelfth annual ACM symposium on Theory of computing, pages 236–243. ACM, 1980. [10] L´aszl´o Babai, D Yu Grigoryev, and David M Mount. Isomorphism of graphs with bounded eigenvalue multiplicity. In Proceedings of the fourteenth annual ACM symposium on Theory of computing, pages 310– 324. ACM, 1982. [11] Gary L Miller. Isomorphism testing and canonical forms for k- contractable graphs (a generalization of bounded valence and bounded genus). In International Conference on Fundamentals of Computation Theory, pages 310–327. Springer, 1983. [12] Eugene M Luks. Parallel algorithms for permutation groups and graph isomorphism. In Foundations of Computer Science, 1986., 27th Annual Symposium on, pages 292–302. IEEE, 1986. [13] Laura A Zager and George C Verghese. Graph similarity scoring and matching. Applied mathematics letters, 21(1):86–94, 2008. [14] Douglas Brent West et al. Introduction to graph theory, volume 2. Prentice hall Upper Saddle River, 2001. [15] The Sage Developers. SageMath, the Sage Mathematics Software System (Version x.y.z), YYYY. http://www.sagemath.org. [16] Brendan D McKay et al. Practical graph isomorphism. 1981. [17] Brendan D McKay and Adolfo Piperno. Practical graph isomorphism, ii. Journal of Symbolic Computation, 60:94–112, 2014. [18] Julian R Ullmann. An algorithm for subgraph isomorphism. Journal of the ACM (JACM), 23(1):31–42, 1976. [19] Pasquale Foggia, Carlo Sansone, and Mario Vento. A performance comparison of five algorithms for graph isomorphism. In Proceedings of the 3rd IAPR TC-15 Workshop on Graph-based Representations in Pattern Recognition, pages 188–199, 2001. [20] Derek G Corneil and Calvin C Gotlieb. An efficient algorithm for graph isomorphism. Journal of the ACM (JACM), 17(1):51–64, 1970. [21] Scott Fortin. The graph isomorphism problem. 1996. [22] Eugene M Luks. Isomorphism of graphs of bounded valence can be tested in polynomial time. Journal of computer and system sciences, 25(1):42–65, 1982.