I have points, I need to check the collisions between them, the solution was to put all of them in a graph, the distance between the points will be the weight. When adding, you need to somehow check that the edge already exists, how to do it correctly, someone can have an example in any C of such a language.
Found something like this:
vector<int> graph[100000]; //массив из 100000 векторов. int main() { int n, m; cin >> n >> m; for (int i = 0; i < m; i++) { int u, v; cin >> u >> v; u--, v--; graph[u].push_back(v); graph[v].push_back(u); } for (int i = 0; i < n; i++) { int c = 0; for (int v: graph[i]) { c++; } cout << c << " edges adjacent to vertex " << i + 1 << endl; } } Did so without a graph:
namespace Helper { export class CollisionContainer { public container: Entities.GameEntity[] = []; public add(entity: Entities.GameEntity) { this.getLength(entity); this.container.push(entity); } public reset(){ this.container = []; } public getLength(entity: Entities.GameEntity) { this.container.forEach((item: Entities.GameEntity)=> { let length = entity.position.getLengthToPoint(item.position); if (item.radius + entity.radius > length) { item.onCollision(entity); entity.onCollision(item); } }); } } }