I've made a decentralized node network using WebSockets with use of Nodejs. I would like to visualize this network with a graph. To visualize the whole network I need all nodes connected to each other, but there is a problem - in the decentralized network there is no central point. How I can get all connected nodes from any node? Let's say we have a connection:
A <-> B <-> C
Like you can see now you can visualize the network from B, but what about visualizing the network from A, C?
How A know about C while drawing graphs? Should I also attach peers of connected nodes ( all peers of B) and then all nodes of next nodes - C? What would be the best way to get all peers connected to each other? Thanks for any tips.
Graph search algorithms could be of use :D Common ones are BFS and DFS. The general gist of the approach is to start with any node and visit its neighbours while keeping track of which ones you have already visited (so you don't have to go over them again).
In your case I think it would be sensible to start with any random node, and do the process iteratively. I found a fantastic explanation here, please check it out.
This is a fun exercise actually