Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. << IGraphM`
  2.  
  3. g1 = Graph[{1 -> 3, 1 -> 4, 1 -> 4, 2 -> 3, 2 -> 3, 2 -> 4}]
  4.  
  5. g2 = Graph[{1 -> 2, 1 -> 2, 1 -> 3, 2 -> 4, 3 -> 4, 3 -> 4}]
  6.  
  7. IGIsomorphicQ[g1, g2]
  8. (* False *)
  9.  
  10. g1 = Graph[{1 <-> 3, 1 <-> 4, 1 <-> 4, 2 <-> 3, 2 <-> 3, 2 <-> 4}]
  11.  
  12. g2 = Graph[{1 <-> 2, 1 <-> 2, 1 <-> 3, 2 <-> 4, 3 <-> 4, 3 <-> 4}]
  13.  
  14. IGIsomorphicQ[g1, g2]
  15. (* True *)
  16.  
  17. IGGetIsomorphism[g1, g2]
  18. (* {<|1 -> 1, 3 -> 3, 4 -> 2, 2 -> 4|>} *)
  19.  
  20. asc1 = Counts[Sort /@ EdgeList[g1]]
  21. (* <|1 <-> 3 -> 1, 1 <-> 4 -> 2, 2 <-> 3 -> 2, 2 <-> 4 -> 1|> *)
  22.  
  23. asc2 = Counts[Sort /@ EdgeList[g2]]
  24. (* <|1 <-> 2 -> 2, 1 <-> 3 -> 1, 2 <-> 4 -> 1, 3 <-> 4 -> 2|> *)
  25.  
  26. IGVF2FindIsomorphisms[{Graph[VertexList[g1],Keys[asc1]], "EdgeColors" -> asc1}, {Graph[VertexList[g2],Keys[asc2]], "EdgeColors" -> asc2}]
  27. (* {<|1 -> 1, 3 -> 3, 4 -> 2, 2 -> 4|>, <|1 -> 3, 3 -> 1, 4 -> 4, 2 -> 2|>,
  28. <|1 -> 2, 3 -> 4, 4 -> 1, 2 -> 3|>, <|1 -> 4, 3 -> 2, 4 -> 3, 2 -> 1|>} *)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement