summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitattributes3
-rw-r--r--.gitignore14
-rw-r--r--CS340.Extensions.csproj7
-rw-r--r--GraphExtensions.cs9
4 files changed, 32 insertions, 1 deletions
diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000..5dc46e6
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1,3 @@
+* text=auto eol=lf
+*.{cmd,[cC][mM][dD]} text eol=crlf
+*.{bat,[bB][aA][tT]} text eol=crlf \ No newline at end of file
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..f075c18
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,14 @@
+
+# Created by https://www.toptal.com/developers/gitignore/api/dotnetcore
+# Edit at https://www.toptal.com/developers/gitignore?templates=dotnetcore
+
+### DotnetCore ###
+# .NET Core build folders
+bin/
+obj/
+
+# Common node modules locations
+/node_modules
+/wwwroot/node_modules
+
+# End of https://www.toptal.com/developers/gitignore/api/dotnetcore
diff --git a/CS340.Extensions.csproj b/CS340.Extensions.csproj
new file mode 100644
index 0000000..f208d30
--- /dev/null
+++ b/CS340.Extensions.csproj
@@ -0,0 +1,7 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+ <PropertyGroup>
+ <TargetFramework>net5.0</TargetFramework>
+ </PropertyGroup>
+
+</Project>
diff --git a/GraphExtensions.cs b/GraphExtensions.cs
index 4d5e468..5980158 100644
--- a/GraphExtensions.cs
+++ b/GraphExtensions.cs
@@ -2,7 +2,7 @@ using System;
using Graph;
using PriorityQueue;
-namespace PrimDijkstra.Extensions
+namespace Extensions
{
// Aliases
using Graph = Graph<double>;
@@ -11,6 +11,7 @@ namespace PrimDijkstra.Extensions
public static class GraphExtensions
{
+
// lambda function for Prim's Algorithm
public static Func<double, double, double> Prim = (_, weight) =>
weight;
@@ -19,6 +20,12 @@ namespace PrimDijkstra.Extensions
public static Func<double, double, double> Dijkstra = (u, weight) =>
weight + u;
+ public static Graph MST(this Graph graph, int init) =>
+ PrimDijkstra(graph, init, Prim);
+
+ public static Graph SPT(this Graph graph, int init) =>
+ PrimDijkstra(graph, init, Dijkstra);
+
// shared code for Prim and Dijkstra
public static Graph PrimDijkstra(this Graph graph, int init, Func<double, double, double> weightCalc)
{