When you tackle this kind of problem you have to list what the system has to know and what it can deduce.
For instance, how the system knows which instance to link which each other instance?
I mean. if you have 4 dots, there's many ways to link them.
In your picture it seems an instance will always be linked to the same two others.
So, how can you tell the system how to link them?
I think you can use an instance variable named 'order' that will hold maybe the order your object were created
so you can create lines from the first to the second, etc etc.