added things
This commit is contained in:
parent
4287c44e6e
commit
1ebc6c67b6
.vs
Verseny
FileContentIndex
41953c11-d4b8-4e9a-852b-e4c5db57a63f.vsidx5141a22c-61ba-42db-a756-5e403fa29073.vsidx9e53bb50-85aa-457c-866d-edd2f082b813.vsidx
v17
fordulo_1/Program/obj
Debug/net9.0
Program.AssemblyInfo.csProgram.AssemblyInfoInputs.cacheProgram.GeneratedMSBuildEditorConfig.editorconfig
Release/net9.0
fordulo_2/Program/obj
fordulo_3
Program
.vs
Program.csproj.dtbcache.json
Doboz.csProgram.csProgram.csprojVirusVoid.csProgram
FileContentIndex
7bb177e6-bed0-410e-b775-a9b6bfd7193b.vsidx84b83a8a-186d-44f9-bc2c-79f3eb943fc5.vsidx8625977a-5147-4783-9e44-a2541008bfc6.vsidx89a9efce-9a8f-4b6b-8bcc-3b5a9b791b04.vsidx91a593c8-82be-4403-b7f8-4ae1fdf23dc0.vsidxab132887-542c-4edf-ac0b-0251699605d4.vsidxb1c87362-3c3a-4373-98a0-5e724e457f47.vsidx
v17
bin/Debug
obj
forrasok
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
.vs/slnx.sqlite
BIN
.vs/slnx.sqlite
Binary file not shown.
|
@ -14,7 +14,7 @@ using System.Reflection;
|
|||
[assembly: System.Reflection.AssemblyCompanyAttribute("Program")]
|
||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+125039f7afa4d55f84ae92ca8bb5d680c96dddaa")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+4287c44e6ea2049cf0a37161c82453ac60f3877e")]
|
||||
[assembly: System.Reflection.AssemblyProductAttribute("Program")]
|
||||
[assembly: System.Reflection.AssemblyTitleAttribute("Program")]
|
||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||
|
|
|
@ -1 +1 @@
|
|||
fa1dd1337108d86b90c993aeca956532f3929d3df42ce60dbfe44b7b4331a5d0
|
||||
0333c6b72ecbcd6537212ba37ec65dec7fbdb8cf3657fb71804dfbce72d26bf4
|
||||
|
|
|
@ -11,5 +11,3 @@ build_property.RootNamespace = Program
|
|||
build_property.ProjectDir = C:\Users\szabomarton\Desktop\Verseny\fordulo_1\Program\
|
||||
build_property.EnableComHosting =
|
||||
build_property.EnableGeneratedComInterfaceComImportInterop =
|
||||
build_property.EffectiveAnalysisLevelStyle = 9.0
|
||||
build_property.EnableCodeStyleSeverity =
|
||||
|
|
|
@ -14,7 +14,7 @@ using System.Reflection;
|
|||
[assembly: System.Reflection.AssemblyCompanyAttribute("Program")]
|
||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Release")]
|
||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+125039f7afa4d55f84ae92ca8bb5d680c96dddaa")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+4287c44e6ea2049cf0a37161c82453ac60f3877e")]
|
||||
[assembly: System.Reflection.AssemblyProductAttribute("Program")]
|
||||
[assembly: System.Reflection.AssemblyTitleAttribute("Program")]
|
||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||
|
|
|
@ -1 +1 @@
|
|||
f906cfd11295328e105ea96075df17757f03b97601f6554b3ba2d5440a6c9a31
|
||||
78c22c4c5f0bf656b7c6ac2e8f670a7dafc6607757ed8135e1f2f0ecdd3d32a2
|
||||
|
|
|
@ -11,5 +11,3 @@ build_property.RootNamespace = Program
|
|||
build_property.ProjectDir = C:\Users\szabomarton\Desktop\Verseny\fordulo_1\Program\
|
||||
build_property.EnableComHosting =
|
||||
build_property.EnableGeneratedComInterfaceComImportInterop =
|
||||
build_property.EffectiveAnalysisLevelStyle = 9.0
|
||||
build_property.EnableCodeStyleSeverity =
|
||||
|
|
Binary file not shown.
Binary file not shown.
1
fordulo_3/Program/.vs/Program.csproj.dtbcache.json
Normal file
1
fordulo_3/Program/.vs/Program.csproj.dtbcache.json
Normal file
|
@ -0,0 +1 @@
|
|||
{"RootPath":"C:\\Users\\szabomarton\\Desktop\\Verseny\\fordulo_3\\Program","ProjectFileName":"Program.csproj","Configuration":"Debug|AnyCPU","FrameworkPath":"","Sources":[{"SourceFile":"Feladat3.cs"},{"SourceFile":"PermutationGenerator.cs"},{"SourceFile":"Program.cs"},{"SourceFile":"Properties\\AssemblyInfo.cs"},{"SourceFile":"Sorozat.cs"},{"SourceFile":"Virus.cs"},{"SourceFile":"obj\\Debug\\.NETFramework,Version=v4.8.AssemblyAttributes.cs"}],"References":[{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\Microsoft.CSharp.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\mscorlib.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Core.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Data.DataSetExtensions.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Data.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Net.Http.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Xml.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Xml.Linq.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""}],"Analyzers":[],"Outputs":[{"OutputItemFullPath":"C:\\Users\\szabomarton\\Desktop\\Verseny\\fordulo_3\\Program\\bin\\Debug\\Program.exe","OutputItemRelativePath":"Program.exe"},{"OutputItemFullPath":"","OutputItemRelativePath":""}],"CopyToOutputEntries":[]}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -7,8 +7,8 @@
|
|||
"RelativeMoniker": "D:0:0:{6A74A9DE-500D-46FF-859A-18F4A752D2A5}|Program.csproj|solutionrelative:program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
|
||||
},
|
||||
{
|
||||
"AbsoluteMoniker": "D:0:0:{6A74A9DE-500D-46FF-859A-18F4A752D2A5}|Program.csproj|C:\\Users\\szabomarton\\Desktop\\Verseny\\fordulo_3\\Program\\virus.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
|
||||
"RelativeMoniker": "D:0:0:{6A74A9DE-500D-46FF-859A-18F4A752D2A5}|Program.csproj|solutionrelative:virus.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
|
||||
"AbsoluteMoniker": "D:0:0:{6A74A9DE-500D-46FF-859A-18F4A752D2A5}|Program.csproj|c:\\users\\szabomarton\\desktop\\verseny\\fordulo_3\\program\\doboz.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
|
||||
"RelativeMoniker": "D:0:0:{6A74A9DE-500D-46FF-859A-18F4A752D2A5}|Program.csproj|solutionrelative:doboz.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
|
||||
}
|
||||
],
|
||||
"DocumentGroupContainers": [
|
||||
|
@ -18,8 +18,21 @@
|
|||
"DocumentGroups": [
|
||||
{
|
||||
"DockedWidth": 200,
|
||||
"SelectedChildIndex": 0,
|
||||
"SelectedChildIndex": 1,
|
||||
"Children": [
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 1,
|
||||
"Title": "Doboz.cs",
|
||||
"DocumentMoniker": "C:\\Users\\szabomarton\\Desktop\\Verseny\\fordulo_3\\Program\\Doboz.cs",
|
||||
"RelativeDocumentMoniker": "Doboz.cs",
|
||||
"ToolTip": "C:\\Users\\szabomarton\\Desktop\\Verseny\\fordulo_3\\Program\\Doboz.cs",
|
||||
"RelativeToolTip": "Doboz.cs",
|
||||
"ViewState": "AgIAAAAAAAAAAAAAAAAAABgAAAAJAAAAAAAAAA==",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
||||
"WhenOpened": "2025-03-14T09:40:24.572Z",
|
||||
"EditorCaption": ""
|
||||
},
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 0,
|
||||
|
@ -28,23 +41,10 @@
|
|||
"RelativeDocumentMoniker": "Program.cs",
|
||||
"ToolTip": "C:\\Users\\szabomarton\\Desktop\\Verseny\\fordulo_3\\Program\\Program.cs",
|
||||
"RelativeToolTip": "Program.cs",
|
||||
"ViewState": "AgIAAGgAAAAAAAAAAAAwwHsAAAAkAAAAAAAAAA==",
|
||||
"ViewState": "AgIAAAAAAAAAAAAAAAAiwBIAAAANAAAAAAAAAA==",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
||||
"WhenOpened": "2025-03-12T12:54:16.847Z",
|
||||
"EditorCaption": ""
|
||||
},
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 1,
|
||||
"Title": "Virus.cs",
|
||||
"DocumentMoniker": "C:\\Users\\szabomarton\\Desktop\\Verseny\\fordulo_3\\Program\\Virus.cs",
|
||||
"RelativeDocumentMoniker": "Virus.cs",
|
||||
"ToolTip": "C:\\Users\\szabomarton\\Desktop\\Verseny\\fordulo_3\\Program\\Virus.cs",
|
||||
"RelativeToolTip": "Virus.cs",
|
||||
"ViewState": "AgIAACMAAAAAAAAAAAAIwDAAAAAJAAAAAAAAAA==",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
||||
"WhenOpened": "2025-03-13T16:14:18.948Z",
|
||||
"EditorCaption": ""
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
"RelativeMoniker": "D:0:0:{6A74A9DE-500D-46FF-859A-18F4A752D2A5}|Program.csproj|solutionrelative:program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
|
||||
},
|
||||
{
|
||||
"AbsoluteMoniker": "D:0:0:{6A74A9DE-500D-46FF-859A-18F4A752D2A5}|Program.csproj|C:\\Users\\szabomarton\\Desktop\\Verseny\\fordulo_3\\Program\\virus.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
|
||||
"RelativeMoniker": "D:0:0:{6A74A9DE-500D-46FF-859A-18F4A752D2A5}|Program.csproj|solutionrelative:virus.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
|
||||
"AbsoluteMoniker": "D:0:0:{6A74A9DE-500D-46FF-859A-18F4A752D2A5}|Program.csproj|c:\\users\\szabomarton\\desktop\\verseny\\fordulo_3\\program\\doboz.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
|
||||
"RelativeMoniker": "D:0:0:{6A74A9DE-500D-46FF-859A-18F4A752D2A5}|Program.csproj|solutionrelative:doboz.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
|
||||
}
|
||||
],
|
||||
"DocumentGroupContainers": [
|
||||
|
@ -18,8 +18,21 @@
|
|||
"DocumentGroups": [
|
||||
{
|
||||
"DockedWidth": 200,
|
||||
"SelectedChildIndex": 0,
|
||||
"SelectedChildIndex": 1,
|
||||
"Children": [
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 1,
|
||||
"Title": "Doboz.cs",
|
||||
"DocumentMoniker": "C:\\Users\\szabomarton\\Desktop\\Verseny\\fordulo_3\\Program\\Doboz.cs",
|
||||
"RelativeDocumentMoniker": "Doboz.cs",
|
||||
"ToolTip": "C:\\Users\\szabomarton\\Desktop\\Verseny\\fordulo_3\\Program\\Doboz.cs",
|
||||
"RelativeToolTip": "Doboz.cs",
|
||||
"ViewState": "AgIAAAAAAAAAAAAAAAAAABgAAAAJAAAAAAAAAA==",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
||||
"WhenOpened": "2025-03-14T09:40:24.572Z",
|
||||
"EditorCaption": ""
|
||||
},
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 0,
|
||||
|
@ -28,23 +41,10 @@
|
|||
"RelativeDocumentMoniker": "Program.cs",
|
||||
"ToolTip": "C:\\Users\\szabomarton\\Desktop\\Verseny\\fordulo_3\\Program\\Program.cs",
|
||||
"RelativeToolTip": "Program.cs",
|
||||
"ViewState": "AgIAAGgAAAAAAAAAAAAwwHsAAAAkAAAAAAAAAA==",
|
||||
"ViewState": "AgIAAAMAAAAAAAAAAAAiwBUAAAAJAAAAAAAAAA==",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
||||
"WhenOpened": "2025-03-12T12:54:16.847Z",
|
||||
"EditorCaption": ""
|
||||
},
|
||||
{
|
||||
"$type": "Document",
|
||||
"DocumentIndex": 1,
|
||||
"Title": "Virus.cs",
|
||||
"DocumentMoniker": "C:\\Users\\szabomarton\\Desktop\\Verseny\\fordulo_3\\Program\\Virus.cs",
|
||||
"RelativeDocumentMoniker": "Virus.cs",
|
||||
"ToolTip": "C:\\Users\\szabomarton\\Desktop\\Verseny\\fordulo_3\\Program\\Virus.cs",
|
||||
"RelativeToolTip": "Virus.cs",
|
||||
"ViewState": "AgIAACMAAAAAAAAAAAAIwDAAAAAJAAAAAAAAAA==",
|
||||
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
||||
"WhenOpened": "2025-03-13T16:14:18.948Z",
|
||||
"EditorCaption": ""
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
27
fordulo_3/Program/Doboz.cs
Normal file
27
fordulo_3/Program/Doboz.cs
Normal file
|
@ -0,0 +1,27 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Program
|
||||
{
|
||||
internal class Doboz
|
||||
{
|
||||
public string Type { get; set; }
|
||||
|
||||
public Doboz Children = null;
|
||||
|
||||
public Doboz Parent = null;
|
||||
|
||||
public Doboz(string Type) {
|
||||
this.Type = Type;
|
||||
}
|
||||
|
||||
public void AddChildren(Doboz doboz)
|
||||
{
|
||||
doboz.Parent = this;
|
||||
this.Children = doboz;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -9,235 +9,17 @@ namespace Program
|
|||
{
|
||||
class Program
|
||||
{
|
||||
public static Dictionary<int, List<int>> Contacts = new Dictionary<int, List<int>>();
|
||||
public static HashSet<int> InfectedPeople = new HashSet<int>();
|
||||
public static List<int> uniquePeople = new List<int>();
|
||||
public static HashSet<int> NewInfectedPeople = new HashSet<int>();
|
||||
|
||||
public static List<Doboz> Boxes = new List<Doboz>();
|
||||
static void Main(string[] args)
|
||||
{
|
||||
Previous();
|
||||
}
|
||||
string path = "../../../forrasok/dobozok.txt";
|
||||
var AllBoxes = File.ReadAllText(path).ToCharArray();
|
||||
|
||||
public static void ListAllInfectionTreeVoid()
|
||||
{
|
||||
string path = $@"../../../forrasok/elek.txt";
|
||||
|
||||
var data = File.ReadAllLines(path);
|
||||
|
||||
foreach (var item in data)
|
||||
foreach (var item in AllBoxes)
|
||||
{
|
||||
string[] nums = item.Split(' ');
|
||||
int infector = Convert.ToInt32(nums[0]);
|
||||
int infected = Convert.ToInt32(nums[1]);
|
||||
|
||||
if (!uniquePeople.Contains(infector))
|
||||
{
|
||||
uniquePeople.Add(infector);
|
||||
}
|
||||
|
||||
if (!uniquePeople.Contains(infected))
|
||||
{
|
||||
uniquePeople.Add(infected);
|
||||
}
|
||||
|
||||
if (Contacts.ContainsKey(infector))
|
||||
{
|
||||
Contacts[infector].Add(infected);
|
||||
}
|
||||
else
|
||||
{
|
||||
Contacts[infector] = new List<int> { infected };
|
||||
}
|
||||
}
|
||||
|
||||
InfectedPeople.Clear(); // Clear the set before starting the spread
|
||||
|
||||
int infectionTreeCount = 0;
|
||||
|
||||
// Spread the virus starting from each unique person if they are not already infected
|
||||
foreach (var person in uniquePeople)
|
||||
{
|
||||
if (!InfectedPeople.Contains(person))
|
||||
{
|
||||
infectionTreeCount++;
|
||||
Virus rootVirus = new Virus(person);
|
||||
InfectedPeople.Add(person); // Add the root virus to the infected set
|
||||
SpreadBFS(rootVirus, int.MaxValue); // Spread without depth limit
|
||||
}
|
||||
}
|
||||
|
||||
Console.WriteLine($"Infected people count: {InfectedPeople.Count}");
|
||||
Console.WriteLine($"Unique people count: {uniquePeople.Count}");
|
||||
Console.WriteLine($"Number of infection trees: {infectionTreeCount}");
|
||||
|
||||
// Verify if all unique people are infected
|
||||
bool allInfected = uniquePeople.All(person => InfectedPeople.Contains(person));
|
||||
Console.WriteLine($"All unique people infected: {allInfected}");
|
||||
|
||||
if (!allInfected)
|
||||
{
|
||||
var notInfected = uniquePeople.Where(person => !InfectedPeople.Contains(person)).ToList();
|
||||
Console.WriteLine("People not infected:");
|
||||
foreach (var person in notInfected)
|
||||
{
|
||||
Console.WriteLine(person);
|
||||
}
|
||||
Console.WriteLine(item);
|
||||
}
|
||||
}
|
||||
|
||||
public static void Previous()
|
||||
{
|
||||
string path = $@"../../../forrasok/elek.txt";
|
||||
|
||||
var data = File.ReadAllLines(path);
|
||||
|
||||
foreach (var item in data)
|
||||
{
|
||||
string[] nums = item.Split(' ');
|
||||
int infector = Convert.ToInt32(nums[0]);
|
||||
int infected = Convert.ToInt32(nums[1]);
|
||||
|
||||
if (!uniquePeople.Contains(infector))
|
||||
{
|
||||
uniquePeople.Add(infector);
|
||||
}
|
||||
|
||||
if (!uniquePeople.Contains(infected))
|
||||
{
|
||||
uniquePeople.Add(infected);
|
||||
}
|
||||
|
||||
if (Contacts.ContainsKey(infector))
|
||||
{
|
||||
Contacts[infector].Add(infected);
|
||||
}
|
||||
else
|
||||
{
|
||||
Contacts[infector] = new List<int> { infected };
|
||||
}
|
||||
}
|
||||
|
||||
Virus rootVirus = new Virus(2);
|
||||
InfectedPeople.Clear(); // Clear the set before starting the spread
|
||||
InfectedPeople.Add(2); // Add the root virus to the infected set
|
||||
SpreadBFS(rootVirus, 5);
|
||||
//Spread(rootVirus, 15);
|
||||
|
||||
//rootVirus.PrintInfectionTreeWithDepth(2, 0, "->");
|
||||
rootVirus.PrintInfectionTree();
|
||||
|
||||
Console.WriteLine(InfectedPeople.Count);
|
||||
Console.WriteLine(rootVirus.CountInfectedInDepthRange(3, 10));
|
||||
|
||||
Console.WriteLine($"Infected people count: {InfectedPeople.Count}");
|
||||
Console.WriteLine($"Unique people count: {uniquePeople.Count}");
|
||||
|
||||
// Verify if all unique people are infected
|
||||
bool allInfected = uniquePeople.All(person => InfectedPeople.Contains(person));
|
||||
Console.WriteLine($"All unique people infected: {allInfected}");
|
||||
|
||||
if (!allInfected)
|
||||
{
|
||||
var notInfected = uniquePeople.Where(person => !InfectedPeople.Contains(person)).ToList();
|
||||
Console.WriteLine("People not infected:");
|
||||
foreach (var person in notInfected)
|
||||
{
|
||||
Console.WriteLine(person);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Virus rootVirus2 = new Virus(2);
|
||||
int count = 0;
|
||||
while (NewInfectedPeople.Count != uniquePeople.Count)
|
||||
{
|
||||
count++;
|
||||
SpreadBFS(rootVirus2, count);
|
||||
}
|
||||
|
||||
Console.WriteLine(count);
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
public static void SpreadBFS(Virus rootVirus, int maxDepth)
|
||||
{
|
||||
Queue<(Virus virus, int depth)> queue = new Queue<(Virus virus, int depth)>();
|
||||
queue.Enqueue((rootVirus, 0));
|
||||
|
||||
while (queue.Count > 0)
|
||||
{
|
||||
var (currentVirus, currentDepth) = queue.Dequeue();
|
||||
|
||||
if (currentDepth >= maxDepth)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (Contacts.ContainsKey(currentVirus.Name))
|
||||
{
|
||||
foreach (var contact in Contacts[currentVirus.Name])
|
||||
{
|
||||
if (!InfectedPeople.Contains(contact))
|
||||
{
|
||||
Virus newInfected = new Virus(contact, currentDepth + 1);
|
||||
currentVirus.Infect(newInfected);
|
||||
InfectedPeople.Add(contact); // Mark as infected
|
||||
queue.Enqueue((newInfected, currentDepth + 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void Spread(Virus virus, int maxDepth, int currentDepth = 0)
|
||||
{
|
||||
if (currentDepth >= maxDepth)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (Contacts.ContainsKey(virus.Name))
|
||||
{
|
||||
foreach (var contact in Contacts[virus.Name])
|
||||
{
|
||||
if (!InfectedPeople.Contains(contact))
|
||||
{
|
||||
Virus newInfected = new Virus(contact);
|
||||
virus.Infect(newInfected);
|
||||
InfectedPeople.Add(contact); // Mark as infected
|
||||
Spread(newInfected, maxDepth, currentDepth + 1);
|
||||
} else
|
||||
{
|
||||
Virus newInfected = new Virus(contact);
|
||||
virus.Infect(newInfected);
|
||||
//InfectedPeople.Add(contact); // Mark as infected
|
||||
Spread(newInfected, maxDepth, currentDepth + 1);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
public static void Spread(Virus virus)
|
||||
{
|
||||
if (Contacts.ContainsKey(virus.Name))
|
||||
{
|
||||
foreach (var contact in Contacts[virus.Name])
|
||||
{
|
||||
if (!InfectedPeople.Contains(contact))
|
||||
{
|
||||
Virus newInfected = new Virus(contact);
|
||||
virus.Infect(newInfected);
|
||||
InfectedPeople.Add(contact); // Mark as infected
|
||||
Spread(newInfected);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
|
@ -43,12 +43,14 @@
|
|||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Doboz.cs" />
|
||||
<Compile Include="Feladat3.cs" />
|
||||
<Compile Include="PermutationGenerator.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Sorozat.cs" />
|
||||
<Compile Include="Virus.cs" />
|
||||
<Compile Include="VirusVoid.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
|
|
238
fordulo_3/Program/VirusVoid.cs
Normal file
238
fordulo_3/Program/VirusVoid.cs
Normal file
|
@ -0,0 +1,238 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Program
|
||||
{
|
||||
internal class VirusVoid
|
||||
{
|
||||
public static Dictionary<int, List<int>> Contacts = new Dictionary<int, List<int>>();
|
||||
public static HashSet<int> InfectedPeople = new HashSet<int>();
|
||||
public static List<int> uniquePeople = new List<int>();
|
||||
public static HashSet<int> NewInfectedPeople = new HashSet<int>();
|
||||
|
||||
public static void ListAllInfectionTreeVoid()
|
||||
{
|
||||
string path = $@"../../../forrasok/elek.txt";
|
||||
|
||||
var data = File.ReadAllLines(path);
|
||||
|
||||
foreach (var item in data)
|
||||
{
|
||||
string[] nums = item.Split(' ');
|
||||
int infector = Convert.ToInt32(nums[0]);
|
||||
int infected = Convert.ToInt32(nums[1]);
|
||||
|
||||
if (!uniquePeople.Contains(infector))
|
||||
{
|
||||
uniquePeople.Add(infector);
|
||||
}
|
||||
|
||||
if (!uniquePeople.Contains(infected))
|
||||
{
|
||||
uniquePeople.Add(infected);
|
||||
}
|
||||
|
||||
if (Contacts.ContainsKey(infector))
|
||||
{
|
||||
Contacts[infector].Add(infected);
|
||||
}
|
||||
else
|
||||
{
|
||||
Contacts[infector] = new List<int> { infected };
|
||||
}
|
||||
}
|
||||
|
||||
InfectedPeople.Clear(); // Clear the set before starting the spread
|
||||
|
||||
int infectionTreeCount = 0;
|
||||
|
||||
// Spread the virus starting from each unique person if they are not already infected
|
||||
foreach (var person in uniquePeople)
|
||||
{
|
||||
if (!InfectedPeople.Contains(person))
|
||||
{
|
||||
infectionTreeCount++;
|
||||
Virus rootVirus = new Virus(person);
|
||||
InfectedPeople.Add(person); // Add the root virus to the infected set
|
||||
SpreadBFS(rootVirus, int.MaxValue); // Spread without depth limit
|
||||
}
|
||||
}
|
||||
|
||||
Console.WriteLine($"Infected people count: {InfectedPeople.Count}");
|
||||
Console.WriteLine($"Unique people count: {uniquePeople.Count}");
|
||||
Console.WriteLine($"Number of infection trees: {infectionTreeCount}");
|
||||
|
||||
// Verify if all unique people are infected
|
||||
bool allInfected = uniquePeople.All(person => InfectedPeople.Contains(person));
|
||||
Console.WriteLine($"All unique people infected: {allInfected}");
|
||||
|
||||
if (!allInfected)
|
||||
{
|
||||
var notInfected = uniquePeople.Where(person => !InfectedPeople.Contains(person)).ToList();
|
||||
Console.WriteLine("People not infected:");
|
||||
foreach (var person in notInfected)
|
||||
{
|
||||
Console.WriteLine(person);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void Previous()
|
||||
{
|
||||
string path = $@"../../../forrasok/elek.txt";
|
||||
|
||||
var data = File.ReadAllLines(path);
|
||||
|
||||
foreach (var item in data)
|
||||
{
|
||||
string[] nums = item.Split(' ');
|
||||
int infector = Convert.ToInt32(nums[0]);
|
||||
int infected = Convert.ToInt32(nums[1]);
|
||||
|
||||
if (!uniquePeople.Contains(infector))
|
||||
{
|
||||
uniquePeople.Add(infector);
|
||||
}
|
||||
|
||||
if (!uniquePeople.Contains(infected))
|
||||
{
|
||||
uniquePeople.Add(infected);
|
||||
}
|
||||
|
||||
if (Contacts.ContainsKey(infector))
|
||||
{
|
||||
Contacts[infector].Add(infected);
|
||||
}
|
||||
else
|
||||
{
|
||||
Contacts[infector] = new List<int> { infected };
|
||||
}
|
||||
}
|
||||
|
||||
Virus rootVirus = new Virus(2);
|
||||
InfectedPeople.Clear(); // Clear the set before starting the spread
|
||||
InfectedPeople.Add(2); // Add the root virus to the infected set
|
||||
SpreadBFS(rootVirus, 5);
|
||||
//Spread(rootVirus, 15);
|
||||
|
||||
//rootVirus.PrintInfectionTreeWithDepth(2, 0, "->");
|
||||
rootVirus.PrintInfectionTree();
|
||||
|
||||
Console.WriteLine(InfectedPeople.Count);
|
||||
Console.WriteLine(rootVirus.CountInfectedInDepthRange(3, 10));
|
||||
|
||||
Console.WriteLine($"Infected people count: {InfectedPeople.Count}");
|
||||
Console.WriteLine($"Unique people count: {uniquePeople.Count}");
|
||||
|
||||
// Verify if all unique people are infected
|
||||
bool allInfected = uniquePeople.All(person => InfectedPeople.Contains(person));
|
||||
Console.WriteLine($"All unique people infected: {allInfected}");
|
||||
|
||||
if (!allInfected)
|
||||
{
|
||||
var notInfected = uniquePeople.Where(person => !InfectedPeople.Contains(person)).ToList();
|
||||
Console.WriteLine("People not infected:");
|
||||
foreach (var person in notInfected)
|
||||
{
|
||||
Console.WriteLine(person);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Virus rootVirus2 = new Virus(2);
|
||||
int count = 0;
|
||||
while (NewInfectedPeople.Count != uniquePeople.Count)
|
||||
{
|
||||
count++;
|
||||
SpreadBFS(rootVirus2, count);
|
||||
}
|
||||
|
||||
Console.WriteLine(count);
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
public static void SpreadBFS(Virus rootVirus, int maxDepth)
|
||||
{
|
||||
Queue<(Virus virus, int depth)> queue = new Queue<(Virus virus, int depth)>();
|
||||
queue.Enqueue((rootVirus, 0));
|
||||
|
||||
while (queue.Count > 0)
|
||||
{
|
||||
var (currentVirus, currentDepth) = queue.Dequeue();
|
||||
|
||||
if (currentDepth >= maxDepth)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (Contacts.ContainsKey(currentVirus.Name))
|
||||
{
|
||||
foreach (var contact in Contacts[currentVirus.Name])
|
||||
{
|
||||
if (!InfectedPeople.Contains(contact))
|
||||
{
|
||||
Virus newInfected = new Virus(contact, currentDepth + 1);
|
||||
currentVirus.Infect(newInfected);
|
||||
InfectedPeople.Add(contact); // Mark as infected
|
||||
queue.Enqueue((newInfected, currentDepth + 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void Spread(Virus virus, int maxDepth, int currentDepth = 0)
|
||||
{
|
||||
if (currentDepth >= maxDepth)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (Contacts.ContainsKey(virus.Name))
|
||||
{
|
||||
foreach (var contact in Contacts[virus.Name])
|
||||
{
|
||||
if (!InfectedPeople.Contains(contact))
|
||||
{
|
||||
Virus newInfected = new Virus(contact);
|
||||
virus.Infect(newInfected);
|
||||
InfectedPeople.Add(contact); // Mark as infected
|
||||
Spread(newInfected, maxDepth, currentDepth + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
Virus newInfected = new Virus(contact);
|
||||
virus.Infect(newInfected);
|
||||
//InfectedPeople.Add(contact); // Mark as infected
|
||||
Spread(newInfected, maxDepth, currentDepth + 1);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
public static void Spread(Virus virus)
|
||||
{
|
||||
if (Contacts.ContainsKey(virus.Name))
|
||||
{
|
||||
foreach (var contact in Contacts[virus.Name])
|
||||
{
|
||||
if (!InfectedPeople.Contains(contact))
|
||||
{
|
||||
Virus newInfected = new Virus(contact);
|
||||
virus.Infect(newInfected);
|
||||
InfectedPeople.Add(contact); // Mark as infected
|
||||
Spread(newInfected);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1 +1 @@
|
|||
ca659b73ef474311d403419aa47bed331b1360853dc02e88fb5dee915c0be9c6
|
||||
611de47925482b3022c54ee32b86e16f94cb14b3b3a22688b17216ae104f5a1b
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
1
fordulo_3/forrasok/dobozok.txt
Normal file
1
fordulo_3/forrasok/dobozok.txt
Normal file
|
@ -0,0 +1 @@
|
|||
ACAABCBAAAABBACABBBBBCBBBABCBCBCAABBCBBAACCBBCCBCABCCCCCCBAABBBCAAACABACBABABCBCBCACCBABBCBCCBCAACAACBBCBABBBBAABBACCABABACCCAABCCAAABCABAACBAACCCBAABCCBABACBBBBBBBABBAAAABAACCCCACACBBCBCBAAACACABABABCBBAAAAAAACABCCBAAAACCBAAAABABABCACBBCBBBACBBAABCABBCBACCCCBAABCBAABABBACAAABBAAABACCABACBCCACABBCAACCCBACBACCABBAACBCCBCACBCCCCCBCBCCACAACACCBCCCBBBABCACAABCAAABCCABAABCABBCCACCCACACAAAACBAACCAABACBCAACAAABCAABCCBCACCBABCCBABAAACCCCAAACCCBACBBCCCCBBCCBAAABBCAACBCBBAABBAAABCBACAC
|
Loading…
Reference in New Issue
Block a user