D
D
dalbio2020-06-18 16:42:38
C++ / C#
dalbio, 2020-06-18 16:42:38

How to store a graph with a large number of vertices?

For example, I have a graph with n=1e+5 vertices. I don't have enough memory to store it as a matrix m[n][n]. What should I do then?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Zhilin, 2020-06-18
@dalbio

For example, vector<vector<pair<int, int>>>where each inner vector<pair<int, int>>contains edges leading from the vertex with the corresponding index, and each pair<int, int>is the destination and weight of the edge.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question