Class: Pacer::GraphML
- Inherits:
-
Object
- Object
- Pacer::GraphML
- Defined in:
- lib/pacer/graph/graph_ml.rb
Overview
Methods to be mixed into Blueprints Graph objects from any implementation.
Adds more convenient/rubyish methods and adds support for extensions to some methods where needed.
Class Method Summary collapse
-
.export(graph, path) ⇒ Object
Export the graph to GraphML.
-
.import(graph, path) ⇒ Object
Import the data in a GraphML file.
Class Method Details
.export(graph, path) ⇒ Object
Export the graph to GraphML
33 34 35 36 37 38 39 |
# File 'lib/pacer/graph/graph_ml.rb', line 33 def self.export(graph, path) path = File. path stream = java.io.FileOutputStream.new path com.tinkerpop.blueprints.util.io.graphml.GraphMLWriter.outputGraph graph.blueprints_graph, stream ensure stream.close if stream end |
.import(graph, path) ⇒ Object
Import the data in a GraphML file.
Will fail if the data already exsts in the current graph.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/pacer/graph/graph_ml.rb', line 13 def self.import(graph, path) path = File. path begin stream = java.net.URL.new(path).open_stream rescue java.net.MalformedURLException stream = java.io.FileInputStream.new path end graph.transaction(nesting: true) do graph.send :creating_elements do com.tinkerpop.blueprints.util.io.graphml.GraphMLReader.input_graph graph.blueprints_graph, stream end end true ensure stream.close if stream end |