javascript - How can I find a path between two abstract nodes -


i wish test "small world" or "six degrees of separation" hypothesis, theory human can reach through 6 mutual friends. (i.e. friend of friend of friend of friend of friend of friend)

example node data (json):

{     "name": "john smith",     "friends": [         "foo bar",         "john doe"     ] } 

there hundreds of objects these, each linking 1 another. want find shortest path between them. pathfinding algorithm such found in games suitable abstract concepts (i.e.: concepts not representable in 2d or 3d world) or there more elegant solution?

i know loop through friends list multiple times increasing depths of search, inelegant solution, taking long time large amounts of data.

i aware of pathfinding algorithms such a*, unsure whether appropriate use them

at least program should output string such "it takes x steps person1 person2" nice know intermediary people , possibly obtain nice web/graph it, too.

this link finding paths in graphs (page 33,34) gives powerful algorithm graphs, assume, these small-world graphs!

before implementing algorithm, should transform json-data graph reasonable fast data-structure (dense vs. sparse graph-representation).


Comments

Popular posts from this blog

1111. appearing after print sequence - php -

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

Ruby on Rails, ActiveRecord, Postgres, UTF-8 and ASCII-8BIT encodings -