-- GENERATED by C->Haskell Compiler, version 0.28.3 Switcheroo, 25 November 2017 (Haskell)
-- Edit the ORIGNAL .chs file instead!


{-# LINE 1 "src/IGraph/Clique.chs" #-}
{-# LANGUAGE ForeignFunctionInterface #-}
module IGraph.Clique
    ( cliques
    , maximalCliques
    ) where
import qualified Foreign.C.Types as C2HSImp



import Control.Applicative ((<$>))
import System.IO.Unsafe (unsafePerformIO)

import qualified Foreign.Ptr as C2HSImp

import IGraph
import IGraph.Internal
{-# LINE 13 "src/IGraph/Clique.chs" #-}




cliques :: LGraph d v e
        -> (Int, Int)  -- ^ Minimum and maximum size of the cliques to be returned.
                       -- No bound will be used if negative or zero
        -> [[Int]]     -- ^ cliques represented by node ids
cliques gr (lo, hi) = unsafePerformIO $ do
    vpptr <- igraphVectorPtrNew 0
    _ <- igraphCliques (_graph gr) vpptr lo hi
    (map.map) truncate <$> toLists vpptr
igraphCliques :: (IGraph) -> (VectorPtr) -> (Int) -> (Int) -> IO ((Int))
igraphCliques a1 a2 a3 a4 =
  (withIGraph) a1 $ \a1' ->
  (withVectorPtr) a2 $ \a2' ->
  let {a3' = fromIntegral a3} in
  let {a4' = fromIntegral a4} in
  igraphCliques'_ a1' a2' a3' a4' >>= \res ->
  let {res' = fromIntegral res} in
  return (res')

{-# LINE 25 "src/IGraph/Clique.chs" #-}


maximalCliques :: LGraph d v e
               -> (Int, Int)  -- ^ Minimum and maximum size of the cliques to be returned.
                              -- No bound will be used if negative or zero
               -> [[Int]]     -- ^ cliques represented by node ids
maximalCliques gr (lo, hi) = unsafePerformIO $ do
    vpptr <- igraphVectorPtrNew 0
    _ <- igraphMaximalCliques (_graph gr) vpptr lo hi
    (map.map) truncate <$> toLists vpptr
igraphMaximalCliques :: (IGraph) -> (VectorPtr) -> (Int) -> (Int) -> IO ((Int))
igraphMaximalCliques a1 a2 a3 a4 =
  (withIGraph) a1 $ \a1' ->
  (withVectorPtr) a2 $ \a2' ->
  let {a3' = fromIntegral a3} in
  let {a4' = fromIntegral a4} in
  igraphMaximalCliques'_ a1' a2' a3' a4' >>= \res ->
  let {res' = fromIntegral res} in
  return (res')

{-# LINE 35 "src/IGraph/Clique.chs" #-}


foreign import ccall safe "IGraph/Clique.chs.h igraph_cliques"
  igraphCliques'_ :: ((C2HSImp.Ptr (IGraph)) -> ((C2HSImp.Ptr (VectorPtr)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (IO C2HSImp.CInt)))))

foreign import ccall safe "IGraph/Clique.chs.h igraph_maximal_cliques"
  igraphMaximalCliques'_ :: ((C2HSImp.Ptr (IGraph)) -> ((C2HSImp.Ptr (VectorPtr)) -> (C2HSImp.CInt -> (C2HSImp.CInt -> (IO C2HSImp.CInt)))))