subgraphIsomorphisms' :: AdjacencyList -> AdjacencyList -> [Subisomorphism]
subgraphIsomorphisms' g_smaller g_larger
  = unsafeLocalState $ withArray (map (fromIntegral . fst) g_smaller) $ \smaller_colors ->
                       withArray (map (fromIntegral . fst) g_larger) $ \larger_colors ->
                       withArray [fromIntegral i | (from, tos) <- [0..] `zip` map snd g_smaller, to <- tos, i <- [from, to]] $ \smaller_edges ->
                       withArray [fromIntegral i | (from, tos) <- [0..] `zip` map snd g_larger, to <- tos, i <- [from, to]] $ \larger_edges -> do
                           isos <- newIORef []
                           let callback mapping_ptr = do
                                  mapping <- peekArray (genericLength g_smaller) mapping_ptr
                                  --trace (show mapping) $ return ()
                                  modifyIORef isos (map (\x -> round (x :: CDouble) - 1) mapping :)
                                  return 1
                           bracket (mkCallback callback) freeHaskellFunPtr $ \callback ->
                              find_graph_subisomorphisms (genericLength g_smaller) smaller_colors (genericLength (concatMap snd g_smaller)) smaller_edges
                                                         (genericLength g_larger)  larger_colors  (genericLength (concatMap snd g_larger))  larger_edges
                                                         callback
                           readIORef isos
subgraphIsomorphisms' :: AdjacencyList -> AdjacencyList -> [Subisomorphism]
subgraphIsomorphisms' g_smaller g_larger
  = unsafeLocalState $ withArray (map (fromIntegral . fst) g_smaller) $ \smaller_colors ->
                       withArray (map (fromIntegral . fst) g_larger) $ \larger_colors ->
                       withArray [fromIntegral i | (from, tos) <- [0..] `zip` map snd g_smaller, to <- tos, i <- [from, to]] $ \smaller_edges ->
                       withArray [fromIntegral i | (from, tos) <- [0..] `zip` map snd g_larger, to <- tos, i <- [from, to]] $ \larger_edges -> do
                           isos <- newIORef []
                           let callback mapping_ptr = do
                                  mapping <- peekArray (genericLength g_smaller) mapping_ptr
                                  --trace (show mapping) $ return ()
                                  modifyIORef isos (map (\x -> round (x :: CDouble) - 1) mapping :)
                                  return 1
                           bracket (mkCallback callback) freeHaskellFunPtr $ \callback ->
                              find_graph_subisomorphisms (genericLength g_smaller) smaller_colors (genericLength (concatMap snd g_smaller)) smaller_edges
                                                         (genericLength g_larger)  larger_colors  (genericLength (concatMap snd g_larger))  larger_edges
                                                         callback
                           readIORef isos
subgraphIsomorphisms' g_smaller g_larger
  = unsafeLocalState $ withArray (map (fromIntegral . fst) g_smaller) $ \smaller_colors ->
                       withArray (map (fromIntegral . fst) g_larger) $ \larger_colors ->
                       withArray [fromIntegral i | (from, tos) <- [0..] `zip` map snd g_smaller, to <- tos, i <- [from, to]] $ \smaller_edges ->
                       withArray [fromIntegral i | (from, tos) <- [0..] `zip` map snd g_larger, to <- tos, i <- [from, to]] $ \larger_edges -> do
                           isos <- newIORef []
                           let callback mapping_ptr = do
                                  mapping <- peekArray (genericLength g_smaller) mapping_ptr
                                  --trace (show mapping) $ return ()
                                  modifyIORef isos (map (\x -> round (x :: CDouble) - 1) mapping :)
                                  return 1
                           bracket (mkCallback callback) freeHaskellFunPtr $ \callback ->
                              find_graph_subisomorphisms (genericLength g_smaller) smaller_colors (genericLength (concatMap snd g_smaller)) smaller_edges
                                                         (genericLength g_larger)  larger_colors  (genericLength (concatMap snd g_larger))  larger_edges
                                                         callback
                           readIORef isos