<commit_before>_              = require('lodash')
log            = require('loglevel')
GraphPrimitive = require('./graph-primitive')

class Node extends GraphPrimitive
  constructor: (nodeSpec={x:0,y:0,title:"untitled",image:null},key) ->
    super()
    if key
      @key = key
    @links = []
    @x = nodeSpec.x
    @y = nodeSpec.y
    @title = nodeSpec.title
    @image = nodeSpec.image

  type: () ->
    "Node"

  addLink: (link) ->
    if link.sourceNode == @ || link.targetNode == @
      if _.contains(@links, link)
        throw new Error "Duplicate link for Node:#{@.id}"
      @links.push(link)
    else
      throw new Error "Bad link for Node:#{@.id}"

  outLinks: () ->
    _.filter @links, (link) =>
      if (link.sourceNode == @)
        return true
      return false

  inLinks: () ->
    _.filter @links, (link) =>
      if (link.targetNode == @)
        return true
      return false

  infoString: () ->
    linkNamer = (link) =>
      " --#{link.title}-->[#{link.targetNode.title}]"
    outs = (linkNamer link for link in @outLinks())
    "#{@title} #{outs}"

  downstreamNodes: () ->
    visitedNodes = []
    
    visit = (node) ->
      log.info("visiting node: #{node.id}")
      visitedNodes.push node
      _.each node.outLinks(), (link) ->
        downstreamNode = link.targetNode
        unless _.contains(visitedNodes, downstreamNode)
          visit(downstreamNode)
    visit(@)
    _.without(visitedNodes, @) # remove ourself from the results.

  toExport: () ->
    {   
      title: @title,
      x: @x,
      y: @y,
      image:@image,
      key: @key
    }
module.exports = Node<commit_msg>whitespace<commit_after>_              = require('lodash')
log            = require('loglevel')
GraphPrimitive = require('./graph-primitive')

class Node extends GraphPrimitive
  constructor: (nodeSpec={x:0,y:0,title:"untitled",image:null},key) ->
    super()
    if key
      @key = key
    @links = []
    @x = nodeSpec.x
    @y = nodeSpec.y
    @title = nodeSpec.title
    @image = nodeSpec.image

  type: () ->
    "Node"

  addLink: (link) ->
    if link.sourceNode == @ || link.targetNode == @
      if _.contains(@links, link)
        throw new Error "Duplicate link for Node:#{@.id}"
      @links.push(link)
    else
      throw new Error "Bad link for Node:#{@.id}"

  outLinks: () ->
    _.filter @links, (link) =>
      if (link.sourceNode == @)
        return true
      return false

  inLinks: () ->
    _.filter @links, (link) =>
      if (link.targetNode == @)
        return true
      return false

  infoString: () ->
    linkNamer = (link) =>
      " --#{link.title}-->[#{link.targetNode.title}]"
    outs = (linkNamer link for link in @outLinks())
    "#{@title} #{outs}"

  downstreamNodes: () ->
    visitedNodes = []
    
    visit = (node) ->
      log.info("visiting node: #{node.id}")
      visitedNodes.push node
      _.each node.outLinks(), (link) ->
        downstreamNode = link.targetNode
        unless _.contains(visitedNodes, downstreamNode)
          visit(downstreamNode)
    visit(@)
    _.without(visitedNodes, @) # remove ourself from the results.

  toExport: () ->
    {   
      title: @title,
      x: @x,
      y: @y,
      image: @image,
      key: @key
    }
module.exports = Node
{'fraction_non_alphanumeric': 0.15899324739103746, 'fraction_numerical': 0.0012277470841006752, 'mean_word_length': 2.2076771653543306, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6627173', 'n_tokens_mistral': 1067, 'n_tokens_neox': 1064, 'n_words': 244}