module IGraph.Motif
( triad
, triadCensus
) where
import Data.Hashable (Hashable)
import System.IO.Unsafe (unsafePerformIO)
import IGraph
import IGraph.Internal.Motif
import IGraph.Internal.Data
triad :: [LGraph D () ()]
triad = map make edgeList
where
edgeList =
[ []
, [(0,1)]
, [(0,1), (1,0)]
, [(1,0), (1,2)]
, [(0,1), (2,1)]
, [(0,1), (1,2)]
, [(0,1), (1,0), (2,1)]
, [(0,1), (1,0), (1,2)]
, [(0,1), (2,1), (0,2)]
, [(1,0), (2,1), (0,2)]
, [(0,1), (1,0), (0,2), (2,0)]
, [(1,0), (1,2), (0,2), (2,0)]
, [(0,1), (2,1), (0,2), (2,0)]
, [(0,1), (1,2), (0,2), (2,0)]
, [(0,1), (1,2), (2,1), (0,2), (2,0)]
, [(0,1), (1,0), (1,2), (2,1), (0,2), (2,0)]
]
make :: [(Int, Int)] -> LGraph D () ()
make xs = mkGraph (replicate 3 ()) $ zip xs $ repeat ()
triadCensus :: (Hashable v, Eq v, Read v) => LGraph d v e -> [Int]
triadCensus gr = unsafePerformIO $ do
vptr <- igraphVectorNew 0
igraphTriadCensus (_graph gr) vptr
map truncate <$> toList vptr