<commit_before># Chapter 4 Trees and Graphs

# 4.1 Route Between Nodes: Given a directed graph, design an algorithm to find out whether there is a route between two nodes.<commit_msg>Add Tree, Graph and Node classes<commit_after># Chapter 4 Trees and Graphs

class Tree
  attr_accessor :root
  def initialize(root = Node.new)
    @root = root
  end
end

class Graph
  attr_accessor :nodes
  def initialize(nodes)
    @nodes = nodes
  end
end

class Node
  attr_accessor :value, :children
  def initialize(value, children)
    @value = value
    @children = children
  end
  def to_s
    value.to_s
  end
end

# 4.1 Route Between Nodes: Given a directed graph, design an algorithm to find out whether there is a route between two nodes.
{'fraction_non_alphanumeric': 0.05714285714285714, 'fraction_numerical': 0.00816326530612245, 'mean_word_length': 3.6289308176100628, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5354001', 'n_tokens_mistral': 225, 'n_tokens_neox': 220, 'n_words': 99}