src/iteration/neighbors.js
function createNeighborArrayForNode(type, direction, nodeData) {

  // If we want only undirected or in or out, we can roll some optimizations
  if (type !== 'mixed') {
    if (type === 'undirected')
      return Object.keys(nodeData.undirected);

    if (typeof direction === 'string')
      return Object.keys(nodeData[direction]);
  }

  // Else we need to keep a set of neighbors not to return duplicates
  const neighbors = new Set();

  if (type !== 'undirected') {

    if (direction !== 'out') {
      merge(neighbors, nodeData.in);
    }
    if (direction !== 'in') {
      merge(neighbors, nodeData.out);
    }
  }

  if (type !== 'directed') {
    merge(neighbors, nodeData.undirected);
  }

  return take(neighbors.values(), neighbors.size);
}
function createNeighborArrayForNode(type, direction, nodeData) {

  // If we want only undirected or in or out, we can roll some optimizations
  if (type !== 'mixed') {
    if (type === 'undirected')
      return Object.keys(nodeData.undirected);

    if (typeof direction === 'string')
      return Object.keys(nodeData[direction]);
  }

  // Else we need to keep a set of neighbors not to return duplicates
  const neighbors = new Set();

  if (type !== 'undirected') {

    if (direction !== 'out') {
      merge(neighbors, nodeData.in);
    }
    if (direction !== 'in') {
      merge(neighbors, nodeData.out);
    }
  }

  if (type !== 'directed') {
    merge(neighbors, nodeData.undirected);
  }

  return take(neighbors.values(), neighbors.size);
}
function createNeighborArrayForNode ( type , direction , nodeData ) { // If we want only undirected or in or out, we can roll some optimizations if ( type !== 'mixed' ) { if ( type === 'undirected' ) return Object . keys ( nodeData . undirected ) ; if ( typeof direction === 'string' ) return Object . keys ( nodeData [ direction ] ) ; } // Else we need to keep a set of neighbors not to return duplicates const neighbors = new Set ( ) ; if ( type !== 'undirected' ) { if ( direction !== 'out' ) { merge ( neighbors , nodeData . in ) ; } if ( direction !== 'in' ) { merge ( neighbors , nodeData . out ) ; } } if ( type !== 'directed' ) { merge ( neighbors , nodeData . undirected ) ; } return take ( neighbors . values ( ) , neighbors . size ) ; }
Function creating an array of relevant neighbors for the given node.

@param  {string}       type      - Type of neighbors.
@param  {string}       direction - Direction.
@param  {any}          nodeData  - Target node's data.
@return {Array}                  - The list of neighbors.
Function creating an array of relevant neighbors for the given node .