ninetynine-1.3.0: Ninety-Nine Haskell Problems
CopyrightCopyright (C) 2021 Yoo Chung
LicenseGPL-3.0-or-later
Maintainerdev@chungyc.org
Safe HaskellSafe-Inferred
LanguageGHC2021

Problems.P85

Description

Part of Ninety-Nine Haskell Problems. Some solutions are in Solutions.P85.

Synopsis

Documentation

isomorphic :: G -> G -> Bool Source #

Two graphs \(G_1 = (V_1,E_1)\) and \(G_2 = (V_2,E_2)\) are isomorphic if there is a bijection \(f: V_1 -> V_2\) such that for any vertexes \(x\), \(y\) in \(V_1\), \(x\) and \(y\) are adjacent if and only if \(f(x)\) and \(f(y)\) are adjacent.

Write a function that determines whether two graphs are isomorphic.

Examples

>>> isomorphic (toG $ Paths [[1,2,3], [2,4]]) (toG $ Paths [[1,2,3],[1,4]])
False
>>> isomorphic graph85 graph85'
True

graph85 :: G Source #

Example graph to try out isomorphic, along with graph85'.

graph85' :: G Source #

Example graph to try out isomorphic, along with graph85.