Init
This commit is contained in:
parent
2ee35246a7
commit
07930ec470
387
.gitignore
vendored
Normal file
387
.gitignore
vendored
Normal file
@ -0,0 +1,387 @@
|
||||
## Ignore Visual Studio temporary files, build results, and
|
||||
## files generated by popular Visual Studio add-ons.
|
||||
##
|
||||
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
|
||||
|
||||
# User-specific files
|
||||
*.suo
|
||||
*.user
|
||||
*.userosscache
|
||||
*.sln.docstates
|
||||
|
||||
# User-specific files (MonoDevelop/Xamarin Studio)
|
||||
*.userprefs
|
||||
|
||||
# Tools pulled down during build
|
||||
.tools/
|
||||
.dotnet/
|
||||
.packages/
|
||||
|
||||
# Build results
|
||||
[Dd]ebug/
|
||||
[Dd]ebugPublic/
|
||||
[Rr]elease/
|
||||
[Rr]eleases/
|
||||
x64/
|
||||
x86/
|
||||
bld/
|
||||
[Bb]in/
|
||||
[Oo]bj/
|
||||
[Ll]og/
|
||||
|
||||
# Visual Studio cache/options directory
|
||||
.vs/
|
||||
.vscode/
|
||||
|
||||
# Uncomment if you have tasks that create the project's static files in wwwroot
|
||||
#wwwroot/
|
||||
|
||||
# Visual Studio 2017 auto generated files
|
||||
Generated\ Files/
|
||||
|
||||
# MSTest test Results
|
||||
[Tt]est[Rr]esult*/
|
||||
[Bb]uild[Ll]og.*
|
||||
|
||||
# NUNIT
|
||||
*.VisualState.xml
|
||||
TestResult.xml
|
||||
|
||||
# Build Results of an ATL Project
|
||||
[Dd]ebugPS/
|
||||
[Rr]eleasePS/
|
||||
dlldata.c
|
||||
|
||||
# Benchmark Results
|
||||
BenchmarkDotNet.Artifacts/
|
||||
|
||||
# .NET Core
|
||||
project.lock.json
|
||||
project.fragment.lock.json
|
||||
artifacts/
|
||||
.dotnet/
|
||||
|
||||
# StyleCop
|
||||
StyleCopReport.xml
|
||||
|
||||
# Files built by Visual Studio
|
||||
*_i.c
|
||||
*_p.c
|
||||
*_i.h
|
||||
*.ilk
|
||||
*.meta
|
||||
*.obj
|
||||
*.iobj
|
||||
*.pch
|
||||
*.pdb
|
||||
*.ipdb
|
||||
*.pgc
|
||||
*.pgd
|
||||
*.rsp
|
||||
*.sbr
|
||||
*.tlb
|
||||
*.tli
|
||||
*.tlh
|
||||
*.tmp
|
||||
*.tmp_proj
|
||||
*.log
|
||||
*.vspscc
|
||||
*.vssscc
|
||||
.builds
|
||||
*.pidb
|
||||
*.svclog
|
||||
*.scc
|
||||
|
||||
# Chutzpah Test files
|
||||
_Chutzpah*
|
||||
|
||||
# Visual C++ cache files
|
||||
ipch/
|
||||
*.aps
|
||||
*.ncb
|
||||
*.opendb
|
||||
*.opensdf
|
||||
*.sdf
|
||||
*.cachefile
|
||||
*.VC.db
|
||||
*.VC.VC.opendb
|
||||
|
||||
# Visual Studio profiler
|
||||
*.psess
|
||||
*.vsp
|
||||
*.vspx
|
||||
*.sap
|
||||
|
||||
# Visual Studio Trace Files
|
||||
*.e2e
|
||||
|
||||
# TFS 2012 Local Workspace
|
||||
$tf/
|
||||
|
||||
# Guidance Automation Toolkit
|
||||
*.gpState
|
||||
|
||||
# ReSharper is a .NET coding add-in
|
||||
_ReSharper*/
|
||||
*.[Rr]e[Ss]harper
|
||||
*.DotSettings.user
|
||||
|
||||
# JustCode is a .NET coding add-in
|
||||
.JustCode
|
||||
|
||||
# TeamCity is a build add-in
|
||||
_TeamCity*
|
||||
|
||||
# DotCover is a Code Coverage Tool
|
||||
*.dotCover
|
||||
|
||||
# AxoCover is a Code Coverage Tool
|
||||
.axoCover/*
|
||||
!.axoCover/settings.json
|
||||
|
||||
# Visual Studio code coverage results
|
||||
*.coverage
|
||||
*.coveragexml
|
||||
|
||||
# Visual Studio Code
|
||||
.vscode/*
|
||||
!.vscode/settings.json
|
||||
!.vscode/tasks.json
|
||||
!.vscode/launch.json
|
||||
!.vscode/extensions.json
|
||||
|
||||
# NCrunch
|
||||
_NCrunch_*
|
||||
.*crunch*.local.xml
|
||||
nCrunchTemp_*
|
||||
|
||||
# MightyMoose
|
||||
*.mm.*
|
||||
AutoTest.Net/
|
||||
|
||||
# Web workbench (sass)
|
||||
.sass-cache/
|
||||
|
||||
# Installshield output folder
|
||||
[Ee]xpress/
|
||||
|
||||
# DocProject is a documentation generator add-in
|
||||
DocProject/buildhelp/
|
||||
DocProject/Help/*.HxT
|
||||
DocProject/Help/*.HxC
|
||||
DocProject/Help/*.hhc
|
||||
DocProject/Help/*.hhk
|
||||
DocProject/Help/*.hhp
|
||||
DocProject/Help/Html2
|
||||
DocProject/Help/html
|
||||
|
||||
# Click-Once directory
|
||||
publish/
|
||||
|
||||
# Publish Web Output
|
||||
*.[Pp]ublish.xml
|
||||
*.azurePubxml
|
||||
# Note: Comment the next line if you want to checkin your web deploy settings,
|
||||
# but database connection strings (with potential passwords) will be unencrypted
|
||||
*.pubxml
|
||||
*.publishproj
|
||||
|
||||
# Microsoft Azure Web App publish settings. Comment the next line if you want to
|
||||
# checkin your Azure Web App publish settings, but sensitive information contained
|
||||
# in these scripts will be unencrypted
|
||||
PublishScripts/
|
||||
|
||||
# NuGet Packages
|
||||
*.nupkg
|
||||
# The packages folder can be ignored because of Package Restore
|
||||
**/[Pp]ackages/*
|
||||
# except build/, which is used as an MSBuild target.
|
||||
!**/[Pp]ackages/build/
|
||||
# Uncomment if necessary however generally it will be regenerated when needed
|
||||
#!**/[Pp]ackages/repositories.config
|
||||
# NuGet v3's project.json files produces more ignorable files
|
||||
*.nuget.props
|
||||
*.nuget.targets
|
||||
|
||||
# Microsoft Azure Build Output
|
||||
csx/
|
||||
*.build.csdef
|
||||
|
||||
# Microsoft Azure Emulator
|
||||
ecf/
|
||||
rcf/
|
||||
|
||||
# Windows Store app package directories and files
|
||||
AppPackages/
|
||||
BundleArtifacts/
|
||||
Package.StoreAssociation.xml
|
||||
_pkginfo.txt
|
||||
*.appx
|
||||
|
||||
# Visual Studio cache files
|
||||
# files ending in .cache can be ignored
|
||||
*.[Cc]ache
|
||||
# but keep track of directories ending in .cache
|
||||
!*.[Cc]ache/
|
||||
|
||||
# Windows image file caches
|
||||
**/Thumbs.db
|
||||
|
||||
# Others
|
||||
ClientBin/
|
||||
~$*
|
||||
*~
|
||||
*.dbmdl
|
||||
*.dbproj.schemaview
|
||||
*.jfm
|
||||
*.pfx
|
||||
*.publishsettings
|
||||
orleans.codegen.cs
|
||||
|
||||
# Including strong name files can present a security risk
|
||||
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
|
||||
#*.snk
|
||||
|
||||
# Since there are multiple workflows, uncomment next line to ignore bower_components
|
||||
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
|
||||
#bower_components/
|
||||
|
||||
# RIA/Silverlight projects
|
||||
Generated_Code/
|
||||
|
||||
# Backup & report files from converting an old project file
|
||||
# to a newer Visual Studio version. Backup files are not needed,
|
||||
# because we have git ;-)
|
||||
_UpgradeReport_Files/
|
||||
Backup*/
|
||||
UpgradeLog*.XML
|
||||
UpgradeLog*.htm
|
||||
ServiceFabricBackup/
|
||||
*.rptproj.bak
|
||||
|
||||
# SQL Server files
|
||||
*.mdf
|
||||
*.ldf
|
||||
*.ndf
|
||||
|
||||
# Business Intelligence projects
|
||||
*.rdl.data
|
||||
*.bim.layout
|
||||
*.bim_*.settings
|
||||
*.rptproj.rsuser
|
||||
|
||||
# Microsoft Fakes
|
||||
FakesAssemblies/
|
||||
|
||||
# GhostDoc plugin setting file
|
||||
*.GhostDoc.xml
|
||||
|
||||
# Node.js Tools for Visual Studio
|
||||
.ntvs_analysis.dat
|
||||
node_modules/
|
||||
|
||||
# Visual Studio 6 build log
|
||||
*.plg
|
||||
|
||||
# Visual Studio 6 workspace options file
|
||||
*.opt
|
||||
|
||||
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
|
||||
*.vbw
|
||||
|
||||
# Visual Studio LightSwitch build output
|
||||
**/*.HTMLClient/GeneratedArtifacts
|
||||
**/*.DesktopClient/GeneratedArtifacts
|
||||
**/*.DesktopClient/ModelManifest.xml
|
||||
**/*.Server/GeneratedArtifacts
|
||||
**/*.Server/ModelManifest.xml
|
||||
_Pvt_Extensions
|
||||
|
||||
# Paket dependency manager
|
||||
.paket/paket.exe
|
||||
paket-files/
|
||||
|
||||
# FAKE - F# Make
|
||||
.fake/
|
||||
|
||||
# JetBrains Rider
|
||||
.idea/
|
||||
*.sln.iml
|
||||
|
||||
# CodeRush
|
||||
.cr/
|
||||
|
||||
# Python Tools for Visual Studio (PTVS)
|
||||
__pycache__/
|
||||
*.pyc
|
||||
|
||||
# Cake - Uncomment if you are using it
|
||||
# tools/**
|
||||
# !tools/packages.config
|
||||
|
||||
# Tabs Studio
|
||||
*.tss
|
||||
|
||||
# Telerik's JustMock configuration file
|
||||
*.jmconfig
|
||||
|
||||
# BizTalk build output
|
||||
*.btp.cs
|
||||
*.btm.cs
|
||||
*.odx.cs
|
||||
*.xsd.cs
|
||||
|
||||
# OpenCover UI analysis results
|
||||
OpenCover/
|
||||
|
||||
# Azure Stream Analytics local run output
|
||||
ASALocalRun/
|
||||
|
||||
# MSBuild Binary and Structured Log
|
||||
*.binlog
|
||||
|
||||
# NVidia Nsight GPU debugger configuration file
|
||||
*.nvuser
|
||||
|
||||
# MFractors (Xamarin productivity tool) working folder
|
||||
.mfractor/
|
||||
|
||||
### OSX ###
|
||||
|
||||
# General
|
||||
.DS_Store
|
||||
.AppleDouble
|
||||
.LSOverride
|
||||
|
||||
# Icon must end with two \r
|
||||
Icon
|
||||
|
||||
|
||||
# Thumbnails
|
||||
._*
|
||||
|
||||
# Files that might appear in the root of a volume
|
||||
.DocumentRevisions-V100
|
||||
.fseventsd
|
||||
.Spotlight-V100
|
||||
.TemporaryItems
|
||||
.Trashes
|
||||
.VolumeIcon.icns
|
||||
.com.apple.timemachine.donotpresent
|
||||
|
||||
# Directories potentially created on remote AFP share
|
||||
.AppleDB
|
||||
.AppleDesktop
|
||||
Network Trash Folder
|
||||
Temporary Items
|
||||
.apdisk
|
||||
|
||||
# Ignore "InteropTests/NativeTests/out"
|
||||
InteropTests/NativeTests/out
|
||||
/src/System.Windows.Forms/src/comctl32.dll
|
||||
*.received.*
|
||||
|
||||
# Normally do not want to pick up changes in the scratch project, this will ignore files that aren't already tracked.
|
||||
# 'git update-index --assume-unchanged <filename>' will allow ignoring changes for tracked files.
|
||||
**/ScratchProject/
|
||||
**/ScratchProjectWithInternals/
|
25
BoykoSolution.sln
Normal file
25
BoykoSolution.sln
Normal file
@ -0,0 +1,25 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.9.34728.123
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cursach", "Cursach\Cursach.csproj", "{A0B30F2B-DF15-4F82-9D0A-FD0B34553E5D}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{A0B30F2B-DF15-4F82-9D0A-FD0B34553E5D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{A0B30F2B-DF15-4F82-9D0A-FD0B34553E5D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{A0B30F2B-DF15-4F82-9D0A-FD0B34553E5D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{A0B30F2B-DF15-4F82-9D0A-FD0B34553E5D}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {F9294F35-DD76-42D1-BA2F-75863153509E}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
35
Cursach/Cursach.csproj
Normal file
35
Cursach/Cursach.csproj
Normal file
@ -0,0 +1,35 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net8.0-windows</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<ApplicationHighDpiMode>SystemAware</ApplicationHighDpiMode>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Saves\" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="protobuf-net" Version="3.2.30" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Update="Properties\Resources.Designer.cs">
|
||||
<DesignTime>True</DesignTime>
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Update="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
136
Cursach/FormCreate.Designer.cs
generated
Normal file
136
Cursach/FormCreate.Designer.cs
generated
Normal file
@ -0,0 +1,136 @@
|
||||
namespace Cursach
|
||||
{
|
||||
partial class FormCreate
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
comboBoxNode1 = new ComboBox();
|
||||
comboBoxNode2 = new ComboBox();
|
||||
buttonAddEdge = new Button();
|
||||
treeView = new TreeView();
|
||||
bttonSubmit = new Button();
|
||||
pictureBox1 = new PictureBox();
|
||||
label1 = new Label();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBox1).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// comboBoxNode1
|
||||
//
|
||||
comboBoxNode1.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
comboBoxNode1.FormattingEnabled = true;
|
||||
comboBoxNode1.Location = new Point(12, 17);
|
||||
comboBoxNode1.Name = "comboBoxNode1";
|
||||
comboBoxNode1.Size = new Size(151, 28);
|
||||
comboBoxNode1.TabIndex = 2;
|
||||
comboBoxNode1.SelectedIndexChanged += comboBoxNode1_SelectedIndexChanged;
|
||||
//
|
||||
// comboBoxNode2
|
||||
//
|
||||
comboBoxNode2.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
comboBoxNode2.FormattingEnabled = true;
|
||||
comboBoxNode2.Location = new Point(12, 51);
|
||||
comboBoxNode2.Name = "comboBoxNode2";
|
||||
comboBoxNode2.Size = new Size(151, 28);
|
||||
comboBoxNode2.TabIndex = 3;
|
||||
comboBoxNode2.SelectedIndexChanged += comboBoxNode2_SelectedIndexChanged;
|
||||
//
|
||||
// buttonAddEdge
|
||||
//
|
||||
buttonAddEdge.Enabled = false;
|
||||
buttonAddEdge.Location = new Point(169, 17);
|
||||
buttonAddEdge.Name = "buttonAddEdge";
|
||||
buttonAddEdge.Size = new Size(108, 62);
|
||||
buttonAddEdge.TabIndex = 5;
|
||||
buttonAddEdge.Text = "Добавить ребро";
|
||||
buttonAddEdge.UseVisualStyleBackColor = true;
|
||||
buttonAddEdge.Click += buttonAddEdge_Click;
|
||||
//
|
||||
// treeView
|
||||
//
|
||||
treeView.Location = new Point(12, 86);
|
||||
treeView.Name = "treeView";
|
||||
treeView.Size = new Size(265, 465);
|
||||
treeView.TabIndex = 6;
|
||||
treeView.AfterSelect += treeView_AfterSelect_1;
|
||||
//
|
||||
// bttonSubmit
|
||||
//
|
||||
bttonSubmit.Location = new Point(12, 557);
|
||||
bttonSubmit.Name = "bttonSubmit";
|
||||
bttonSubmit.Size = new Size(771, 40);
|
||||
bttonSubmit.TabIndex = 7;
|
||||
bttonSubmit.Text = "Обойти граф в ширину";
|
||||
bttonSubmit.UseVisualStyleBackColor = true;
|
||||
bttonSubmit.Click += buttonStart_Click;
|
||||
//
|
||||
// pictureBox1
|
||||
//
|
||||
pictureBox1.Location = new Point(281, 51);
|
||||
pictureBox1.Name = "pictureBox1";
|
||||
pictureBox1.Size = new Size(500, 500);
|
||||
pictureBox1.TabIndex = 8;
|
||||
pictureBox1.TabStop = false;
|
||||
pictureBox1.Click += pictureBox1_Click;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.AutoSize = true;
|
||||
label1.Location = new Point(283, 25);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(320, 20);
|
||||
label1.TabIndex = 9;
|
||||
label1.Text = "Нажмите на холст, чтобы добавить вершину";
|
||||
//
|
||||
// FormCreate
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(793, 600);
|
||||
Controls.Add(label1);
|
||||
Controls.Add(pictureBox1);
|
||||
Controls.Add(bttonSubmit);
|
||||
Controls.Add(treeView);
|
||||
Controls.Add(buttonAddEdge);
|
||||
Controls.Add(comboBoxNode2);
|
||||
Controls.Add(comboBoxNode1);
|
||||
Name = "FormCreate";
|
||||
Text = "Создание графа";
|
||||
((System.ComponentModel.ISupportInitialize)pictureBox1).EndInit();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
private ComboBox comboBoxNode1;
|
||||
private ComboBox comboBoxNode2;
|
||||
private Button buttonAddEdge;
|
||||
private TreeView treeView;
|
||||
private Button bttonSubmit;
|
||||
private PictureBox pictureBox1;
|
||||
private Label label1;
|
||||
}
|
||||
}
|
120
Cursach/FormCreate.cs
Normal file
120
Cursach/FormCreate.cs
Normal file
@ -0,0 +1,120 @@
|
||||
using Cursach.Parameters;
|
||||
using Cursach.Realisations;
|
||||
|
||||
namespace Cursach
|
||||
{
|
||||
public partial class FormCreate : Form
|
||||
{
|
||||
private AdjacencyList _adjacencyList;
|
||||
private Node startNode = new Node(0);
|
||||
public event Action<BFSParameters>? parameterDelegate;
|
||||
|
||||
private VizulizatorGraph? visualizatorGraph;
|
||||
|
||||
public FormCreate()
|
||||
{
|
||||
InitializeComponent();
|
||||
_adjacencyList = new AdjacencyList();
|
||||
visualizatorGraph = new VizulizatorGraph();
|
||||
Draw();
|
||||
}
|
||||
|
||||
private void buttonAddNode_Click(object sender, EventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
private void buttonAddEdge_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (!_adjacencyList.AddBind(new Bind(
|
||||
node1: _adjacencyList.GetByNameNode(comboBoxNode1.SelectedItem.ToString()),
|
||||
node2: _adjacencyList.GetByNameNode(comboBoxNode2.SelectedItem.ToString())
|
||||
)))
|
||||
{
|
||||
MessageBox.Show("Неверное ребро");
|
||||
return;
|
||||
}
|
||||
|
||||
treeView.Nodes.Clear();
|
||||
foreach (var parentNode in _adjacencyList.Keys())
|
||||
{
|
||||
TreeNode smartNode = new TreeNode(parentNode.ToString());
|
||||
foreach (var childNode in _adjacencyList.Values(parentNode))
|
||||
{
|
||||
smartNode.Nodes.Add(childNode.ToString());
|
||||
}
|
||||
|
||||
treeView.Nodes.Add(smartNode);
|
||||
}
|
||||
|
||||
treeView.ExpandAll();
|
||||
Draw();
|
||||
}
|
||||
|
||||
private void buttonStart_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
_adjacencyList.Mirror();
|
||||
BFSParameters parameter = new BFSParameters(startNode, _adjacencyList);
|
||||
parameterDelegate?.Invoke(parameter);
|
||||
Close();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
MessageBox.Show("Граф пустой");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void pictureBox1_Click(object sender, EventArgs e)
|
||||
{
|
||||
MouseEventArgs me = (MouseEventArgs)e;
|
||||
Point coordinates = me.Location;
|
||||
|
||||
_adjacencyList.AddNode(new Node(_adjacencyList.Keys().Count(), coordinates));
|
||||
comboBoxNode1.Items.Clear();
|
||||
comboBoxNode2.Items.Clear();
|
||||
foreach (var item in _adjacencyList.Keys())
|
||||
{
|
||||
comboBoxNode1.Items.Add(item);
|
||||
comboBoxNode2.Items.Add(item);
|
||||
}
|
||||
EnableAddEdgeButton();
|
||||
Draw();
|
||||
}
|
||||
|
||||
private void Draw()
|
||||
{
|
||||
|
||||
Bitmap bmp = new(pictureBox1.Width, pictureBox1.Height);
|
||||
Graphics gr = Graphics.FromImage(bmp);
|
||||
|
||||
if (visualizatorGraph != null)
|
||||
{
|
||||
visualizatorGraph.Draw(gr, _adjacencyList);
|
||||
}
|
||||
|
||||
pictureBox1.Image = bmp;
|
||||
}
|
||||
|
||||
private void treeView_AfterSelect_1(object sender, TreeViewEventArgs e)
|
||||
{
|
||||
startNode = _adjacencyList.GetByNameNode(e.Node?.Text);
|
||||
}
|
||||
|
||||
private void comboBoxNode1_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
EnableAddEdgeButton();
|
||||
}
|
||||
|
||||
private void comboBoxNode2_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
EnableAddEdgeButton();
|
||||
}
|
||||
|
||||
private void EnableAddEdgeButton()
|
||||
{
|
||||
buttonAddEdge.Enabled = comboBoxNode1.Text.Length > 0 && comboBoxNode2.Text.Length > 0;
|
||||
}
|
||||
}
|
||||
}
|
120
Cursach/FormCreate.resx
Normal file
120
Cursach/FormCreate.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
317
Cursach/InfoForm.Designer.cs
generated
Normal file
317
Cursach/InfoForm.Designer.cs
generated
Normal file
@ -0,0 +1,317 @@
|
||||
namespace Cursach
|
||||
{
|
||||
partial class InfoForm
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(InfoForm));
|
||||
tabControl1 = new TabControl();
|
||||
tabPageAboutBFS = new TabPage();
|
||||
richTextBox1 = new RichTextBox();
|
||||
pictureBox1 = new PictureBox();
|
||||
documentBFSInfo = new RichTextBox();
|
||||
tabPageHow = new TabPage();
|
||||
panel1 = new Panel();
|
||||
richTextBox3 = new RichTextBox();
|
||||
pictureBox2 = new PictureBox();
|
||||
label3 = new Label();
|
||||
richTextBox2 = new RichTextBox();
|
||||
label2 = new Label();
|
||||
pictureBox3 = new PictureBox();
|
||||
tabPageSaveLoad = new TabPage();
|
||||
label4 = new Label();
|
||||
documentSaveLoad = new RichTextBox();
|
||||
label1 = new Label();
|
||||
pictureBox4 = new PictureBox();
|
||||
label5 = new Label();
|
||||
tabControl1.SuspendLayout();
|
||||
tabPageAboutBFS.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBox1).BeginInit();
|
||||
tabPageHow.SuspendLayout();
|
||||
panel1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBox2).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBox3).BeginInit();
|
||||
tabPageSaveLoad.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBox4).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// tabControl1
|
||||
//
|
||||
tabControl1.Controls.Add(tabPageAboutBFS);
|
||||
tabControl1.Controls.Add(tabPageHow);
|
||||
tabControl1.Controls.Add(tabPageSaveLoad);
|
||||
tabControl1.Location = new Point(4, 45);
|
||||
tabControl1.Name = "tabControl1";
|
||||
tabControl1.SelectedIndex = 0;
|
||||
tabControl1.Size = new Size(756, 587);
|
||||
tabControl1.TabIndex = 0;
|
||||
//
|
||||
// tabPageAboutBFS
|
||||
//
|
||||
tabPageAboutBFS.Controls.Add(richTextBox1);
|
||||
tabPageAboutBFS.Controls.Add(pictureBox1);
|
||||
tabPageAboutBFS.Controls.Add(documentBFSInfo);
|
||||
tabPageAboutBFS.Location = new Point(4, 29);
|
||||
tabPageAboutBFS.Name = "tabPageAboutBFS";
|
||||
tabPageAboutBFS.Padding = new Padding(3);
|
||||
tabPageAboutBFS.Size = new Size(748, 554);
|
||||
tabPageAboutBFS.TabIndex = 0;
|
||||
tabPageAboutBFS.Text = "Описание алгоритма";
|
||||
tabPageAboutBFS.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// richTextBox1
|
||||
//
|
||||
richTextBox1.BorderStyle = BorderStyle.None;
|
||||
richTextBox1.Location = new Point(28, 316);
|
||||
richTextBox1.Name = "richTextBox1";
|
||||
richTextBox1.Size = new Size(240, 144);
|
||||
richTextBox1.TabIndex = 2;
|
||||
richTextBox1.Text = "Белый — вершина, которая ещё не обнаружена. Серый — вершина, уже обнаруженная и добавленная в очередь. Чёрный — вершина, извлечённая из очереди\n";
|
||||
//
|
||||
// pictureBox1
|
||||
//
|
||||
pictureBox1.Image = (Image)resources.GetObject("pictureBox1.Image");
|
||||
pictureBox1.InitialImage = (Image)resources.GetObject("pictureBox1.InitialImage");
|
||||
pictureBox1.Location = new Point(28, 83);
|
||||
pictureBox1.Name = "pictureBox1";
|
||||
pictureBox1.Size = new Size(240, 240);
|
||||
pictureBox1.SizeMode = PictureBoxSizeMode.CenterImage;
|
||||
pictureBox1.TabIndex = 1;
|
||||
pictureBox1.TabStop = false;
|
||||
//
|
||||
// documentBFSInfo
|
||||
//
|
||||
documentBFSInfo.BorderStyle = BorderStyle.None;
|
||||
documentBFSInfo.Location = new Point(298, 9);
|
||||
documentBFSInfo.Name = "documentBFSInfo";
|
||||
documentBFSInfo.ReadOnly = true;
|
||||
documentBFSInfo.ScrollBars = RichTextBoxScrollBars.Vertical;
|
||||
documentBFSInfo.Size = new Size(444, 539);
|
||||
documentBFSInfo.TabIndex = 0;
|
||||
documentBFSInfo.Text = "";
|
||||
//
|
||||
// tabPageHow
|
||||
//
|
||||
tabPageHow.AutoScroll = true;
|
||||
tabPageHow.Controls.Add(panel1);
|
||||
tabPageHow.Location = new Point(4, 29);
|
||||
tabPageHow.Name = "tabPageHow";
|
||||
tabPageHow.Padding = new Padding(3);
|
||||
tabPageHow.Size = new Size(748, 554);
|
||||
tabPageHow.TabIndex = 1;
|
||||
tabPageHow.Text = "Как пользоваться программой";
|
||||
tabPageHow.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// panel1
|
||||
//
|
||||
panel1.Controls.Add(richTextBox3);
|
||||
panel1.Controls.Add(pictureBox2);
|
||||
panel1.Controls.Add(label3);
|
||||
panel1.Controls.Add(richTextBox2);
|
||||
panel1.Controls.Add(label2);
|
||||
panel1.Controls.Add(pictureBox3);
|
||||
panel1.Location = new Point(3, 6);
|
||||
panel1.Name = "panel1";
|
||||
panel1.Size = new Size(718, 1271);
|
||||
panel1.TabIndex = 0;
|
||||
//
|
||||
// richTextBox3
|
||||
//
|
||||
richTextBox3.BorderStyle = BorderStyle.None;
|
||||
richTextBox3.Location = new Point(35, 1096);
|
||||
richTextBox3.Name = "richTextBox3";
|
||||
richTextBox3.ReadOnly = true;
|
||||
richTextBox3.ScrollBars = RichTextBoxScrollBars.None;
|
||||
richTextBox3.Size = new Size(641, 168);
|
||||
richTextBox3.TabIndex = 6;
|
||||
richTextBox3.Text = resources.GetString("richTextBox3.Text");
|
||||
//
|
||||
// pictureBox2
|
||||
//
|
||||
pictureBox2.Anchor = AnchorStyles.Top;
|
||||
pictureBox2.Image = Properties.Resources.Снимок_экрана_2024_05_15_2342491;
|
||||
pictureBox2.Location = new Point(47, 743);
|
||||
pictureBox2.Name = "pictureBox2";
|
||||
pictureBox2.Size = new Size(668, 347);
|
||||
pictureBox2.SizeMode = PictureBoxSizeMode.Zoom;
|
||||
pictureBox2.TabIndex = 5;
|
||||
pictureBox2.TabStop = false;
|
||||
//
|
||||
// label3
|
||||
//
|
||||
label3.AutoSize = true;
|
||||
label3.Font = new Font("Segoe UI", 12F, FontStyle.Bold, GraphicsUnit.Point, 204);
|
||||
label3.Location = new Point(175, 712);
|
||||
label3.Name = "label3";
|
||||
label3.Size = new Size(358, 28);
|
||||
label3.TabIndex = 4;
|
||||
label3.Text = "Окно создания графа (Окно ввода)";
|
||||
//
|
||||
// richTextBox2
|
||||
//
|
||||
richTextBox2.BorderStyle = BorderStyle.None;
|
||||
richTextBox2.Location = new Point(35, 431);
|
||||
richTextBox2.Name = "richTextBox2";
|
||||
richTextBox2.ReadOnly = true;
|
||||
richTextBox2.ScrollBars = RichTextBoxScrollBars.None;
|
||||
richTextBox2.Size = new Size(641, 265);
|
||||
richTextBox2.TabIndex = 3;
|
||||
richTextBox2.Text = resources.GetString("richTextBox2.Text");
|
||||
//
|
||||
// label2
|
||||
//
|
||||
label2.AutoSize = true;
|
||||
label2.Font = new Font("Segoe UI", 12F, FontStyle.Bold, GraphicsUnit.Point, 204);
|
||||
label2.Location = new Point(175, 22);
|
||||
label2.Name = "label2";
|
||||
label2.Size = new Size(396, 28);
|
||||
label2.TabIndex = 2;
|
||||
label2.Text = "Основное окно (Отрисовка алгоритма)";
|
||||
//
|
||||
// pictureBox3
|
||||
//
|
||||
pictureBox3.Anchor = AnchorStyles.Top;
|
||||
pictureBox3.Image = Properties.Resources.Снимок_экрана_2024_05_15_234525;
|
||||
pictureBox3.Location = new Point(8, 53);
|
||||
pictureBox3.Name = "pictureBox3";
|
||||
pictureBox3.Size = new Size(699, 372);
|
||||
pictureBox3.SizeMode = PictureBoxSizeMode.Zoom;
|
||||
pictureBox3.TabIndex = 1;
|
||||
pictureBox3.TabStop = false;
|
||||
//
|
||||
// tabPageSaveLoad
|
||||
//
|
||||
tabPageSaveLoad.Controls.Add(label5);
|
||||
tabPageSaveLoad.Controls.Add(pictureBox4);
|
||||
tabPageSaveLoad.Controls.Add(label4);
|
||||
tabPageSaveLoad.Controls.Add(documentSaveLoad);
|
||||
tabPageSaveLoad.Location = new Point(4, 29);
|
||||
tabPageSaveLoad.Name = "tabPageSaveLoad";
|
||||
tabPageSaveLoad.Padding = new Padding(3);
|
||||
tabPageSaveLoad.Size = new Size(748, 554);
|
||||
tabPageSaveLoad.TabIndex = 2;
|
||||
tabPageSaveLoad.Text = "Сохрание и загрузка";
|
||||
tabPageSaveLoad.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// label4
|
||||
//
|
||||
label4.AutoSize = true;
|
||||
label4.Font = new Font("Segoe UI", 12F, FontStyle.Bold | FontStyle.Italic, GraphicsUnit.Point, 204);
|
||||
label4.Location = new Point(158, 12);
|
||||
label4.Name = "label4";
|
||||
label4.Size = new Size(424, 28);
|
||||
label4.TabIndex = 1;
|
||||
label4.Text = "Сохранение и загрузка списка состояний\r\n";
|
||||
//
|
||||
// documentSaveLoad
|
||||
//
|
||||
documentSaveLoad.BorderStyle = BorderStyle.None;
|
||||
documentSaveLoad.ForeColor = SystemColors.WindowText;
|
||||
documentSaveLoad.Location = new Point(16, 53);
|
||||
documentSaveLoad.Name = "documentSaveLoad";
|
||||
documentSaveLoad.ReadOnly = true;
|
||||
documentSaveLoad.ScrollBars = RichTextBoxScrollBars.None;
|
||||
documentSaveLoad.Size = new Size(716, 92);
|
||||
documentSaveLoad.TabIndex = 0;
|
||||
documentSaveLoad.Text = resources.GetString("documentSaveLoad.Text");
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.AutoSize = true;
|
||||
label1.Font = new Font("Arial Black", 9F, FontStyle.Bold, GraphicsUnit.Point, 0);
|
||||
label1.Location = new Point(164, 9);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(454, 22);
|
||||
label1.TabIndex = 1;
|
||||
label1.Text = "Информация о программе \"Обход графа в ширину\"";
|
||||
//
|
||||
// pictureBox4
|
||||
//
|
||||
pictureBox4.Image = Properties.Resources.Снимок_экрана_2024_05_16_002226;
|
||||
pictureBox4.Location = new Point(16, 151);
|
||||
pictureBox4.Name = "pictureBox4";
|
||||
pictureBox4.Size = new Size(716, 274);
|
||||
pictureBox4.SizeMode = PictureBoxSizeMode.Zoom;
|
||||
pictureBox4.TabIndex = 2;
|
||||
pictureBox4.TabStop = false;
|
||||
//
|
||||
// label5
|
||||
//
|
||||
label5.AutoSize = true;
|
||||
label5.Location = new Point(133, 428);
|
||||
label5.Name = "label5";
|
||||
label5.Size = new Size(494, 20);
|
||||
label5.TabIndex = 3;
|
||||
label5.Text = "Структура примера файла *.states (граф из 2 вершин и одного ребра)";
|
||||
//
|
||||
// InfoForm
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(772, 632);
|
||||
Controls.Add(label1);
|
||||
Controls.Add(tabControl1);
|
||||
Name = "InfoForm";
|
||||
Text = "Информация";
|
||||
tabControl1.ResumeLayout(false);
|
||||
tabPageAboutBFS.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)pictureBox1).EndInit();
|
||||
tabPageHow.ResumeLayout(false);
|
||||
panel1.ResumeLayout(false);
|
||||
panel1.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBox2).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBox3).EndInit();
|
||||
tabPageSaveLoad.ResumeLayout(false);
|
||||
tabPageSaveLoad.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBox4).EndInit();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private TabControl tabControl1;
|
||||
private TabPage tabPageAboutBFS;
|
||||
private Label label1;
|
||||
private RichTextBox documentBFSInfo;
|
||||
private PictureBox pictureBox1;
|
||||
private RichTextBox richTextBox1;
|
||||
private TabPage tabPageHow;
|
||||
private Panel panel1;
|
||||
private PictureBox pictureBox3;
|
||||
private Label label2;
|
||||
private RichTextBox richTextBox2;
|
||||
private PictureBox pictureBox2;
|
||||
private Label label3;
|
||||
private RichTextBox richTextBox3;
|
||||
private TabPage tabPageSaveLoad;
|
||||
private Label label4;
|
||||
private RichTextBox documentSaveLoad;
|
||||
private Label label5;
|
||||
private PictureBox pictureBox4;
|
||||
}
|
||||
}
|
61
Cursach/InfoForm.cs
Normal file
61
Cursach/InfoForm.cs
Normal file
@ -0,0 +1,61 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Cursach
|
||||
{
|
||||
public partial class InfoForm : Form
|
||||
{
|
||||
public InfoForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
ShowDocumentation();
|
||||
}
|
||||
|
||||
private void ShowDocumentation()
|
||||
{
|
||||
# region BFSInfo
|
||||
|
||||
documentBFSInfo.Clear();
|
||||
documentBFSInfo.SelectionFont = new Font("Arial", 12);
|
||||
documentBFSInfo.SelectionFont = new Font(documentBFSInfo.SelectionFont, FontStyle.Bold);
|
||||
documentBFSInfo.AppendText("Описание\n");
|
||||
documentBFSInfo.SelectionFont = new Font("Arial", 10);
|
||||
documentBFSInfo.SelectionFont = new Font(documentBFSInfo.SelectionFont, FontStyle.Regular);
|
||||
documentBFSInfo.AppendText(
|
||||
"Поиск в ширину (англ. breadth-first search, BFS) — один из методов обхода графа. " +
|
||||
"Пусть задан граф \ud835\udc3a=(\ud835\udc49,\ud835\udc38) и выделена исходная вершина" +
|
||||
" \ud835\udc60. Алгоритм поиска в ширину систематически обходит все ребра \ud835\udc3a" +
|
||||
" для «открытия» всех вершин, достижимых из \ud835\udc60, вычисляя при этом расстояние" +
|
||||
" (минимальное количество рёбер) от \ud835\udc60 до каждой достижимой из \ud835\udc60" +
|
||||
" вершины. Алгоритм работает как для ориентированных, так и для неориентированных графов.\n\n");
|
||||
documentBFSInfo.SelectionFont = new Font("Arial", 12);
|
||||
documentBFSInfo.SelectionFont = new Font(documentBFSInfo.SelectionFont, FontStyle.Bold);
|
||||
documentBFSInfo.AppendText("Работа алгоритма\n");
|
||||
documentBFSInfo.SelectionFont = new Font("Arial", 10);
|
||||
documentBFSInfo.SelectionFont = new Font(documentBFSInfo.SelectionFont, FontStyle.Regular);
|
||||
documentBFSInfo.AppendText(
|
||||
"Поиск в ширину работает путём последовательного просмотра отдельных уровней графа," +
|
||||
" начиная с узла-источника \ud835\udc62.\n\nРассмотрим все рёбра (\ud835\udc62,\ud835\udc63)," +
|
||||
" выходящие из узла \ud835\udc62. Если очередной узел \ud835\udc63 является целевым узлом, то поиск" +
|
||||
" завершается; в противном случае узел \ud835\udc63 добавляется в очередь. После того, как будут" +
|
||||
" проверены все рёбра, выходящие из узла \ud835\udc62, из очереди извлекается следующий узел" +
|
||||
" \ud835\udc62, и процесс повторяется.\n");
|
||||
#endregion
|
||||
|
||||
# region SaveLoadInfo
|
||||
documentBFSInfo.Clear();
|
||||
documentBFSInfo.SelectionFont = new Font("Arial", 10);
|
||||
documentBFSInfo.AppendText("Сохрание осуществляется в через сохраниение класса StateList в бинарный файл с использованием технологии серверной сериализации brotobuf (библиотека для C# protobuf-net).\n\n");
|
||||
documentBFSInfo.AppendText("Бинарный файл имеет разрешение .state, что позволяет не путать файлы с другими расширениями.\n\n");
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
}
|
1278
Cursach/InfoForm.resx
Normal file
1278
Cursach/InfoForm.resx
Normal file
File diff suppressed because it is too large
Load Diff
235
Cursach/MainForm.Designer.cs
generated
Normal file
235
Cursach/MainForm.Designer.cs
generated
Normal file
@ -0,0 +1,235 @@
|
||||
namespace Cursach
|
||||
{
|
||||
partial class MainForm
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
pictureBox1 = new PictureBox();
|
||||
buttonNext = new Button();
|
||||
buttonPrev = new Button();
|
||||
listBox1 = new ListBox();
|
||||
listBox2 = new ListBox();
|
||||
label1 = new Label();
|
||||
label2 = new Label();
|
||||
buttonCreate = new Button();
|
||||
progressBar1 = new ProgressBar();
|
||||
menuStrip1 = new MenuStrip();
|
||||
SaveToolStripMenuItem = new ToolStripMenuItem();
|
||||
SaveToolStripMenuItem1 = new ToolStripMenuItem();
|
||||
LoadToolStripMenuItem = new ToolStripMenuItem();
|
||||
InfoToolStripMenuItem = new ToolStripMenuItem();
|
||||
saveFileDialog = new SaveFileDialog();
|
||||
openFileDialog = new OpenFileDialog();
|
||||
startPointLabel = new Label();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBox1).BeginInit();
|
||||
menuStrip1.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
// pictureBox1
|
||||
//
|
||||
pictureBox1.Location = new Point(27, 41);
|
||||
pictureBox1.Name = "pictureBox1";
|
||||
pictureBox1.Size = new Size(500, 500);
|
||||
pictureBox1.TabIndex = 0;
|
||||
pictureBox1.TabStop = false;
|
||||
//
|
||||
// buttonNext
|
||||
//
|
||||
buttonNext.Location = new Point(666, 41);
|
||||
buttonNext.Name = "buttonNext";
|
||||
buttonNext.Size = new Size(114, 51);
|
||||
buttonNext.TabIndex = 1;
|
||||
buttonNext.Text = "Следующее";
|
||||
buttonNext.UseVisualStyleBackColor = true;
|
||||
buttonNext.Click += buttonNext_Click;
|
||||
//
|
||||
// buttonPrev
|
||||
//
|
||||
buttonPrev.Location = new Point(546, 41);
|
||||
buttonPrev.Name = "buttonPrev";
|
||||
buttonPrev.Size = new Size(114, 51);
|
||||
buttonPrev.TabIndex = 2;
|
||||
buttonPrev.Text = "Предыдущее";
|
||||
buttonPrev.UseVisualStyleBackColor = true;
|
||||
buttonPrev.Click += buttonPrev_Click;
|
||||
//
|
||||
// listBox1
|
||||
//
|
||||
listBox1.FormattingEnabled = true;
|
||||
listBox1.Location = new Point(546, 211);
|
||||
listBox1.MultiColumn = true;
|
||||
listBox1.Name = "listBox1";
|
||||
listBox1.Size = new Size(114, 364);
|
||||
listBox1.TabIndex = 3;
|
||||
//
|
||||
// listBox2
|
||||
//
|
||||
listBox2.FormattingEnabled = true;
|
||||
listBox2.Location = new Point(666, 211);
|
||||
listBox2.MultiColumn = true;
|
||||
listBox2.Name = "listBox2";
|
||||
listBox2.Size = new Size(114, 364);
|
||||
listBox2.TabIndex = 4;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.AutoSize = true;
|
||||
label1.Location = new Point(666, 188);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(99, 20);
|
||||
label1.TabIndex = 5;
|
||||
label1.Text = "Посетившие:";
|
||||
//
|
||||
// label2
|
||||
//
|
||||
label2.AutoSize = true;
|
||||
label2.Location = new Point(546, 188);
|
||||
label2.Name = "label2";
|
||||
label2.Size = new Size(72, 20);
|
||||
label2.TabIndex = 6;
|
||||
label2.Text = "Очередь:";
|
||||
//
|
||||
// buttonCreate
|
||||
//
|
||||
buttonCreate.Location = new Point(546, 98);
|
||||
buttonCreate.Name = "buttonCreate";
|
||||
buttonCreate.Size = new Size(234, 51);
|
||||
buttonCreate.TabIndex = 7;
|
||||
buttonCreate.Text = "Задать граф";
|
||||
buttonCreate.UseVisualStyleBackColor = true;
|
||||
buttonCreate.Click += buttonCreate_Click;
|
||||
//
|
||||
// progressBar1
|
||||
//
|
||||
progressBar1.Location = new Point(27, 552);
|
||||
progressBar1.Name = "progressBar1";
|
||||
progressBar1.Size = new Size(500, 23);
|
||||
progressBar1.TabIndex = 8;
|
||||
//
|
||||
// menuStrip1
|
||||
//
|
||||
menuStrip1.ImageScalingSize = new Size(20, 20);
|
||||
menuStrip1.Items.AddRange(new ToolStripItem[] { SaveToolStripMenuItem, InfoToolStripMenuItem });
|
||||
menuStrip1.Location = new Point(0, 0);
|
||||
menuStrip1.Name = "menuStrip1";
|
||||
menuStrip1.Size = new Size(792, 28);
|
||||
menuStrip1.TabIndex = 9;
|
||||
menuStrip1.Text = "menuStrip1";
|
||||
//
|
||||
// SaveToolStripMenuItem
|
||||
//
|
||||
SaveToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { SaveToolStripMenuItem1, LoadToolStripMenuItem });
|
||||
SaveToolStripMenuItem.Name = "SaveToolStripMenuItem";
|
||||
SaveToolStripMenuItem.Size = new Size(59, 24);
|
||||
SaveToolStripMenuItem.Text = "Файл";
|
||||
//
|
||||
// SaveToolStripMenuItem1
|
||||
//
|
||||
SaveToolStripMenuItem1.Name = "SaveToolStripMenuItem1";
|
||||
SaveToolStripMenuItem1.Size = new Size(166, 26);
|
||||
SaveToolStripMenuItem1.Text = "Сохранить";
|
||||
SaveToolStripMenuItem1.Click += SaveToolStripMenuItem1_Click;
|
||||
//
|
||||
// LoadToolStripMenuItem
|
||||
//
|
||||
LoadToolStripMenuItem.Name = "LoadToolStripMenuItem";
|
||||
LoadToolStripMenuItem.Size = new Size(166, 26);
|
||||
LoadToolStripMenuItem.Text = "Загрузить";
|
||||
LoadToolStripMenuItem.Click += LoadToolStripMenuItem_Click;
|
||||
//
|
||||
// InfoToolStripMenuItem
|
||||
//
|
||||
InfoToolStripMenuItem.Name = "InfoToolStripMenuItem";
|
||||
InfoToolStripMenuItem.Size = new Size(116, 24);
|
||||
InfoToolStripMenuItem.Text = "Информация";
|
||||
InfoToolStripMenuItem.Click += InfoToolStripMenuItem_Click;
|
||||
//
|
||||
// saveFileDialog
|
||||
//
|
||||
saveFileDialog.Filter = "states file | *.states";
|
||||
//
|
||||
// openFileDialog
|
||||
//
|
||||
openFileDialog.Filter = "states file | *.states";
|
||||
//
|
||||
// startPointLabel
|
||||
//
|
||||
startPointLabel.Location = new Point(546, 160);
|
||||
startPointLabel.Name = "startPointLabel";
|
||||
startPointLabel.Size = new Size(234, 25);
|
||||
startPointLabel.TabIndex = 10;
|
||||
startPointLabel.Text = "Начальная точка: Null";
|
||||
startPointLabel.TextAlign = ContentAlignment.MiddleCenter;
|
||||
//
|
||||
// MainForm
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(792, 583);
|
||||
Controls.Add(startPointLabel);
|
||||
Controls.Add(progressBar1);
|
||||
Controls.Add(buttonCreate);
|
||||
Controls.Add(label2);
|
||||
Controls.Add(label1);
|
||||
Controls.Add(listBox2);
|
||||
Controls.Add(listBox1);
|
||||
Controls.Add(buttonPrev);
|
||||
Controls.Add(buttonNext);
|
||||
Controls.Add(pictureBox1);
|
||||
Controls.Add(menuStrip1);
|
||||
MainMenuStrip = menuStrip1;
|
||||
Name = "MainForm";
|
||||
Text = "Визуализатор обхода графа в ширину";
|
||||
Load += MainForm_Load;
|
||||
((System.ComponentModel.ISupportInitialize)pictureBox1).EndInit();
|
||||
menuStrip1.ResumeLayout(false);
|
||||
menuStrip1.PerformLayout();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private PictureBox pictureBox1;
|
||||
private Button buttonNext;
|
||||
private Button buttonPrev;
|
||||
private ListBox listBox1;
|
||||
private ListBox listBox2;
|
||||
private Label label1;
|
||||
private Label label2;
|
||||
private Button buttonCreate;
|
||||
private ProgressBar progressBar1;
|
||||
private MenuStrip menuStrip1;
|
||||
private ToolStripMenuItem SaveToolStripMenuItem;
|
||||
private ToolStripMenuItem SaveToolStripMenuItem1;
|
||||
private ToolStripMenuItem LoadToolStripMenuItem;
|
||||
private ToolStripMenuItem InfoToolStripMenuItem;
|
||||
private SaveFileDialog saveFileDialog;
|
||||
private OpenFileDialog openFileDialog;
|
||||
private Label startPointLabel;
|
||||
}
|
||||
}
|
162
Cursach/MainForm.cs
Normal file
162
Cursach/MainForm.cs
Normal file
@ -0,0 +1,162 @@
|
||||
using System.Text;
|
||||
using Cursach.Parameters;
|
||||
using Cursach.States;
|
||||
|
||||
namespace Cursach
|
||||
{
|
||||
public partial class MainForm : Form
|
||||
{
|
||||
private Visualizator? visualizator;
|
||||
private StatesManager? _storage;
|
||||
|
||||
public MainForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
visualizator = new Visualizator();
|
||||
}
|
||||
|
||||
private void MainForm_Load(object sender, EventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
private void buttonCreate_Click(object sender, EventArgs e)
|
||||
{
|
||||
FormCreate formCreate = new FormCreate();
|
||||
formCreate.parameterDelegate += AddData;
|
||||
formCreate.Show();
|
||||
}
|
||||
|
||||
private void buttonNext_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_storage == null)
|
||||
{
|
||||
MessageBox.Show("Сначала нужно создать граф");
|
||||
return;
|
||||
}
|
||||
|
||||
if (_storage.NextState())
|
||||
{
|
||||
UpdateVizualization();
|
||||
}
|
||||
else
|
||||
{
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
stringBuilder.Append("Обход графа в ширину завершен\n");
|
||||
stringBuilder.Append("Результат:\n");
|
||||
foreach (var node in _storage.GetCurrentState().visited)
|
||||
{
|
||||
stringBuilder.Append("- " + node + "\n");
|
||||
}
|
||||
|
||||
MessageBox.Show(stringBuilder.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonPrev_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_storage == null)
|
||||
{
|
||||
MessageBox.Show("Сначала нужно создать граф");
|
||||
return;
|
||||
}
|
||||
|
||||
if (_storage.PrevState())
|
||||
{
|
||||
UpdateVizualization();
|
||||
}
|
||||
else
|
||||
{
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
stringBuilder.Append("Выхода нет\n");
|
||||
MessageBox.Show(stringBuilder.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
private void AddData(BFSParameters paramter)
|
||||
{
|
||||
if (visualizator == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_storage = new Manager(paramter).StartBFS();
|
||||
MessageBox.Show("Обход графа в ширину запущен");
|
||||
UpdateVizualization();
|
||||
}
|
||||
|
||||
private void Draw()
|
||||
{
|
||||
if (visualizator == null || _storage == null || _storage.GetCurrentState() == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Bitmap bmp = new(pictureBox1.Width, pictureBox1.Height);
|
||||
Graphics gr = Graphics.FromImage(bmp);
|
||||
visualizator.Draw(gr, _storage.GetCurrentState());
|
||||
pictureBox1.Image = bmp;
|
||||
}
|
||||
|
||||
private void SaveToolStripMenuItem1_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_storage == null)
|
||||
{
|
||||
MessageBox.Show("Сначала нужно создать граф");
|
||||
return;
|
||||
}
|
||||
|
||||
if (saveFileDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
MessageBox.Show(_storage.SaveStateList(saveFileDialog.FileName)
|
||||
? $"Список состояний успешно сохранён в {saveFileDialog.FileName}"
|
||||
: $"Ошибка при сохранении файла {saveFileDialog.FileName}");
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
_storage ??= new StatesManager();
|
||||
|
||||
if (openFileDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
string filePath = openFileDialog.FileName;
|
||||
if (_storage.LoadStateList(filePath))
|
||||
{
|
||||
UpdateVizualization();
|
||||
MessageBox.Show("Файл загружен успешно");
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Неверный формат файла или файл поврежден");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void InfoToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
InfoForm infoForm = new InfoForm();
|
||||
infoForm.Show();
|
||||
}
|
||||
|
||||
private void UpdateVizualization()
|
||||
{
|
||||
startPointLabel.Text = "Отсчёт от: " + _storage.GetStartNode();
|
||||
progressBar1.Maximum = _storage.Count;
|
||||
progressBar1.Value = _storage.CurrentStateIndex + 1;
|
||||
|
||||
listBox1.Items.Clear();
|
||||
foreach (var node in _storage.GetCurrentState().queue)
|
||||
{
|
||||
listBox1.Items.Add(node.ToString());
|
||||
}
|
||||
|
||||
listBox2.Items.Clear();
|
||||
foreach (var node in _storage.GetCurrentState().visited)
|
||||
{
|
||||
listBox2.Items.Add(node.ToString());
|
||||
}
|
||||
|
||||
Draw();
|
||||
}
|
||||
}
|
||||
}
|
129
Cursach/MainForm.resx
Normal file
129
Cursach/MainForm.resx
Normal file
@ -0,0 +1,129 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>336, 17</value>
|
||||
</metadata>
|
||||
<metadata name="saveFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<metadata name="openFileDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>174, 17</value>
|
||||
</metadata>
|
||||
</root>
|
22
Cursach/Manager.cs
Normal file
22
Cursach/Manager.cs
Normal file
@ -0,0 +1,22 @@
|
||||
using System.Reflection.Metadata;
|
||||
using Cursach.Parameters;
|
||||
using Cursach.Realisations;
|
||||
using Cursach.States;
|
||||
|
||||
namespace Cursach;
|
||||
|
||||
public class Manager(BFSParameters parameter)
|
||||
{
|
||||
public BFS BFS = new(parameter);
|
||||
|
||||
public StatesManager StartBFS()
|
||||
{
|
||||
StatesManager statesManager = new();
|
||||
statesManager.AddState(BFS.GetState());
|
||||
while (BFS.Step())
|
||||
{
|
||||
statesManager.AddState(BFS.GetState());
|
||||
}
|
||||
return statesManager;
|
||||
}
|
||||
}
|
15
Cursach/Parameters/BFSParameters.cs
Normal file
15
Cursach/Parameters/BFSParameters.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using Cursach.Realisations;
|
||||
|
||||
namespace Cursach.Parameters;
|
||||
|
||||
public class BFSParameters
|
||||
{
|
||||
public Node StartNode { private set; get; }
|
||||
public AdjacencyList adjacencyList;
|
||||
|
||||
public BFSParameters(Node startNode, AdjacencyList adjacencyList)
|
||||
{
|
||||
StartNode = startNode;
|
||||
this.adjacencyList = adjacencyList;
|
||||
}
|
||||
}
|
17
Cursach/Program.cs
Normal file
17
Cursach/Program.cs
Normal file
@ -0,0 +1,17 @@
|
||||
namespace Cursach
|
||||
{
|
||||
internal static class Program
|
||||
{
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
// To customize application configuration such as set high DPI settings or default font,
|
||||
// see https://aka.ms/applicationconfiguration.
|
||||
ApplicationConfiguration.Initialize();
|
||||
Application.Run(new MainForm());
|
||||
}
|
||||
}
|
||||
}
|
123
Cursach/Properties/Resources.Designer.cs
generated
Normal file
123
Cursach/Properties/Resources.Designer.cs
generated
Normal file
@ -0,0 +1,123 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// Этот код создан программой.
|
||||
// Исполняемая версия:4.0.30319.42000
|
||||
//
|
||||
// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
|
||||
// повторной генерации кода.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Cursach.Properties {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Класс ресурса со строгой типизацией для поиска локализованных строк и т.д.
|
||||
/// </summary>
|
||||
// Этот класс создан автоматически классом StronglyTypedResourceBuilder
|
||||
// с помощью такого средства, как ResGen или Visual Studio.
|
||||
// Чтобы добавить или удалить член, измените файл .ResX и снова запустите ResGen
|
||||
// с параметром /str или перестройте свой проект VS.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Resources {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal Resources() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Возвращает кэшированный экземпляр ResourceManager, использованный этим классом.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Cursach.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Перезаписывает свойство CurrentUICulture текущего потока для всех
|
||||
/// обращений к ресурсу с помощью этого класса ресурса со строгой типизацией.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap Снимок_экрана_2024_05_15_233208 {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("Снимок экрана 2024-05-15 233208", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap Снимок_экрана_2024_05_15_234249 {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("Снимок экрана 2024-05-15 234249", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap Снимок_экрана_2024_05_15_2342491 {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("Снимок экрана 2024-05-15 2342491", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap Снимок_экрана_2024_05_15_234525 {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("Снимок экрана 2024-05-15 234525", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap Снимок_экрана_2024_05_15_2345251 {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("Снимок экрана 2024-05-15 2345251", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap Снимок_экрана_2024_05_16_002226 {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("Снимок экрана 2024-05-16 002226", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
139
Cursach/Properties/Resources.resx
Normal file
139
Cursach/Properties/Resources.resx
Normal file
@ -0,0 +1,139 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
<data name="Снимок экрана 2024-05-15 234249" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\Снимок экрана 2024-05-15 234249.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="Снимок экрана 2024-05-15 2345251" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\Снимок экрана 2024-05-15 2345251.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="Снимок экрана 2024-05-15 233208" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\Снимок экрана 2024-05-15 233208.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="Снимок экрана 2024-05-15 234525" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\Снимок экрана 2024-05-15 234525.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="Снимок экрана 2024-05-15 2342491" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\Снимок экрана 2024-05-15 2342491.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="Снимок экрана 2024-05-16 002226" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\Снимок экрана 2024-05-16 002226.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
</root>
|
108
Cursach/Realisations/AdjacencyList.cs
Normal file
108
Cursach/Realisations/AdjacencyList.cs
Normal file
@ -0,0 +1,108 @@
|
||||
using ProtoBuf;
|
||||
|
||||
namespace Cursach.Realisations;
|
||||
|
||||
[ProtoContract]
|
||||
[Serializable]
|
||||
public class AdjacencyList
|
||||
{
|
||||
[ProtoMember(1)] private Dictionary<Node, List<Node>> bindings;
|
||||
|
||||
public AdjacencyList()
|
||||
{
|
||||
bindings = new Dictionary<Node, List<Node>>();
|
||||
}
|
||||
|
||||
public bool AddBind(Bind bind)
|
||||
{
|
||||
if (bind.Node1 == null || bind.Node2 == null) return false;
|
||||
if (Equals(bind.Node1, bind.Node2)) return false;
|
||||
if (bind.Node1.GetHashCode() > bind.Node2.GetHashCode())
|
||||
{
|
||||
bind = new Bind(bind.Node2, bind.Node1);
|
||||
}
|
||||
|
||||
;
|
||||
if (!bindings.ContainsKey(bind.Node1))
|
||||
{
|
||||
bindings[bind.Node1] = [bind.Node2];
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!bindings[bind.Node1].Contains(bind.Node2))
|
||||
{
|
||||
bindings[bind.Node1].Add(bind.Node2);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void AddNode(Node node)
|
||||
{
|
||||
if (bindings.ContainsKey(node))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
bindings[node] = new List<Node>();
|
||||
}
|
||||
|
||||
public static bool operator -(AdjacencyList adjacencyList, Bind bind)
|
||||
{
|
||||
if (!adjacencyList.bindings.ContainsKey(bind.Node1))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!adjacencyList.bindings[bind.Node1].Contains(bind.Node2))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
adjacencyList.bindings[bind.Node1].Remove(bind.Node2);
|
||||
return true;
|
||||
}
|
||||
|
||||
public IEnumerable<Node> Values(Node key)
|
||||
{
|
||||
return bindings[key];
|
||||
}
|
||||
|
||||
public IEnumerable<Node> Keys()
|
||||
{
|
||||
return bindings.Keys;
|
||||
}
|
||||
|
||||
public Node? GetByNameNode(String name)
|
||||
{
|
||||
foreach (Node node in bindings.Keys)
|
||||
{
|
||||
if (node.ToString() == name)
|
||||
{
|
||||
return node;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void Mirror()
|
||||
{
|
||||
foreach (Node node in bindings.Keys)
|
||||
{
|
||||
foreach (Node childNode in bindings[node])
|
||||
{
|
||||
if (!bindings.ContainsKey(childNode))
|
||||
{
|
||||
bindings[childNode] = new List<Node>();
|
||||
}
|
||||
|
||||
if (!bindings[childNode].Contains(node))
|
||||
{
|
||||
bindings[childNode].Add(node);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
59
Cursach/Realisations/BFS.cs
Normal file
59
Cursach/Realisations/BFS.cs
Normal file
@ -0,0 +1,59 @@
|
||||
using System.Reflection.Metadata;
|
||||
using Cursach.Parameters;
|
||||
using Cursach.States;
|
||||
|
||||
namespace Cursach.Realisations;
|
||||
|
||||
public class BFS
|
||||
{
|
||||
public Node StartNode { private set; get; }
|
||||
public bool IsEnd { private set; get; }
|
||||
private AdjacencyList adjacencyList;
|
||||
private bool isCompleted = false;
|
||||
|
||||
public List<Node> visited;
|
||||
public Queue<Node> queue;
|
||||
|
||||
public BFS(BFSParameters parameter)
|
||||
{
|
||||
StartNode = parameter.StartNode;
|
||||
adjacencyList = parameter.adjacencyList;
|
||||
visited = new();
|
||||
queue = new();
|
||||
queue.Enqueue(StartNode);
|
||||
IsEnd = false;
|
||||
isCompleted = false;
|
||||
}
|
||||
|
||||
public State GetState()
|
||||
{
|
||||
return new State(adjacencyList, new List<Node>(visited), new List<Node>(queue));
|
||||
}
|
||||
|
||||
public bool Step()
|
||||
{
|
||||
if (queue.Count > 0)
|
||||
{
|
||||
Node currentNode = queue.Dequeue();
|
||||
visited.Add(currentNode);
|
||||
foreach (Node neighbour in adjacencyList.Values(currentNode))
|
||||
{
|
||||
if (!visited.Contains(neighbour) && !queue.Contains(neighbour))
|
||||
{
|
||||
queue.Enqueue(neighbour);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (queue.Count <= 0)
|
||||
{
|
||||
if (!isCompleted)
|
||||
{
|
||||
isCompleted = true;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
18
Cursach/Realisations/Bind.cs
Normal file
18
Cursach/Realisations/Bind.cs
Normal file
@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Cursach.Realisations;
|
||||
|
||||
public class Bind
|
||||
{
|
||||
public Node Node1 { private set; get; }
|
||||
public Node Node2 { private set; get; }
|
||||
public Bind(Node node1, Node node2)
|
||||
{
|
||||
Node1 = node1;
|
||||
Node2 = node2;
|
||||
}
|
||||
}
|
67
Cursach/Realisations/Node.cs
Normal file
67
Cursach/Realisations/Node.cs
Normal file
@ -0,0 +1,67 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ProtoBuf;
|
||||
|
||||
namespace Cursach.Realisations;
|
||||
|
||||
[ProtoContract]
|
||||
[Serializable]
|
||||
public class Node()
|
||||
{
|
||||
[ProtoMember(1)] private int Id { get; set; }
|
||||
|
||||
[ProtoMember(2)] private MyPoint Position { get; set; }
|
||||
|
||||
public Node(int id) : this()
|
||||
{
|
||||
Id = id;
|
||||
}
|
||||
public Node(string name) : this(int.Parse(name.Split("#")[1]))
|
||||
{
|
||||
}
|
||||
|
||||
public Node(int id, Point position) : this(id)
|
||||
{
|
||||
Position = new MyPoint(position);
|
||||
}
|
||||
|
||||
public override bool Equals(object? obj)
|
||||
{
|
||||
try
|
||||
{
|
||||
return ((obj as Node)!).Id == Id;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return Id;
|
||||
}
|
||||
|
||||
public Point GetPosition()
|
||||
{
|
||||
return Position.GetPoint;
|
||||
}
|
||||
|
||||
public override string ToString() => "Вершина #" + Id;
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
[ProtoContract]
|
||||
public struct MyPoint(int x, int y)
|
||||
{
|
||||
[ProtoMember(1)] public int X = x;
|
||||
[ProtoMember(2)] public int Y = y;
|
||||
|
||||
public MyPoint(Point point) : this(x: point.X, y: point.Y) { }
|
||||
|
||||
public Point GetPoint => new(x: X, y: Y);
|
||||
|
||||
}
|
BIN
Cursach/Resources/Снимок экрана 2024-05-15 2342491.png
Normal file
BIN
Cursach/Resources/Снимок экрана 2024-05-15 2342491.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 50 KiB |
BIN
Cursach/Resources/Снимок экрана 2024-05-15 234525.png
Normal file
BIN
Cursach/Resources/Снимок экрана 2024-05-15 234525.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 51 KiB |
BIN
Cursach/Resources/Снимок экрана 2024-05-16 002226.png
Normal file
BIN
Cursach/Resources/Снимок экрана 2024-05-16 002226.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 133 KiB |
26
Cursach/States/State.cs
Normal file
26
Cursach/States/State.cs
Normal file
@ -0,0 +1,26 @@
|
||||
using Cursach.Realisations;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ProtoBuf;
|
||||
|
||||
namespace Cursach.States;
|
||||
|
||||
[ProtoContract]
|
||||
[Serializable]
|
||||
public class State()
|
||||
{
|
||||
[ProtoMember(1)] public List<Node> visited = [];
|
||||
[ProtoMember(2)] public List<Node> queue = [];
|
||||
[ProtoMember(3)] public AdjacencyList AdjacencyList = new();
|
||||
public bool IsCompleted => !queue.Any();
|
||||
|
||||
public State(AdjacencyList adjacencyList, List<Node> visited, List<Node> queue) : this()
|
||||
{
|
||||
this.visited = visited;
|
||||
this.queue = queue;
|
||||
AdjacencyList = adjacencyList;
|
||||
}
|
||||
}
|
19
Cursach/States/StateList.cs
Normal file
19
Cursach/States/StateList.cs
Normal file
@ -0,0 +1,19 @@
|
||||
using ProtoBuf;
|
||||
|
||||
namespace Cursach.States;
|
||||
[ProtoContract]
|
||||
[Serializable]
|
||||
public class StateList
|
||||
{
|
||||
[ProtoMember(1)]
|
||||
public List<State> States;
|
||||
|
||||
public StateList()
|
||||
{
|
||||
States = new List<State>();
|
||||
}
|
||||
public StateList(List<State> states) : this()
|
||||
{
|
||||
States = states;
|
||||
}
|
||||
}
|
132
Cursach/States/StatesManager.cs
Normal file
132
Cursach/States/StatesManager.cs
Normal file
@ -0,0 +1,132 @@
|
||||
using Cursach.Realisations;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.Design;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using ProtoBuf;
|
||||
|
||||
namespace Cursach.States;
|
||||
|
||||
public class StatesManager
|
||||
{
|
||||
List<State> states;
|
||||
public int Count => states.Count;
|
||||
public int CurrentStateIndex { get; private set; }
|
||||
|
||||
public StatesManager()
|
||||
{
|
||||
states = [];
|
||||
CurrentStateIndex = 0;
|
||||
}
|
||||
|
||||
public bool NextState()
|
||||
{
|
||||
CurrentStateIndex += 1;
|
||||
if (CurrentStateIndex >= Count)
|
||||
{
|
||||
CurrentStateIndex = Count - 1;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool PrevState()
|
||||
{
|
||||
CurrentStateIndex -= 1;
|
||||
if (CurrentStateIndex < 0)
|
||||
{
|
||||
CurrentStateIndex = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public State? GetCurrentState()
|
||||
{
|
||||
return GetState(CurrentStateIndex);
|
||||
}
|
||||
|
||||
public bool AddState(State state)
|
||||
{
|
||||
states.Add(state);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public State? GetState(int index)
|
||||
{
|
||||
if (index >= 0 && index < states.Count)
|
||||
{
|
||||
return states[index];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public State? GetFirstState()
|
||||
{
|
||||
if (states.Count == 0)
|
||||
{
|
||||
return states[0];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public State? GetLastState()
|
||||
{
|
||||
if (states.Count == 0)
|
||||
{
|
||||
return states[Count - 1];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public bool SaveStateList(string filename)
|
||||
{
|
||||
try
|
||||
{
|
||||
using var file = File.Create(filename);
|
||||
Serializer.Serialize(file, new StateList(states));
|
||||
return true;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public bool LoadStateList(string filename)
|
||||
{
|
||||
try
|
||||
{
|
||||
StateList tmpStates;
|
||||
using (var file = File.OpenRead(filename))
|
||||
{
|
||||
tmpStates = Serializer.Deserialize<StateList>(file);
|
||||
states = tmpStates.States;
|
||||
CurrentStateIndex = 0;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public Node GetStartNode()
|
||||
{
|
||||
if (GetCurrentState().visited.Count == 0)
|
||||
{
|
||||
return GetCurrentState().queue.Last();
|
||||
}
|
||||
return GetCurrentState().visited[0];
|
||||
}
|
||||
}
|
43
Cursach/Visualizator.cs
Normal file
43
Cursach/Visualizator.cs
Normal file
@ -0,0 +1,43 @@
|
||||
using Cursach.Realisations;
|
||||
using Cursach.States;
|
||||
|
||||
namespace Cursach;
|
||||
|
||||
public class Visualizator
|
||||
{
|
||||
private State? State { get; set; }
|
||||
|
||||
public void Draw(Graphics g, State state)
|
||||
{
|
||||
Pen penLine = new(Color.Black, 5);
|
||||
Pen penBid = new(Color.Red, 2);
|
||||
Pen penSelectedBid = new(Color.Green, 3);
|
||||
Brush darkBrush = new SolidBrush(Color.Black);
|
||||
g.FillRectangle(new SolidBrush(Color.White), 0, 0, 500, 500);
|
||||
|
||||
AdjacencyList _adjacencyList = state.AdjacencyList;
|
||||
foreach (var parentNode in _adjacencyList.Keys())
|
||||
{
|
||||
foreach (var childNode in _adjacencyList.Values(parentNode))
|
||||
{
|
||||
g.DrawLine(penLine, parentNode.GetPosition(), childNode.GetPosition());
|
||||
}
|
||||
|
||||
|
||||
g.DrawString(parentNode.ToString(), new Font("Comic Sans MS", 7), darkBrush,
|
||||
parentNode.GetPosition().X - 20, parentNode.GetPosition().Y - 30);
|
||||
if (state.visited.Contains(parentNode))
|
||||
{
|
||||
VizulizatorGraph.DrawPoint(g, parentNode.GetPosition(), Color.Crimson);
|
||||
}
|
||||
else if (state.queue.Contains(parentNode))
|
||||
{
|
||||
VizulizatorGraph.DrawPoint(g, parentNode.GetPosition(), Color.DarkSlateGray);
|
||||
}
|
||||
else
|
||||
{
|
||||
VizulizatorGraph.DrawPoint(g, parentNode.GetPosition(), Color.Gray);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
32
Cursach/VizulizatorGraph.cs
Normal file
32
Cursach/VizulizatorGraph.cs
Normal file
@ -0,0 +1,32 @@
|
||||
using Cursach.Realisations;
|
||||
|
||||
namespace Cursach;
|
||||
|
||||
public class VizulizatorGraph
|
||||
{
|
||||
public void Draw(Graphics g, AdjacencyList _adjacencyList)
|
||||
{
|
||||
Pen penLine = new(Color.Black, 5);
|
||||
Pen penBid = new(Color.Red, 2);
|
||||
Pen penSelectedBid = new(Color.Green, 3);
|
||||
Brush brush = new SolidBrush(Color.Gray);
|
||||
Brush darkBrush = new SolidBrush(Color.Black);
|
||||
g.FillRectangle(new SolidBrush(Color.White), 0, 0, 500, 500);
|
||||
foreach (var parentNode in _adjacencyList.Keys())
|
||||
{
|
||||
foreach (var childNode in _adjacencyList.Values(parentNode))
|
||||
{
|
||||
g.DrawLine(penLine, parentNode.GetPosition(), childNode.GetPosition());
|
||||
}
|
||||
|
||||
g.DrawString(parentNode.ToString(), new Font("Comic Sans MS", 7), darkBrush,
|
||||
parentNode.GetPosition().X - 20, parentNode.GetPosition().Y - 30);
|
||||
DrawPoint(g, parentNode.GetPosition(), Color.Gray);
|
||||
}
|
||||
}
|
||||
|
||||
public static void DrawPoint(Graphics g, Point point, Color color = default)
|
||||
{
|
||||
g.FillEllipse(new SolidBrush(color), point.X - 10, point.Y - 10, 20, 20);
|
||||
}
|
||||
}
|
BIN
Cursach/data/inp.states
Normal file
BIN
Cursach/data/inp.states
Normal file
Binary file not shown.
0
Cursach/data/states
Normal file
0
Cursach/data/states
Normal file
Loading…
Reference in New Issue
Block a user