class RDF::Graph

An RDF graph.

An {RDF::Graph} contains a unique set of {RDF::Statement}. It is based on an underlying data object, which may be specified when the graph is initialized, and will default to a {RDF::Repository} without support for named graphs otherwise.

Note that in RDF 1.1, graphs are not named, but are associated with a graph name in a Dataset, as a pair of <name, graph>. This class allows a name to be associated with a graph when it is a projection of an underlying {RDF::Repository} supporting graph_names.

@example Creating an empty unnamed graph

graph = RDF::Graph.new

@example Loading graph data from a URL

graph = RDF::Graph.load("http://ruby-rdf.github.io/rdf/etc/doap.nt")

@example Loading graph data from a URL

require 'rdf/rdfxml'  # for RDF/XML support

graph = RDF::Graph.load("http://www.bbc.co.uk/programmes/b0081dq5.rdf")

@example Accessing a specific named graph within a {RDF::Repository}

require 'rdf/trig'  # for TriG support

repository = graph = RDF::Repository.load("https://raw.githubusercontent.com/ruby-rdf/rdf-trig/develop/etc/doap.trig", format: :trig))
graph = RDF::Graph.new(graph_name: RDF::URI("http://greggkellogg.net/foaf#me"), data: repository)