greedyIndSetN :: Int -> ArrayGraph -> ([Int],Int)
greedyIndSetN n (ArrayGraph graph sg) = gis n sg
  where
    gis n sg@(Subgraph _ ds) =
      case minDegs ds of
        [] -> ([],n)
        xs -> let (x, newN) = rListElem xs n
              in mapFst (x :) (gis newN (updateSubgraph graph sg x))
greedyIndSetN :: Int -> ArrayGraph -> ([Int],Int)
greedyIndSetN n (ArrayGraph graph sg) = gis n sg
  where
    gis n sg@(Subgraph _ ds) =
      case minDegs ds of
        [] -> ([],n)
        xs -> let (x, newN) = rListElem xs n
              in mapFst (x :) (gis newN (updateSubgraph graph sg x))
greedyIndSetN n (ArrayGraph graph sg) = gis n sg
  where
    gis n sg@(Subgraph _ ds) =
      case minDegs ds of
        [] -> ([],n)
        xs -> let (x, newN) = rListElem xs n
              in mapFst (x :) (gis newN (updateSubgraph graph sg x))