public List <Node> ConvertToGraph(Maze maze)
        {
            _mazeValidator.ValidateAndThrowErrors(maze);
            ValidateMaze(maze);

            var nodesById = InitializeNodes(maze.Cells);

            for (var h = 0; h < maze.Height; h++)
            {
                for (var w = 0; w < maze.Width; w++)
                {
                    var cellIndex = h * maze.Width + w;
                    var cell      = maze.Cells[cellIndex];

                    var northCell = h > 0 ? maze.Cells[(h - 1) * maze.Width + w] : null;
                    var southCell = h < maze.Height - 1 ? maze.Cells[(h + 1) * maze.Width + w] : null;
                    var eastCell  = w < maze.Width - 1 ? maze.Cells[cellIndex + 1] : null;
                    var westCell  = w > 0 ? maze.Cells[cellIndex - 1] : null;

                    foreach (var direction in cell.Passages)
                    {
                        var neighbor = PickNeighborCell(northCell, southCell, eastCell, westCell, direction);

                        if (neighbor != null)
                        {
                            nodesById[cell.Id].Neighbors.Add(new Neighbor {
                                NodeId = neighbor.Id, Cost = 1
                            });
                        }
                    }
                }
            }

            return(nodesById.Values.ToList());
        }