internal bool ValidateParams(IRandomNetGenParamMgr paramMgr, out int nodeCount, out int edgeCount, out bool isDirected, out string networkName, out bool allowCycles, out bool allowSelfLoops, out bool allowMultiEdges, out Exception ex) { bool isValid = true; nodeCount = edgeCount =0; isDirected = false; networkName = null; allowCycles = allowSelfLoops = allowMultiEdges = true; ex = null; string mssg = null; if (paramMgr == null) { mssg = Standard.Properties.Resources.MssgParamMgrIsNull; isValid = false; } else { nodeCount = paramMgr.NodeCount; edgeCount = paramMgr.EdgeCount; isDirected = paramMgr.IsDirected; networkName = paramMgr.NetworkName; allowCycles = paramMgr.AllowCycles; allowSelfLoops = paramMgr.AllowSelfLoops; allowMultiEdges = paramMgr.AllowMultiEdges; if (nodeCount<0) { mssg = string.Format(BlueSpider.Element.Standard.Properties.Resources.MssgNodeCountLessThan0, "NodeCount", nodeCount); isValid = false; } else if (edgeCount < 0) { mssg = string.Format(BlueSpider.Element.Standard.Properties.Resources.MssgEdgeCountLessThan0, "EdgeCount", edgeCount); isValid = false; } } if (!isValid) { FxArgumentException argEx = new FxArgumentException(mssg); argEx.FxId = this.Id; argEx.ParentElementId = this.ParentId; argEx.FxTypeName = this.GetType().FullName; ex = argEx; } return isValid; }
internal INetwork CreateNetwork(Guid id, IRandomNetGenParamMgr paramMgr) { INetwork net = null; using (var toolProvider = new NetworkToolProvider()) { using (var rgg = toolProvider.GetRandomGenerator<IBasicAdjList>()) { rgg.NodeCount = paramMgr.NodeCount; rgg.EdgeCount = paramMgr.EdgeCount; rgg.IsDirected = paramMgr.IsDirected; net = rgg.Generate(id); net.Name = paramMgr.NetworkName; } } return net; }