Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public Graf()
- {
- this.nodes = new List<Node>();
- this.krawedzie = new List<Krawedz>();
- }
- public List<Krawedz> ZwrocKrawedzie(Node n)
- {
- List<Krawedz> zbior = new List<Krawedz>();
- for (int i = 0; i < this.krawedzie.Count; i++)
- {
- var k = this.krawedzie[i];
- if ((k.start == n) || (k.koniec == n))
- zbior.Add(k);
- }
- return zbior;
- }
- public void PrzejscieGrafu(Node start)
- {
- this.odwiedzone = new List<Node>();
- this.DFS(start);
- }
- public void DFS(Node n)
- {
- if (this.odwiedzone.Contains(n))
- {
- return;
- }
- this.odwiedzone.Add(n);
- var krawedzieOb = this.ZwrocKrawedzie(n);
- foreach (var k in krawedzieOb)
- {
- var drugi = k.ZnajdzDrugi(n);
- DFS(drugi);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement