# C# Help Determining Issue

4.3 Mono

### Question

Im currently trying to adapt some GDScript to C# but the visual output is incorrect but im having difficulty discerning if the draw logic is flawed or if it its the actual method. i should be getting a visual representation of the Minimum Spanning Tree between my rooms. but instead i get this monstrosity.

Here is the MST Method

``````private AStar2D FindMST(Array<Vector2> roomPositions)
{
roomPositions.RemoveAt(0);
while (roomPositions.Count > 0)
{
float minDistance = float.PositiveInfinity;
Vector2 closestPosition = Vector2.Inf;
Vector2 currentPosition = Vector2.Inf;
for (int i = 0; i < path.GetPointIds().Length; i++)
{
Vector2 startingPoint = path.GetPointPosition(i);
foreach (Vector2 position in roomPositions)
{
if (startingPoint.DistanceTo(position) < minDistance)
{
minDistance = startingPoint.DistanceTo(position);
closestPosition = position;
currentPosition = startingPoint;
}
}
}
long nextPoint = path.GetAvailablePointId();
path.ConnectPoints(path.GetClosestPoint(currentPosition),nextPoint);
roomPositions.Remove(closestPosition);
}
return path;
}
``````

Here is the Draw Method (first part works)

``````public override void _Draw()
{
if (rooms.GetChildCount() > 0)
{
foreach (Node child in rooms.GetChildren())
{
int newX = (int)(child as Node2D).Position.X - (int)((child as Room).size.X/2);
int newY = (int)(child as Node2D).Position.Y - (int)((child as Room).size.Y/2);
DrawRect(new Rect2(new Vector2(newX,newY),(child as Room).size), new Color(32,228,0),false);
}
}
if (path != null)
{
for (int i = 0; i < path.GetPointCount(); i++)
{
for (int j = 0; j < path.GetPointConnections(i).Length; j++)
{
DrawLine(path.GetPointPosition(i),path.GetPointPosition(j),new Color(1,1,0), 15, true);
}
}
}
}
``````

Any help would be much appreciated.