Module: RGraph::IO::GraphML::Read

Defined in:
lib/rgraph/io/graph_ml.rb

Overview

Class methods

Instance Method Summary collapse

Instance Method Details

#read(path, instream = 0) ⇒ Graph

Reads the graph from a GraphML file.

Parameters:

  • path (String)

    Path to an input file.

  • instream (Integer) (defaults to: 0)

    A graphg index.

Returns:

  • (Graph)

    The graph instance.



59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/rgraph/io/graph_ml.rb', line 59

def read(path, instream = 0)
  file_pointer = Bindings::C.fopen(path, "r")

  if file_pointer.null?
    raise "Error: Openning a file with fopen failed."
  end

  Graph.new do |graph|
    Bindings.igraph_read_graph_graphml(graph, file_pointer, instream)
    Bindings::C.fclose(file_pointer)
  end
end