java - Dense and Sparse Run Time -


i trying make program finds shortest path in graph. example, make 100 vertices , 100 edges 100 vertices again , 500 edges , measure run time.

my question how can understand whether dense or sparse?

the density ratio of number of edges in graph number of edges in complete graph same vertex set.

both of these graphs reasonably sparse, though first sparser.

often density of graph used decide data structure use represent graph

  • an adjacency matrix makes sense dense graphs enumerating outbound edges not common operation.
  • edge lists make sense sparse graphs or enumerating outbound edges done frequently.

it's trade-off though. adjacency graphs take more memory vertex count scales, getting list of edges between 2 vertices fast. scanning outbound edges slow.

edge lists take less memory vertex count increases, looking edges between 2 vertices slower, enumerating outgoing edges fast.


Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -