added things

This commit is contained in:
szabomarton 2025-03-14 10:51:00 +01:00
parent 4287c44e6e
commit 1ebc6c67b6
36 changed files with 314 additions and 267 deletions

Binary file not shown.

Binary file not shown.

View File

@ -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")]

View File

@ -1 +1 @@
fa1dd1337108d86b90c993aeca956532f3929d3df42ce60dbfe44b7b4331a5d0
0333c6b72ecbcd6537212ba37ec65dec7fbdb8cf3657fb71804dfbce72d26bf4

View File

@ -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 =

View File

@ -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")]

View File

@ -1 +1 @@
f906cfd11295328e105ea96075df17757f03b97601f6554b3ba2d5440a6c9a31
78c22c4c5f0bf656b7c6ac2e8f670a7dafc6607757ed8135e1f2f0ecdd3d32a2

View File

@ -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 =

View 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":[]}

View File

@ -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": ""
}
]
}

View File

@ -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": ""
}
]
}

View 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;
}
}
}

View File

@ -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);
}
}
}
}
*/
}
}

View File

@ -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" />

View 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);
}
}
}
}
*/
}
}

View File

@ -1 +1 @@
ca659b73ef474311d403419aa47bed331b1360853dc02e88fb5dee915c0be9c6
611de47925482b3022c54ee32b86e16f94cb14b3b3a22688b17216ae104f5a1b

View File

@ -0,0 +1 @@
ACAABCBAAAABBACABBBBBCBBBABCBCBCAABBCBBAACCBBCCBCABCCCCCCBAABBBCAAACABACBABABCBCBCACCBABBCBCCBCAACAACBBCBABBBBAABBACCABABACCCAABCCAAABCABAACBAACCCBAABCCBABACBBBBBBBABBAAAABAACCCCACACBBCBCBAAACACABABABCBBAAAAAAACABCCBAAAACCBAAAABABABCACBBCBBBACBBAABCABBCBACCCCBAABCBAABABBACAAABBAAABACCABACBCCACABBCAACCCBACBACCABBAACBCCBCACBCCCCCBCBCCACAACACCBCCCBBBABCACAABCAAABCCABAABCABBCCACCCACACAAAACBAACCAABACBCAACAAABCAABCCBCACCBABCCBABAAACCCCAAACCCBACBBCCCCBBCCBAAABBCAACBCBBAABBAAABCBACAC