Breadth first traversal, also known as breadth first search or BFS, is an algorithm for traversing or searching tree or graph data structures. It starts at the tree root (or some arbitrary node of a graph, sometimes referred to as a 'search key') and explores the neighbor nodes first, before moving to the next level neighbors.

```									```public struct Vertex
{
public char Label;
public bool Visited;
}

private static int _rear = -1;
private static int _front = 0;
private static int _queueItemCount = 0;
private static int _vertexCount = 0;

private static void Insert(int[] queue, int data)
{
queue[++_rear] = data;
_queueItemCount++;
}

private static int RemoveData(int[] queue)
{
_queueItemCount--;
return queue[_front++];
}

private static bool IsQueueEmpty()
{
return _queueItemCount == 0;
}

public static void AddVertex(Vertex[] arrVertices, char label)
{
Vertex vertex = new Vertex();
vertex.Label = label;
vertex.Visited = false;
arrVertices[_vertexCount++] = vertex;
}

{
}

private static void DisplayVertex(Vertex[] arrVertices, int vertexIndex)
{
Console.Write(arrVertices[vertexIndex].Label + " ");
}

{
int i;

for (i = 0; i < _vertexCount; i++)
{
if (adjacencyMatrix[vertexIndex, i] == 1 && arrVertices[i].Visited == false)
return i;
}

return -1;
}

{
int i;
arrVertices.Visited = true;
DisplayVertex(arrVertices, 0);
Insert(queue, 0);
int unvisitedVertex;

while (!IsQueueEmpty())
{
int tempVertex = RemoveData(queue);

{
arrVertices[unvisitedVertex].Visited = true;
DisplayVertex(arrVertices, unvisitedVertex);
Insert(queue, unvisitedVertex);
}
}

for (i = 0; i < _vertexCount; i++)
{
arrVertices[i].Visited = false;
}
}```
```

### Example

```									```int max = 5;
int[] queue = new int[max];
Vertex[] arrVertices = new Vertex[max];
int[,] adjacencyMatrix = new int[max, max];

for (int i = 0; i < max; i++)
for (int j = 0; j < max; j++)

```									`Breadth First Search: S A B C D`