August 28, 2024

P85 - Graph isomorphism.

Two graphs G1(N1,E1)G1​(N1​,E1​) and G2(N2,E2)G2​(N2​,E2​) are isomorphic if there is a bijection f:N1→N2f:N1​→N2​ such that for any nodes X,YX,Y of N1N1​, XX and YY are adjacent if and only if f(X)f(X) and f(Y)f(Y) are adjacent.

Write a method that determines whether two graphs are isomorphic.

scala

scala> Graph.fromString("[a-b]").isIsomorphicTo(Graph.fromString("[5-7]"))
res0: Boolean = true
Be first to comment
Leave a reply