private void GetDrum(Retea retea, Nod nodStoc, Nod nodSursa) { nodStoc.Distanta = 0; Stack <Nod> stack = new Stack <Nod>(); List <Drum> drumuri = new List <Drum>(); List <Nod> noduriDrum = new List <Nod>(); stack.Push(nodStoc); while (stack.Count() != 0) { Nod nodCurent = stack.Pop(); noduriDrum.Add(nodCurent); if (nodCurent.Id == nodSursa.Id) { noduriDrum.Reverse(); drumuri.Add(new Drum(retea, noduriDrum)); noduriDrum = new List <Nod>(); } List <Arc> arce = retea.Arce.Where(arc => arc.Y.Id == nodCurent.Id && arc.X.Id == nodCurent.Predecesor.Id).ToList(); arce.ForEach(a => { stack.Push(a.X); }); } }
public IEnumerator GetEnumerator() { for (Nod p = prim; p != null; p = p.urm) { yield return(p.info); } }
public Monster(Nod start, Spawn pSpawn, byte type) : base(start, pSpawn, type) { Nod nod = GameServer.world.GetPositionAtTile(start.X, start.Y); posX = (int)nod.X; posY = (int)nod.Y; }
public void draw(Nod nod) { grp.FillEllipse(Brushes.Black, nod.x, nod.y, size, size); grp.DrawEllipse(Pens.Black, nod.x, nod.y, size, size); grp.DrawLine(Pens.Black, nod.parentCoord.X + size / 2, nod.parentCoord.Y + size / 2, nod.x + size, nod.y + size / 2); pictureBox1.Image = bmp; }
private List <SampleDataModel> NodToData(Nod nd, string parent) { var sampleTree = new List <SampleDataModel>(); int pos = i; if (nd.ch.Count == 3) { sampleTree.Add(new SampleDataModel { Id = pos.ToString(), ParentId = parent, Name = nd.ch[1].ToString() }); } else { sampleTree.Add(new SampleDataModel { Id = pos.ToString(), ParentId = parent, Name = nd.ch[0].ToString() }); } i++; if (nd.nods.Count > 0) { sampleTree.AddRange(NodToData(nd.nods[0], pos.ToString())); } if (nd.nods.Count > 1) { sampleTree.AddRange(NodToData(nd.nods[1], pos.ToString())); } return(sampleTree); }
Nod createnod(char cha) { Nod tmp = new Nod(); tmp.ch.Add(cha); return(tmp); }
private static void DeleteNode(Nod current) { var delNod = current.Next; current.Next = current.Next.Next; delNod.Next = null; }
public void AdaugaLaFinal(object data) { Nod newNod = new Nod(); newNod.val = data; curent.Next = newNod; curent = newNod; nr++; }
private void Formula_TextChanged(object sender, TextChangedEventArgs e) { text = formula.Text; reset(); text = tostrict(text); Console.WriteLine(text); MyNod = tonod(); }
private void Start() { bmp = new Bitmap(pictureBox1.Width, pictureBox1.Height); grp = Graphics.FromImage(bmp); radacina = new Nod(bmp.Width / 2, 0, 16, 5, new Point(bmp.Width / 2, 0)); draw(radacina); frunze.Add(radacina); }
private Nod GetCurrent(T t, Nod current) { while (current != null && current.Data.Equals(t)) { start = start.Next; current = start; } return(current); }
public void UsualDateBinTest() { int firstN = 585; int secondN = 81; int expected = 9; int nod = Nod.BinaryNod(firstN, secondN); Assert.AreEqual(expected, nod, "NOD not found correctly"); }
private void InaintareReetichetare(Retea retea, Nod x) { List <Arc> arceDinX = retea.Arce.Where(a => a.X.Id == x.Id).OrderBy(a => a.Y.Id).ToList(); Queue <Arc> coadaArce = new Queue <Arc>(arceDinX); Arc arc = coadaArce.Dequeue(); bool esteReetichetat = false; do { if (arc.EsteAdmisibil(retea)) { arc.Flux += Math.Min(x.GetExces(retea), arc.GetCapacitateReziduala(retea)); Arc arcInvers = retea.Arce.FirstOrDefault(a => a.X.Id == arc.Y.Id && a.Y.Id == arc.X.Id); if (arcInvers == null) { arcInvers = new Arc(arc.Y, arc.X, 0, 0); retea.Arce.Add(arcInvers); } if (!_L.Contains(arc.Y) && !arc.Y.EsteNodSursa && !arc.Y.EsteNodStoc) { _L.Enqueue(arc.Y); } } if (x.GetExces(retea) > 0) { if (coadaArce.Count() > 0) { arc = coadaArce.Dequeue(); } else { x.Distanta = arceDinX.Where(a => a.GetCapacitateReziduala(retea) > 0).Min(a => a.Y.Distanta + 1); esteReetichetat = true; } } Console.WriteLine(retea.ToString()); Console.Write("Distante:"); retea.Noduri.Select(n => n.Distanta).ToList().ForEach(d => Console.Write($"{d}, ")); Console.WriteLine("\n"); } while (x.GetExces(retea) != 0 && !esteReetichetat); if (x.GetExces(retea) > 0) { _L.Enqueue(x); } }
public void AdaugaLaInceput(object data) { Nod newNod = new Nod() { val = data }; newNod.Next = cap.Next; //new node will have reference of head's next reference cap.Next = newNod; //and now head will refer to new node nr++; }
public void Push(Nod n) { dim++; Nod[] aux = new Nod[dim]; aux[0] = n; for (int i = 1; i < dim; i++) { aux[i] = values[i - 1]; } values = aux; }
public void CreareText() { Nod aux = cap; while (aux != null) { ListaScoruri = ListaScoruri + aux.nume + " " + aux.time + " " + aux.val + "\n"; aux = aux.urm; } //ListaScoruri = ListaScoruri + "\n" + System.DateTime.Now.Hour.ToString() + " : " + System.DateTime.Now.Minute.ToString() + " " + curent.nume + " " + curent.val; }
private void PerformDeletion(Nod current) { if (end == current.Next) { DeleteLast(current); } else { DeleteNode(current); } }
public void insertToFront(T type) { var nod = new Nod(type); nod.Next = start; start = nod; if (end == null) { end = nod; } }
public Retea UpdateRetea(Retea retea) { Initializare(retea); while (_L.Count() != 0) { Nod nod = _L.Dequeue(); InaintareReetichetare(retea, nod); } return(retea); }
public void Sterge(ElemType e) { for (Nod p = prim; p != null; p = p.urm) { if (p.urm.info.Equals(e)) { p.urm = p.urm.urm; dimensiune--; break; } } }
public void AdaugaInceput(string nume, string time, object data) { Nod newNod = new Nod(); newNod.val = data; newNod.nume = nume; newNod.urm = cap; newNod.time = time; cap = newNod; curent = newNod; nr++; }
public void NullArgBinTest() { int firstN = 0; int secondN = 81; int thirdN = 9; int fourth = 3; int more = 0; int expected = 0; int nod = Nod.BinaryNod(firstN, secondN, thirdN, fourth, more); Assert.AreEqual(expected, nod, "NOD not found correctly"); }
public void NegativArgEvklidTest() { int firstN = -585; int secondN = 81; int thirdN = -9; int fourth = 3; int more = 12; int expected = 3; int nod = Nod.NodEvklid(firstN, secondN, thirdN, fourth, more); Assert.AreEqual(expected, nod, "NOD not found correctly"); }
private Nod DeleteNodes(T t, Nod current) { if (current.Next.Data.Equals(t)) { PerformDeletion(current); } else { current = current.Next; } return(current); }
public void nod_10and20_10returned() { // arrange int x = 10; int y = 20; int expected = 10; // act int actual = Nod.nod(x, y); // assert Assert.AreEqual(expected, actual); }
public Nod Pop() { dim--; Nod[] aux = new Nod[dim]; for (int i = 0; i < dim; i++) { aux[i] = values[i]; } Nod a = values[dim]; values = aux; return(a); }
public MainForm(Nod nods) { InitializeComponent(); //_data = GetSampleData(); _data = NodToData(nods, string.Empty); _tree = GetSampleTree(_data); TreeHelpers <SampleDataModel> .CalculateNodePositions(_tree); CalculateControlSize(); DoubleBuffered = true; treePanel.Paint += treePanel_Paint; }
public void Afisare() { //Traverse from head Console.Write("Cap ->"); Nod aux = head; while (aux.Next != null) { aux = aux.Next; Console.Write(aux.val); Console.Write("->"); } Console.Write("NULL"); }
public void nodBigInputTest_10and20and30_10returned() { // arrange int x = 10; int y = 20; int z = 30; int expected = 10; // act int actual = Nod.nodBigInput(x, y, z); // assert Assert.AreEqual(expected, actual); }
public void insertToEnd(T type) { var node = new Nod(type); if (start == null) { start = node; } if (end != null) { end.Next = node; } end = node; }
private void buttonCrypto_Click(object sender, EventArgs e) { string cipher,substring,tempstring=""; int indexfirst,indexlast,i,j,k,a,b; List<int> distList = new List<int>(); List<Nod> NodList = new List<Nod>(); Nod currentnod=new Nod(); bool check; if (textBox_Cipher.Lines.Count() == 0) { MessageBox.Show("Не введен шифротекст!"); return; } textBox_Source.Clear(); cipher = textBox_Cipher.Text.ToString(); for (indexfirst = 0; indexfirst < cipher.Length; indexfirst++) { if (Array.IndexOf(Alphabet, cipher[indexfirst]) == -1) { cipher = cipher.Remove(indexfirst, 1); indexfirst--; } } for (int length = 10; length >= 3; length--) { for (indexfirst = 0; indexfirst < cipher.Length-length; indexfirst++) { substring = cipher.Substring(indexfirst,length); if ((textBox_Source.Text.IndexOf(substring) == -1) && (textBox_Source.Text.IndexOf(substring.Substring(0,3)) == -1)) { tempstring = ""; indexlast = indexfirst + length - 1; while (indexlast > -1) { indexlast = cipher.IndexOf(substring, indexlast + 1); if (indexlast > -1) { tempstring = tempstring + "pos=" + indexlast + " dist=" + (indexlast - indexfirst) + "; "; distList.Add(indexlast - indexfirst); } } if (tempstring != "") textBox_Source.AppendText("\"" + substring + "\" " + "starting pos=" + indexfirst + " " + tempstring + "\r\n"); } } } distList.Sort(); for (i = 1; i < distList.Count; i++) { if (distList[i] == distList[i - 1]) { distList.RemoveAt(i); i--; } } for (i = 0; i < distList.Count; i++) { for (j = i+1; j < distList.Count; j++) { check = true; a = distList[i]; b = distList[j]; while ((a!=0) && (b!=0)) { if (a > b) a = a % b; else b = b % a; } currentnod.value=a+b; currentnod.chance=1; if (currentnod.value == 1) continue; for (k = 0; k < NodList.Count; k++) { if (NodList[k].value == currentnod.value) { check = false; currentnod = NodList[k]; currentnod.chance++; NodList[k] = currentnod; break; } } if (check) NodList.Add(currentnod); } } indexfirst = 0; currentnod = NodList[0]; for (i = 0; i < NodList.Count; i++) { indexfirst+=NodList[i].chance; if (NodList[i].chance>currentnod.chance) currentnod = NodList[i]; } textBox_Source.AppendText("Криптоанализ завершен!\r\n"); textBox_Source.AppendText("Вероятная длинна ключа: "+currentnod.value+". Вероятность: "+(currentnod.chance*100/indexfirst)+"%\r\n"); }