<commit_before>module Pacer
  import com.tinkerpop.blueprints.pgm.impls.tg.TinkerGraph
  import com.tinkerpop.blueprints.pgm.impls.tg.TinkerVertex
  import com.tinkerpop.blueprints.pgm.impls.tg.TinkerEdge

  # Create a new TinkerGraph. If path is given, import the GraphML data from
  # the file specified.
  def self.tg(path = nil)
    graph = TinkerGraph.new
    if path
      graph.import(path)
    end
    graph
  end


  # Extend the java class imported from blueprints.
  class TinkerGraph
    include Routes::Base
    include Routes::GraphRoute

    # TODO: set the vertex graph when the vertex is created
    # Load and initialize a vertex by id.
    def vertex(id)
      if v = get_vertex(id)
        v.graph = self
        v
      end
    end

    # TODO: set the edge graph when the edge is created
    # Load and initialize an edge by id.
    def edge(id)
      if e = get_edge(id)
        e.graph = self
        e
      end
    end

    # Override to return an enumeration-friendly array of vertices.
    def get_vertices
      getVertices.to_a
    end

    # Override to return an enumeration-friendly array of edges.
    def get_edges
      getEdges.to_a
    end

    def ==(other)
      other.class == self.class and other.object_id == self.object_id
    end

    # Discourage use of the native getVertex and getEdge methods
    protected :get_vertex, :getVertex, :get_edge, :getEdge
  end


  # Extend the java class imported from blueprints.
  class TinkerVertex
    include Routes::VerticesRouteModule
    include ElementMixin
    include VertexMixin
  end


  # Extend the java class imported from blueprints.
  class TinkerEdge
    include Routes::EdgesRouteModule
    include ElementMixin
    include EdgeMixin
  end
end<commit_msg>Tie tinker graph elements to their graph when they are created.<commit_after>module Pacer
  import com.tinkerpop.blueprints.pgm.impls.tg.TinkerGraph
  import com.tinkerpop.blueprints.pgm.impls.tg.TinkerVertex
  import com.tinkerpop.blueprints.pgm.impls.tg.TinkerEdge

  # Create a new TinkerGraph. If path is given, import the GraphML data from
  # the file specified.
  def self.tg(path = nil)
    graph = TinkerGraph.new
    if path
      graph.import(path)
    end
    graph
  end


  # Extend the java class imported from blueprints.
  class TinkerGraph
    include Routes::Base
    include Routes::GraphRoute

    alias vertex get_vertex
    alias edge get_edge

    # Override to return an enumeration-friendly array of vertices.
    def get_vertices
      getVertices.to_a
    end

    # Override to return an enumeration-friendly array of edges.
    def get_edges
      getEdges.to_a
    end

    def ==(other)
      other.class == self.class and other.object_id == self.object_id
    end

    alias original_add_edge addEdge
    def add_edge(*args)
      v = original_add_edge(*args)
      v.graph = self
      v
    end
    alias addEdge add_edge

    alias original_add_vertex addVertex
    def add_vertex(*args)
      v = original_add_vertex(*args)
      v.graph = self
      v
    end
    alias addVertex add_vertex
  end


  # Extend the java class imported from blueprints.
  class TinkerVertex
    include Routes::VerticesRouteModule
    include ElementMixin
    include VertexMixin
  end


  # Extend the java class imported from blueprints.
  class TinkerEdge
    include Routes::EdgesRouteModule
    include ElementMixin
    include EdgeMixin
  end
end
{'fraction_non_alphanumeric': 0.0545985401459854, 'fraction_numerical': 0.0, 'mean_word_length': 2.7118093174431204, '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': '2525668', 'n_tokens_mistral': 1088, 'n_tokens_neox': 1033, 'n_words': 339}