class KohonenSet{ float learningRate= .25; int numNodes, numWeights; int vNodes, hNodes; float MAX_ITERATIONS = 250; int iterationCounter = 0; float neighborDist; float weightArray[][]; //an array of 'node' by 'weight' dimensions float kset[][]; //values to be sorted Integer ksetRandomOrder[]; int mapMode = 0; void KohonenSet(){ } void initWeights(int hNodes, int vNodes, int numWeights){ weightArray = new float[vNodes*hNodes][numWeights]; numNodes = vNodes*hNodes; this.hNodes = hNodes; this.vNodes = vNodes; this.numWeights = numWeights; for (int i=0; i=hNodes){ adjacentWeights += weightArray[node-hNodes][i];//if you're along the top don't check above you numWeightsChecked++; } if(node<(numNodes-hNodes)){ adjacentWeights += weightArray[node+hNodes][i];//if you're along the bottem don't check below yourself numWeightsChecked++; } // nodeValue += weightArray[node][i]; nodeValue += abs(weightArray[node][i] - (adjacentWeights/numWeightsChecked)); } // fill(255-abs(nodeValue/numWeights - adjacentWeights/numWeightsChecked)); fill(255-5*nodeValue); pushMatrix(); translate(500/hNodes*(node%hNodes),500/vNodes*(node/hNodes)); rect(0,0,500/hNodes,500/vNodes); popMatrix(); } } void listMap(){ float m=.5; //a multiplier for easier visualization for(int node=0; node