```using System;

namespace Algorithms.Graph.MinimumSpanningTree;

/// <summary>
///     Class that uses Prim's (Jarnik's algorithm) to determine the minimum
///     spanning tree (MST) of a given graph. Prim's algorithm is a greedy
///     algorithm that can determine the MST of a weighted undirected graph
///     in O(V^2) time where V is the number of nodes/vertices when using an
///     Pseudocode and runtime analysis: https://www.personal.kent.edu/~rmuhamma/Algorithms/MyAlgorithms/GraphAlgor/primAlgor.htm .
/// </summary>
public static class PrimMatrix
{
/// <summary>
///     Determine the minimum spanning tree for a given weighted undirected graph.
/// </summary>
/// <param name="start">Node to start search from.</param>
/// <returns>Adjacency matrix of the found MST.</returns>
public static float[,] Solve(float[,] adjacencyMatrix, int start)
{

// Create array to represent minimum spanning tree
var mst = new float[numNodes, numNodes];

// Create array to keep track of which nodes are in the MST already

// Create array to keep track of smallest edge weight for node
var key = new float[numNodes];

// Create array to store parent of node
var parent = new int[numNodes];

for (var i = 0; i < numNodes; i++)
{
mst[i, i] = float.PositiveInfinity;
key[i] = float.PositiveInfinity;

for (var j = i + 1; j < numNodes; j++)
{
mst[i, j] = float.PositiveInfinity;
mst[j, i] = float.PositiveInfinity;
}
}

// Ensures that the starting node is added first
key[start] = 0;

// Keep looping until all nodes are in tree
for (var i = 0; i < numNodes - 1; i++)
{
}

// Build adjacency matrix for tree
for (var i = 0; i < numNodes; i++)
{
if (i == start)
{
continue;
}

}

return mst;
}

/// <summary>
///     Ensure that the given adjacency matrix represents a weighted undirected graph.
/// </summary>
{
// Matrix should be square
{
throw new ArgumentException("Adjacency matrix must be square!");
}

// Graph needs to be undirected and connected
for (var i = 0; i < adjacencyMatrix.GetLength(0); i++)
{
var connection = false;
for (var j = 0; j < adjacencyMatrix.GetLength(0); j++)
{
{
throw new ArgumentException("Adjacency matrix must be symmetric!");
}

{
connection = true;
}
}

if (!connection)
{
throw new ArgumentException("Graph must be connected!");
}
}
}

/// <summary>
///     Determine which node should be added next to the MST.
/// </summary>
/// <param name="key">Currently known minimum edge weight connected to each node.</param>
/// <param name="added">Whether or not a node has been added to the MST.</param>
/// <param name="parent">The node that added the node to the MST. Used for building MST adjacency matrix.</param>
{
var minWeight = float.PositiveInfinity;

var node = -1;

// Find node with smallest node with known edge weight not in tree. Will always start with starting node
for (var i = 0; i < numNodes; i++)
{
if (!added[i] && key[i] < minWeight)
{
minWeight = key[i];
node = i;
}
}