From 5a9abe40845e94957aab583bd19fe1e07809cf5e Mon Sep 17 00:00:00 2001 From: Ahmed Zamil Date: Mon, 27 Mar 2023 20:30:35 +0300 Subject: [PATCH] graph --- Esiur.Analysis.Test/FGraph.Designer.cs | 46 ++++++++++++++++++ Esiur.Analysis.Test/FGraph.cs | 20 ++++++++ Esiur.Analysis.Test/FGraph.resx | 60 ++++++++++++++++++++++++ Esiur.Analysis/Esiur.Analysis.csproj | 2 +- Esiur.Analysis/Graph/DirectedGraph.cs | 15 ++++++ Esiur.Analysis/Graph/Edge.cs | 12 +++++ Esiur.Analysis/Graph/IGraph.cs | 10 ++++ Esiur.Analysis/Graph/Node.cs | 14 ++++++ Esiur.Analysis/Graph/TransitionMatrix.cs | 47 +++++++++++++++++++ 9 files changed, 225 insertions(+), 1 deletion(-) create mode 100644 Esiur.Analysis.Test/FGraph.Designer.cs create mode 100644 Esiur.Analysis.Test/FGraph.cs create mode 100644 Esiur.Analysis.Test/FGraph.resx create mode 100644 Esiur.Analysis/Graph/DirectedGraph.cs create mode 100644 Esiur.Analysis/Graph/Edge.cs create mode 100644 Esiur.Analysis/Graph/IGraph.cs create mode 100644 Esiur.Analysis/Graph/Node.cs create mode 100644 Esiur.Analysis/Graph/TransitionMatrix.cs diff --git a/Esiur.Analysis.Test/FGraph.Designer.cs b/Esiur.Analysis.Test/FGraph.Designer.cs new file mode 100644 index 0000000..a0184dc --- /dev/null +++ b/Esiur.Analysis.Test/FGraph.Designer.cs @@ -0,0 +1,46 @@ +namespace Esiur.Analysis.Test +{ + partial class FGraph + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.SuspendLayout(); + // + // FGraph + // + this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(838, 494); + this.Name = "FGraph"; + this.Text = "FGraph"; + this.ResumeLayout(false); + + } + + #endregion + } +} \ No newline at end of file diff --git a/Esiur.Analysis.Test/FGraph.cs b/Esiur.Analysis.Test/FGraph.cs new file mode 100644 index 0000000..fd3b6e6 --- /dev/null +++ b/Esiur.Analysis.Test/FGraph.cs @@ -0,0 +1,20 @@ +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 Esiur.Analysis.Test +{ + public partial class FGraph : Form + { + public FGraph() + { + InitializeComponent(); + } + } +} diff --git a/Esiur.Analysis.Test/FGraph.resx b/Esiur.Analysis.Test/FGraph.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/Esiur.Analysis.Test/FGraph.resx @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Esiur.Analysis/Esiur.Analysis.csproj b/Esiur.Analysis/Esiur.Analysis.csproj index ad627d7..f5b19ec 100644 --- a/Esiur.Analysis/Esiur.Analysis.csproj +++ b/Esiur.Analysis/Esiur.Analysis.csproj @@ -1,4 +1,4 @@ - + netstandard2.1 diff --git a/Esiur.Analysis/Graph/DirectedGraph.cs b/Esiur.Analysis/Graph/DirectedGraph.cs new file mode 100644 index 0000000..f793edd --- /dev/null +++ b/Esiur.Analysis/Graph/DirectedGraph.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Esiur.Analysis.Graph +{ + public class DirectedGraph : IGraph + { + public Node[] Nodes { get; set; } + public Edge[] Edges { get; set; } + + + + } +} diff --git a/Esiur.Analysis/Graph/Edge.cs b/Esiur.Analysis/Graph/Edge.cs new file mode 100644 index 0000000..eefbb7c --- /dev/null +++ b/Esiur.Analysis/Graph/Edge.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Esiur.Analysis.Graph +{ + public class Edge + { + public T SourceNode { get; set; } + public T DestinationNode { get; set; } + } +} diff --git a/Esiur.Analysis/Graph/IGraph.cs b/Esiur.Analysis/Graph/IGraph.cs new file mode 100644 index 0000000..ac6ff78 --- /dev/null +++ b/Esiur.Analysis/Graph/IGraph.cs @@ -0,0 +1,10 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Esiur.Analysis.Graph +{ + public interface IGraph + { + } +} diff --git a/Esiur.Analysis/Graph/Node.cs b/Esiur.Analysis/Graph/Node.cs new file mode 100644 index 0000000..7740e4e --- /dev/null +++ b/Esiur.Analysis/Graph/Node.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Esiur.Analysis.Graph +{ + public class Node + { + public T Value { get; set; } + + public int X { get; set; } + public int Y { get; set; } + } +} diff --git a/Esiur.Analysis/Graph/TransitionMatrix.cs b/Esiur.Analysis/Graph/TransitionMatrix.cs new file mode 100644 index 0000000..12bbb82 --- /dev/null +++ b/Esiur.Analysis/Graph/TransitionMatrix.cs @@ -0,0 +1,47 @@ +using System; +using System.Collections.Generic; +using System.Reflection.Metadata.Ecma335; +using System.Security.Cryptography.X509Certificates; +using System.Text; + +namespace Esiur.Analysis.Graph +{ + public class Matrix where T : struct + { + internal T[,] value; + + public int Rows => value.GetLength(0); + public int Columns => value.GetLength(1); + + public T this[int x, int y] => value[x, y]; + + public Matrix(T[,] value) + { + this.value = value; + } + + public static Matrix Multiply(Matrix a, Matrix b) where T:struct + { + + + if (a.Columns != b.Rows) + throw new ArgumentException("`a` rows do not match `b` columns."); + + + T[,] rt = new T[a.Rows, b.Columns]; + + for (int i = 0; i < a.Rows; i++) + { // aRow + for (int j = 0; j < b.Columns; j++) + { // bColumn + for (int k = 0; k < a.Columns; k++) + { // aColumn + rt[i, j] += a[i, k] * b[k, j]; + } + } + } + + return new Matrix(rt); + } + } +}