コード例 #1
0
    private void AdicionarArestas(Grafo <Node, double> grafo)
    {
        for (var y = 0; y < _fieldSize; y++)
        {
            for (var x = 0; x < _fieldSize; x++)
            {
                var corrente = PegarTerrenoDeGrafoEmCoordenada(grafo, x, y);

                foreach (var coordinates in new[]
                {
                    new[] { 1, 0 },
                    new[] { -1, 0 },
                    new[] { 0, 1 },
                    new[] { 0, -1 }
                })
                {
                    var noAdjacente = PegarTerrenoDeGrafoEmCoordenada(grafo, x + coordinates[0], y + coordinates[1]);

                    if (noAdjacente != null)
                    {
                        grafo.AdicionarAresta(corrente, _timeByNode[corrente.type], noAdjacente);
                    }
                }
            }
        }
    }