Skip to content

Instantly share code, notes, and snippets.

@dibikhin
Created April 30, 2020 23:25
Show Gist options
  • Save dibikhin/a72a816e94c8d5808ce86bc36859f088 to your computer and use it in GitHub Desktop.
Save dibikhin/a72a816e94c8d5808ce86bc36859f088 to your computer and use it in GitHub Desktop.
Build friends network
a = a.map(x => ({id: x.id, fids: x.friendsIds}))
data = {}
data.nodes = a.map(x => ({ id: x.id }))
data.links = a.reduce((acc, cur) => {
const links = cur.fids.map(x => ({ source: cur.id, target: x }))
return acc.concat(links)
}, [])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment