I have these informations to save in a variable for my basic neural network simulation.
- Node (NodeId, State)
- Relationship (SourceNodeId, TargetNodeId, Weight, State)
State is the activation level which is the only value which changes during simulation. It is an unsigned float.
I want to easily get all incoming and all outgoing relationships for the current node. By easily I mean very great performance. (I have around 1,000,000 nodes with each 50 relationships on average.)
The main part of my program looks like this (pseudo code).
foreach(Node in Nodes)
{
Inputs[] = all incomeing relationships;
Node.State = sum of all Inputs[] elements;
Outputs[] = all outgoing relationships;
normalize all Outputs[] elements temporarly; // so that the sum of their weights is 1
foreach(Output in Outputs[])
{
Output.State = Node.State * Output.Weight;
}
}
I hope you understand what I want to do. If not I will try to explain better.
What type of Object would be best to have quick access to the nodes by their SourceNodeId and by their TargetNodeId?
PS: Programming in C# using Visual Studio.
I think list with nodes + two syncronized Dictionaries will be fast.
I recommend you to encapsulate them into single object… Two-Way-Dictionary: