private void AlgorithmFinal(AbstractNetworkContainer containerToChange) { Int32[] final = new Int32[containerToChange.Size]; for (int i = 0; i < final.Length; ++i) { final[i] = containerToChange.GetActiveStatus(i) ? 1 : 0; } for (int i = 0; i < containerToChange.GetActiveStatuses().Count; ++i) { if (!containerToChange.GetActiveStatus(i)) { continue; } if (Rand.NextDouble() < lambda) { Int32 index = RandomNeighbourToActivate(containerToChange, true, i); if (index != -1) { ++final[index]; } } if (Rand.NextDouble() < mu) { --final[i]; } } for (int i = 0; i < final.Count(); ++i) { // TODO get k as parameter containerToChange.SetActiveStatus(i, final[i] > 0); } }
private void Algorithm2(AbstractNetworkContainer containerToChange) { Int32 RandomActiveNode = GetRandomActiveNodeIndex(containerToChange); Debug.Assert(RandomActiveNode < containerToChange.Size); Debug.Assert(containerToChange.GetActiveStatus(RandomActiveNode)); if (Rand.NextDouble() < lambda) { ActivateVertex(containerToChange, true, RandomActiveNode); } if (Rand.NextDouble() < mu) { containerToChange.SetActiveStatus(RandomActiveNode, false); } }
private List <Int32> GetVertexPassiveNeighbours(AbstractNetworkContainer containerToChange, Int32 Vertex) { List <Int32> PassiveNeighbours = new List <Int32>(); for (int i = 0; i < container.Size; ++i) { if (i == Vertex) { continue; } if (containerToChange.AreConnected(Vertex, i) && !containerToChange.GetActiveStatus(i)) { PassiveNeighbours.Add(i); } } return(PassiveNeighbours); }
private Int32 GetRandomActiveNodeIndex(AbstractNetworkContainer containerToChange) { List <Int32> activeIndexes = new List <Int32>(); for (int i = 0; i < container.Size; ++i) { if (containerToChange.GetActiveStatus(i)) { activeIndexes.Add(i); } } if (activeIndexes.Count == 0) { return(-1); } return(GetRandomIndex(activeIndexes)); }