private ERContainer Transformations(ERContainer trcontainer,Random random, bool keepdistribution,out int triangle) { var tranformation = trcontainer.Copy(); triangle = 0; try { var removeedje = random.Next(0, tranformation.Edjes.Count - 1); var removeedjeVertix1 = tranformation.Edjes[removeedje].Key; var removeedjeVertix2 = tranformation.Edjes[removeedje].Value; var addEdje = random.Next(0, tranformation.NoEdjes.Count - 1); var addEdjeVertix1 = tranformation.NoEdjes[addEdje].Key; var addEdjeVertix2 = tranformation.NoEdjes[addEdje].Value; //Remove edje tranformation.Neighbourship[removeedjeVertix1].Remove(removeedjeVertix2); tranformation.Neighbourship[removeedjeVertix2].Remove(removeedjeVertix1); tranformation.NoEdjes.Add(tranformation.Edjes[removeedje]); tranformation.Edjes.RemoveAt(removeedje); //Count remove triangle int removetriangle = CountTriangle(removeedjeVertix1, removeedjeVertix2, tranformation); //add edje tranformation.Neighbourship[addEdjeVertix1].Add(addEdjeVertix2); tranformation.Neighbourship[addEdjeVertix2].Add(addEdjeVertix1); tranformation.Edjes.Add(tranformation.NoEdjes[addEdje]); tranformation.NoEdjes.RemoveAt(addEdje); // Count Add triangle int addtriangle = CountTriangle(addEdjeVertix1, addEdjeVertix2, tranformation); triangle = addtriangle - removetriangle; } catch (Exception ex) { log.Error("Error according when transforms edges"); } return tranformation; }
public override SortedDictionary<int, double> GetTrianglesTrajectory(double constant, BigInteger stepcount,bool keepdistribution) { log.Info("Getting triangle trajectory."); var stepscount = stepcount; var tarctory = new SortedDictionary<int, double>(); int time = 0; int currentcounttriangle = GetCyclesForTringle(container); tarctory.Add(time, currentcounttriangle); if (keepdistribution) container.Get4Motifs(); var currentContainer = container.Copy(); var tempContainer = new ERContainer(); var random = new Random(); while (time != stepcount) { try { time++; var count = 0; tempContainer = keepdistribution? TransformKeppingDistriburtion(currentContainer, random, out count) : Transformations(currentContainer, random,keepdistribution,out count); if (currentcounttriangle < (-count)) { Console.WriteLine("f**k"); } var counttriangle = currentcounttriangle + count; var delta = counttriangle - currentcounttriangle; if (delta > 0) { tarctory.Add(time, counttriangle); currentContainer = tempContainer.Copy(); currentcounttriangle = counttriangle; } else { if (new Random().NextDouble() < CalculatePropability(delta, constant)) { tarctory.Add(time, counttriangle); currentContainer = tempContainer.Copy(); currentcounttriangle = counttriangle; } else { tarctory.Add(time, currentcounttriangle); } Console.WriteLine(time); } } catch (Exception ex) { log.Error(String.Format("Error occurred in step {0} ,Error message {1} ", stepcount, ex.InnerException)); } } // very freak code bool trace = false; Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); if (config.AppSettings.Settings["Tracing"].Value == "yes") trace = true; if (trace) { TraceContainer(config.AppSettings.Settings["TracingDirectory"].Value, currentContainer, constant); } // end of freak code return tarctory; }