Module: RGraph::IO::GraphML

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

Overview

GraphML

Defined Under Namespace

Modules: Read

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object

Adds class methods.



18
19
20
# File 'lib/rgraph/io/graph_ml.rb', line 18

def self.included(base)
  base.extend(GraphML::Read)
end

Instance Method Details

#write(path, prefixattr: false) ⇒ Object

Writes the graph to a file in GraphML format.

Parameters:

  • path (String)

    Path to an output file.

  • prefixattr (Boolean) (defaults to: false)

    Indicates whether to put a prefix in front of the attribute names to ensure uniqueness.



32
33
34
35
36
37
38
39
40
41
# File 'lib/rgraph/io/graph_ml.rb', line 32

def write(path, prefixattr: false)
  file_pointer = Bindings::C.fopen(path, "w")

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

  Bindings.igraph_write_graph_graphml(self, file_pointer, prefixattr)
  Bindings::C.fclose(file_pointer)
end