def inboundNodes()

in cassovary-core/src/main/scala/com/twitter/cassovary/graph/Node.scala [35:148]


  def inboundNodes(): CSeq[Int]

  /**
   * Returns up to `max` nodes that this node points to.
   * @param max the max number of nodes it needs
   * @return a sequence of inboundNode ids
   */
  def inboundNodes(max: Int): CSeq[Int] = inboundNodes().slice(0, max)

  /**
   * Returns a random node from the set of nodes that points to this node or else `None` if
   * this node has no inbound edges.
   *
   * The default implementation picks a random node from `inboundNodes()` so subclasses
   * should consider overriding this method if the `Seq` sequence they produce is not
   * a `IndexedSeq`.
   *
   * @return a sequence of random node ids
   */
  def randomInboundNode: Option[Int] = randomInboundNode(Node.randGen)

  /**
   * Returns a random node from the set of nodes that points to this node or else `None` if
   * this node has no inbound edges, using the supplied random number generator `rnd`.
   * @param rnd user defined random number generator
   * @return a random node id
   */
  def randomInboundNode(rnd: Random) = randomNode(inboundNodes(), rnd)

  /**
   * Returns a random sample of size at most `numResults` from the set of nodes
   * that point to this node using the supplied random number generator `rnd`.
   * @param numResults max number of random nodes needed
   * @param rnd user defined random number generator
   * @return a set of random node id
   */
  def randomInboundNodeSet(numResults: Int, rnd: Random): Seq[Int] =
    randomNodeSet(inboundNodes, numResults, rnd)

  /**
   * Returns `true` if the given `nodeId` points to this node.
   * @param nodeId host node id
   * @return a set of random node id
   */
  def isInboundNode(nodeId: Int): Boolean = containsNode(inboundNodes, nodeId)

  /**
   * @return the total number of inbound edges.
   */
  def inboundCount: Int = inboundNodes.length

  /**
   * @return all nodes this node points to.
   */
  def outboundNodes(): CSeq[Int]

  /**
   * @param max the maximum number of outBound nodes needed.
   * @return up to `max` nodes that this node points to.
   */
  def outboundNodes(max: Int): CSeq[Int] = outboundNodes().slice(0, max)

  /**
   * Returns a random node from the set of nodes that this node points to or else `None` if
   * this node has no outbound edges.
   *
   * The default implementation picks a random node from `outboundNodes()` so subclasses
   * should consider overriding this method if the `Seq` sequence they produce is not
   * a lazy `IndexedSeq`.
   *
   * @return a random node that this node points to.
   */
  def randomOutboundNode: Option[Int] = randomOutboundNode(Node.randGen)

  /**
   * Returns a random node from the set of nodes that this node points to or else `None` if
   * this node has no outbound edges, using the supplied random number generator `rnd`.
   * @param rnd a user defined random number generator.
   * @return a random node that this node points to.
   */
  def randomOutboundNode(rnd: Random) = randomNode(outboundNodes, rnd)

  /**
   * Returns a random sample of size at most `numResults` from the set of nodes
   * that this node points to using the supplied random number generator `rnd`.
   * @param rnd a user defined random number generator.
   * @return a set of random nodes that this node points to.
   */
  def randomOutboundNodeSet(numResults: Int, rnd: Random): Seq[Int] =
      randomNodeSet(outboundNodes, numResults, rnd)

  /**
   * Returns `true` if the this node point to the given `node`.
   * @param nodeId home node id
   * @return a boolean indicating whether outbound nodes contains `nodeId`.
   */
  def isOutboundNode(nodeId: Int): Boolean = containsNode(outboundNodes, nodeId)

  /**
   * @return the total number of outbound edges.
   */
  def outboundCount: Int = outboundNodes.length

  /**
   * A method that return either inbound or outbound allowing direction `dir`.
   * @param dir the direction (inbound or outbound) that the method is applied to.
   * @return a sequence of inbound or outbound neighbors.
   */
  def neighborIds(dir: GraphDir): CSeq[Int] = {
    dir match {
      case OutDir => outboundNodes
      case InDir => inboundNodes
    }
  }