I am not quite sure if I completely understand the Entity Component System approach, and probably that is one of the reasons for the emergence of this question. Still struggling with the OOP mindset!
I am trying to create a data structure similar to a network, so for instance, something like a circuit:
So, for instance, entity 4 is connected to 1, 1 to 2, and so on. So far I have understood how to create the components, but I can't understand how the connectivity information should be stored. I believe that the entity should point to another entity?!? I have also imagined that would be even better practice to have a component that would have the connectivity information, but in that case, once again, what should it store? Ideally would be the entities themself, right? How to do it?
You should always refer to other entities using their Id and don't store pointers to them between System runs.
Entity id in Bevy stored in struct
Entity
Note:Also, if this network is something unique for your game (e.g. there are maximum one instance in whole game) than it's connectivity data can be stored in the "resource". You get most benefits from Entity-Component part of ECS when your entities and components are created and processed in large quantities.
I cannot say anything more about your particular use-case because I don't know how many networks there would be, how you plan use them and interact with them. ECS is DDD pattern (Data-Driven Development) so architecture depends on how much data exists, which properties this data has and how it is used.
Example of multiple networks
If you have multiple networks, you can store them in such fashion:
And you can store parts of electric network in such fashion:
After finishing spawning parts like that, you would know only connections on plus side but you can fill negative side in separate system, for example: