Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace L12A2Z_Prog2_Beadando
- {
- abstract class Graph
- {
- public int N;
- abstract public List<int> Csucsok(); //csucsok listaja
- abstract public void ElFelvetel(int honnan, int hova);
- abstract public bool VezetEl(int honnan, int hova); //vezet-e el
- public List<int> Szomszedok(int cs)
- {
- List<int> szomszedsag = new List<int>();
- foreach (int n in Csucsok())
- {
- if (VezetEl(cs, n))
- szomszedsag.Add(n);
- }
- return szomszedsag;
- }
- public int SzelessegiKereses(int start)
- {
- //kiirja
- List<int> F = new List<int>(); //feldolgozottak
- Queue<int> S = new Queue<int>(); //meg ellenorizni kell
- F.Add(start);
- S.Enqueue(start);
- while (S.Count > 0)
- {
- int k = S.Dequeue();
- //Console.WriteLine( "Elert elem {0}", k); //itt lehet műveletet végezni
- foreach (int n in Szomszedok(k))
- {
- if (!F.Contains(n))
- {
- F.Add(n);
- S.Enqueue(n);
- }
- }
- }
- return F.Count;
- }
- public bool Osszefuggo()
- {
- return SzelessegiKereses(0) == N;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement