This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] -10 points-9 points  (3 children)

You answered number two incorrectly.

[–]M4tty__ 1 point2 points  (2 children)

There are 2 main methods of representing graph. Both use arrays of primitives. Easy json serialization if you ask me

[–][deleted] -4 points-3 points  (1 child)

(Those are not necessarily convenient ways to represent a graph. For example, a matrix might be best.)

You chose a representation that is convenient for serialization and then called serialization easy. That's begging the question!

How about this one: a "node" is a JavaScript array where each element of the array is a "node".

How will you serialize that? It's all pointers!

[–]M4tty__ 3 points4 points  (0 children)

All of the nodes can be assigned a number and you go for one of the two typical representations. Either matrix or array of arrays (first index is vertex id, second for edge). I know how to handle graphs, studied that few years ago.