public IEnumerable <IPartition> PartitionModel(IModel model) { List <IPartition> partitionList = new List <IPartition>(); List <INode> nodes = new List <INode>(model.Nodes); int seed = Seed(); logger.Debug("Seed used for partition shuffling: {0}", seed); nodes.Shuffle(seed); int numberOfPartitions = int.Parse(Configuration.Current.GetOption("partitions")); int numberOfNodesInPartion = (int)Math.Ceiling(nodes.Count / (double)numberOfPartitions); int cntr = 0; IPartition partition = this.partitionFactory.CreatePartition(); foreach (var node in nodes) { if (cntr < numberOfNodesInPartion) { partition.Add(node); ++cntr; } else { cntr = 1; partitionList.Add(partition); partition = this.partitionFactory.CreatePartition(); partition.Add(node); } } if (!partition.IsEmpty && !partitionList.Contains(partition)) { partitionList.Add(partition); } return(partitionList); }