This constructor supposes that a square network will be passed for training - it should be possible to get square root of network's neurons amount.
public SOMLearning( DistanceNetwork network ) { // network's dimension was not specified, let's try to guess int neuronsCount = network.Layers[0].Neurons.Length; int width = (int) Math.Sqrt( neuronsCount ); if ( width * width != neuronsCount ) { throw new ArgumentException( "Invalid network size." ); } // ok, we got it this.network = network; this.width = width; this.height = width; }