/
Simple algorithm to eliminate circular references
Simple algorithm to eliminate circular references
We are starting with Neuron XYZ
Begin with array of all neurons
Create a dictionary
Fill dictionary with the GUID of every neuron as the key (value doesn’t really matter)
Now remove neuron XYZ from the dictionary (ie. itself)
Now iterate through every neuron that XYZ is currently connected to and remove those from the map
If we find those in map then repeat removing connected neurons of that neuron - but if the neuron is already present in the map then we are done for that particular neuron.
Example code in Lua:
function CreateNeuronMap(N)
local Map = {}
for i=1, #N do
Map[i] = true
end
return Map
end
function FindSuitors(Neurons, Map, ID)
if Map[ID] then
Map[ID]= nil
for i=1, #Neurons[ID] do
FindSuitors(Neurons, Map, Neurons[ID][i])
end
end
end
function main()
local Neurons = {}
Neurons[1] = {2,3}
Neurons[2] = {2}
Neurons[3] = {}
local Map = CreateNeuronMap(Neurons)
FindSuitors(Neurons, Map, 3)
trace(Map)
end
, multiple selections available,
Related content
Get a Lua sandbox and learn about the core eight types of variables
Get a Lua sandbox and learn about the core eight types of variables
Read with this
Grid Discovery
Grid Discovery
More like this
Using Prefixed Name Spaces with Javascript
Using Prefixed Name Spaces with Javascript
Read with this
How do we solve synchronization issues with the network neuron implementation
How do we solve synchronization issues with the network neuron implementation
More like this
Our Core Values
Our Core Values
Read with this
Methods on object orientated code
Methods on object orientated code
More like this