src/iteration/neighbors.js
function nodeHasNeighbor(graph, type, direction, node, neighbor) {

  const nodeData = graph._nodes.get(node);

  if (type !== 'undirected') {

    if (direction !== 'out' && typeof nodeData.in !== 'undefined') {
      for (const k in nodeData.in)
        if (k === neighbor)
          return true;
    }
    if (direction !== 'in' && typeof nodeData.out !== 'undefined') {
      for (const k in nodeData.out)
        if (k === neighbor)
          return true;
    }
  }

  if (type !== 'directed' && typeof nodeData.undirected !== 'undefined') {
    for (const k in nodeData.undirected)
        if (k === neighbor)
          return true;
  }

  return false;
}
function nodeHasNeighbor(graph, type, direction, node, neighbor) {

  const nodeData = graph._nodes.get(node);

  if (type !== 'undirected') {

    if (direction !== 'out' && typeof nodeData.in !== 'undefined') {
      for (const k in nodeData.in)
        if (k === neighbor)
          return true;
    }
    if (direction !== 'in' && typeof nodeData.out !== 'undefined') {
      for (const k in nodeData.out)
        if (k === neighbor)
          return true;
    }
  }

  if (type !== 'directed' && typeof nodeData.undirected !== 'undefined') {
    for (const k in nodeData.undirected)
        if (k === neighbor)
          return true;
  }

  return false;
}
function nodeHasNeighbor ( graph , type , direction , node , neighbor ) { const nodeData = graph . _nodes . get ( node ) ; if ( type !== 'undirected' ) { if ( direction !== 'out' && typeof nodeData . in !== 'undefined' ) { for ( const k in nodeData . in ) if ( k === neighbor ) return true ; } if ( direction !== 'in' && typeof nodeData . out !== 'undefined' ) { for ( const k in nodeData . out ) if ( k === neighbor ) return true ; } } if ( type !== 'directed' && typeof nodeData . undirected !== 'undefined' ) { for ( const k in nodeData . undirected ) if ( k === neighbor ) return true ; } return false ; }
Function returning whether the given node has target neighbor.

@param  {Graph}        graph     - Target graph.
@param  {string}       type      - Type of neighbor.
@param  {string}       direction - Direction.
@param  {any}          node      - Target node.
@param  {any}          neighbor  - Target neighbor.
@return {boolean}
Function returning whether the given node has target neighbor .