示例#1
0
        public Structure(List <int> _graphStructure, int _min, int _max)
        {
            this.graphStructure = _graphStructure;
            int CurrentCount = 0;
            int OlderCount   = 0;
            int EdgeCount    = 0;


            for (int i = 0; i < graphStructure.Count; i++)
            {
                for (int j = 0; j < graphStructure[i]; j++)
                {
                    if (i == 0)
                    {
                        OlderCount += 1;
                    }
                    else
                    {
                        CurrentCount += 1;
                    }


                    if (j == graphStructure[i] - 1 && i > 0)
                    {
                        EdgeCount    = EdgeCount + (OlderCount * CurrentCount) + CurrentCount;
                        OlderCount   = CurrentCount;
                        CurrentCount = 0;
                    }
                }
            }

            for (int i = 0; i < EdgeCount; i++)
            {
                this.edgeValues.Add(float.Parse(RandomFloatValues.nextRandomFloat(_max, _min).ToString("0.00")));
            }
        }
        public static void save(Structure tmpStructure)
        {
            string jsonToSave = JsonConvert.SerializeObject(tmpStructure, Formatting.Indented);

            File.WriteAllText("Structure" + RandomFloatValues.nextRandomFloat(0, 1000).ToString("0,00") + ".json", jsonToSave);
        }