mirror of
https://github.com/Lendaia/oe-alga-feladatok.git
synced 2026-04-23 04:16:32 +01:00
ehehehhh
This commit is contained in:
@@ -1,6 +1,152 @@
|
||||
using System;
|
||||
using System.Data.Common;
|
||||
using Newtonsoft.Json.Converters;
|
||||
|
||||
namespace OE.ALGA.Adatszerkezetek
|
||||
{
|
||||
// 10. heti labor feladat - Tesztek: 10_SulyozatlanGrafTesztek.cs
|
||||
public class EgeszGrafEl : GrafEl<int>, IComparable
|
||||
{
|
||||
public int Honnan {get;}
|
||||
|
||||
public int Hova {get;}
|
||||
public EgeszGrafEl(int honnan, int hova)
|
||||
{
|
||||
Honnan = honnan;
|
||||
Hova = hova;
|
||||
}
|
||||
|
||||
public int CompareTo(object? obj)
|
||||
{
|
||||
EgeszGrafEl ob = (EgeszGrafEl)obj;
|
||||
|
||||
if (this.Honnan != ob.Honnan)
|
||||
{
|
||||
if(this.Honnan < ob.Honnan)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(this.Hova < ob.Hova)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
else if(this.Hova > ob.Hova)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public class CsucsmatrixSulyozatlanEgeszGraf : SulyozatlanGraf<int, EgeszGrafEl>
|
||||
{
|
||||
int n;
|
||||
bool[,] M;
|
||||
public int CsucsokSzama
|
||||
{
|
||||
get{ return n; }
|
||||
}
|
||||
|
||||
public int ElekSzama
|
||||
{
|
||||
get
|
||||
{
|
||||
int elek = 0;
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
for (int j = 0; j < n; j++)
|
||||
{
|
||||
if (M[i,j])
|
||||
{
|
||||
elek++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return elek;
|
||||
}
|
||||
}
|
||||
|
||||
public Halmaz<int> Csucsok
|
||||
{
|
||||
get
|
||||
{
|
||||
FaHalmaz<int> fahalmaz = new FaHalmaz<int>();
|
||||
for (int i = 0; i < n-1; i++)
|
||||
{
|
||||
fahalmaz.Beszur(i);
|
||||
}
|
||||
return fahalmaz;
|
||||
}
|
||||
}
|
||||
|
||||
public Halmaz<EgeszGrafEl> Elek
|
||||
{
|
||||
get
|
||||
{
|
||||
FaHalmaz<EgeszGrafEl> fahalmaz = new FaHalmaz<EgeszGrafEl>();
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
for (int j = 0; j < n; j++)
|
||||
{
|
||||
if (M[i,j])
|
||||
{
|
||||
EgeszGrafEl egeszgrafel = new EgeszGrafEl(i, j);
|
||||
fahalmaz.Beszur(egeszgrafel);
|
||||
}
|
||||
}
|
||||
}
|
||||
return fahalmaz;
|
||||
}
|
||||
}
|
||||
|
||||
//Halmaz<EgeszGrafEl> Graf<int, EgeszGrafEl>.Elek => throw new NotImplementedException();
|
||||
|
||||
public CsucsmatrixSulyozatlanEgeszGraf(int n)
|
||||
{
|
||||
this.n = n;
|
||||
M = new bool[n,n];
|
||||
}
|
||||
|
||||
public Halmaz<int> Szomszedai(int csucs)
|
||||
{
|
||||
FaHalmaz<int> fahalmaz = new FaHalmaz<int>();
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
if (M[csucs, i])
|
||||
{
|
||||
fahalmaz.Beszur(i);
|
||||
}
|
||||
}
|
||||
return fahalmaz;
|
||||
}
|
||||
|
||||
public void UjEl(int honnan, int hova)
|
||||
{
|
||||
M[honnan, hova] = true;
|
||||
}
|
||||
|
||||
public bool VezetEl(int honnan, int hova)
|
||||
{
|
||||
return M[honnan, hova];
|
||||
}
|
||||
}
|
||||
public class GrafBejaras<T>
|
||||
{
|
||||
public static Halmaz<V> SzelessegiBejaras<V, E>(Graf<V, E> g, V start, Action<V> muvelet) where V : IComparable
|
||||
{
|
||||
FaHalmaz<int> fahalmaz = new FaHalmaz<int>();
|
||||
int j = 0;
|
||||
g.Csucsok.Bejar(muvelet);
|
||||
//eheheheee
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user