January 2018
Intermediate to advanced
332 pages
7h 36m
English
Before we write any code for our Personalized PageRank, let's first create a Node.js application, as explained earlier.
Once the application is ready, let's create a route that will be serving us our user suggestions. Similar to the example from the preceding example, we can quickly piece together the following route under routes/suggestions.js:
const express = require('express');const router = express.Router();const _ = require('lodash');// sample set of users with friends extracted from some grapgh dbconst users = { A: { neighbors: [ 'B', 'D' ] }, B: { neighbors: [ 'A', 'C', 'E' ] }, C: { neighbors: [ 'B', 'D', 'E' ] }, D: { neighbors: [ 'A', 'C' ] }, E: { neighbors: [ 'B', 'C' ] }};// middleware router.use(function ...
Read now
Unlock full access