This file is indexed.

/usr/share/doc/python-rdflib-doc/html/intro_to_graphs.html is in python-rdflib-doc 4.1.2-3.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    

    <title>Navigating Graphs &mdash; rdflib 4.1.2 documentation</title>

<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;"/>


    
    <link rel="stylesheet" href="_static/rtd.css" type="text/css" />
    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
    
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    './',
        VERSION:     '4.1.2',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="_static/jquery.js"></script>
    <script type="text/javascript" src="_static/underscore.js"></script>
    <script type="text/javascript" src="_static/doctools.js"></script>
    <script type="text/javascript" src="_static/searchtools.js"></script>
    <link rel="top" title="rdflib 4.1.2 documentation" href="index.html" />
    <link rel="next" title="Querying with SPARQL" href="intro_to_sparql.html" />
    <link rel="prev" title="Creating RDF triples" href="intro_to_creating_rdf.html" /> 
  </head>
  <body>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="intro_to_sparql.html" title="Querying with SPARQL"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="intro_to_creating_rdf.html" title="Creating RDF triples"
             accesskey="P">previous</a> |</li>
        <li><a href="index.html">rdflib 4.1.2 documentation</a> &raquo;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <div class="section" id="navigating-graphs">
<h1>Navigating Graphs<a class="headerlink" href="#navigating-graphs" title="Permalink to this headline"></a></h1>
<p>An RDF Graph is a set of RDF triples, and we try to mirror exactly this in RDFLib, and the graph tries to emulate a container type:</p>
<div class="section" id="graphs-as-iterators">
<h2>Graphs as Iterators<a class="headerlink" href="#graphs-as-iterators" title="Permalink to this headline"></a></h2>
<p>RDFLib graphs override <a class="reference internal" href="apidocs/rdflib.html#rdflib.graph.Graph.__iter__" title="rdflib.graph.Graph.__iter__"><tt class="xref py py-meth docutils literal"><span class="pre">__iter__()</span></tt></a> in order to support iteration over the contained triples:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="k">for</span> <span class="n">subject</span><span class="p">,</span><span class="n">predicate</span><span class="p">,</span><span class="n">obj</span> <span class="ow">in</span> <span class="n">someGraph</span><span class="p">:</span>
   <span class="k">if</span> <span class="ow">not</span> <span class="p">(</span><span class="n">subject</span><span class="p">,</span><span class="n">predicate</span><span class="p">,</span><span class="n">obj</span><span class="p">)</span> <span class="ow">in</span> <span class="n">someGraph</span><span class="p">:</span>
      <span class="k">raise</span> <span class="ne">Exception</span><span class="p">(</span><span class="s">&quot;Iterator / Container Protocols are Broken!!&quot;</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="section" id="contains-check">
<h2>Contains check<a class="headerlink" href="#contains-check" title="Permalink to this headline"></a></h2>
<p>Graphs implement <a class="reference internal" href="apidocs/rdflib.html#rdflib.graph.Graph.__contains__" title="rdflib.graph.Graph.__contains__"><tt class="xref py py-meth docutils literal"><span class="pre">__contains__()</span></tt></a>, so you can check if a triple is in a graph with <tt class="docutils literal"><span class="pre">triple</span> <span class="pre">in</span> <span class="pre">graph</span></tt> syntax:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">rdflib</span> <span class="kn">import</span> <span class="n">URIRef</span>
<span class="kn">from</span> <span class="nn">rdflib.namespace</span> <span class="kn">import</span> <span class="n">RDF</span>
<span class="n">bob</span> <span class="o">=</span> <span class="n">URIRef</span><span class="p">(</span><span class="s">&quot;http://example.org/people/bob&quot;</span><span class="p">)</span>
<span class="k">if</span> <span class="p">(</span> <span class="n">bob</span><span class="p">,</span> <span class="n">RDF</span><span class="o">.</span><span class="n">type</span><span class="p">,</span> <span class="n">FOAF</span><span class="o">.</span><span class="n">Person</span> <span class="p">)</span> <span class="ow">in</span> <span class="n">graph</span><span class="p">:</span>
   <span class="k">print</span> <span class="s">&quot;This graph knows that Bob is a person!&quot;</span>
</pre></div>
</div>
<p>Note that this triple does not have to be completely bound:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="k">if</span> <span class="p">(</span><span class="n">bob</span><span class="p">,</span> <span class="bp">None</span><span class="p">,</span> <span class="bp">None</span><span class="p">)</span> <span class="ow">in</span> <span class="n">graph</span><span class="p">:</span>
   <span class="k">print</span> <span class="s">&quot;This graph contains triples about Bob!&quot;</span>
</pre></div>
</div>
</div>
<div class="section" id="set-operations-on-rdflib-graphs">
<span id="graph-setops"></span><h2>Set Operations on RDFLib Graphs<a class="headerlink" href="#set-operations-on-rdflib-graphs" title="Permalink to this headline"></a></h2>
<p>Graphs override several pythons operators: <a class="reference internal" href="apidocs/rdflib.html#rdflib.graph.Graph.__iadd__" title="rdflib.graph.Graph.__iadd__"><tt class="xref py py-meth docutils literal"><span class="pre">__iadd__()</span></tt></a>, <a class="reference internal" href="apidocs/rdflib.html#rdflib.graph.Graph.__isub__" title="rdflib.graph.Graph.__isub__"><tt class="xref py py-meth docutils literal"><span class="pre">__isub__()</span></tt></a>, etc. This supports addition, subtraction and other set-operations on Graphs:</p>
<table border="1" class="docutils">
<colgroup>
<col width="19%" />
<col width="81%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">operation</th>
<th class="head">effect</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td><tt class="docutils literal"><span class="pre">G1</span> <span class="pre">+</span> <span class="pre">G2</span></tt></td>
<td>return new graph with union</td>
</tr>
<tr class="row-odd"><td><tt class="docutils literal"><span class="pre">G1</span> <span class="pre">+=</span> <span class="pre">G1</span></tt></td>
<td>in place union / addition</td>
</tr>
<tr class="row-even"><td><tt class="docutils literal"><span class="pre">G1</span> <span class="pre">-</span> <span class="pre">G2</span></tt></td>
<td>return new graph with difference</td>
</tr>
<tr class="row-odd"><td><tt class="docutils literal"><span class="pre">G1</span> <span class="pre">-=</span> <span class="pre">G2</span></tt></td>
<td>in place difference / subtraction</td>
</tr>
<tr class="row-even"><td><tt class="docutils literal"><span class="pre">G1</span> <span class="pre">&amp;</span> <span class="pre">G2</span></tt></td>
<td>intersection (triples in both graphs)</td>
</tr>
<tr class="row-odd"><td><tt class="docutils literal"><span class="pre">G1</span> <span class="pre">^</span> <span class="pre">G2</span></tt></td>
<td>xor (triples in either G1 or G2, but not in both)</td>
</tr>
</tbody>
</table>
<div class="admonition warning">
<p class="first admonition-title">Warning</p>
<p class="last">Set-operations on graphs assume bnodes are shared between graphs. This may or may not do what you want. See <a class="reference internal" href="merging.html"><em>Merging graphs</em></a> for details.</p>
</div>
</div>
<div class="section" id="basic-triple-matching">
<h2>Basic Triple Matching<a class="headerlink" href="#basic-triple-matching" title="Permalink to this headline"></a></h2>
<p>Instead of iterating through all triples, RDFLib graphs support basic triple pattern matching with a <a class="reference internal" href="apidocs/rdflib.html#rdflib.graph.Graph.triples" title="rdflib.graph.Graph.triples"><tt class="xref py py-meth docutils literal"><span class="pre">triples()</span></tt></a> function.
This function is a generator of triples that match the pattern given by the arguments.  The arguments of these are RDF terms that restrict the triples that are returned.  Terms that are <tt class="xref py py-data docutils literal"><span class="pre">None</span></tt> are treated as a wildcard. For example:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">g</span><span class="o">.</span><span class="n">load</span><span class="p">(</span><span class="s">&quot;some_foaf.rdf&quot;</span><span class="p">)</span>
<span class="k">for</span> <span class="n">s</span><span class="p">,</span><span class="n">p</span><span class="p">,</span><span class="n">o</span> <span class="ow">in</span> <span class="n">g</span><span class="o">.</span><span class="n">triples</span><span class="p">(</span> <span class="p">(</span><span class="bp">None</span><span class="p">,</span> <span class="n">RDF</span><span class="o">.</span><span class="n">type</span><span class="p">,</span> <span class="n">FOAF</span><span class="o">.</span><span class="n">Person</span><span class="p">)</span> <span class="p">):</span>
   <span class="k">print</span> <span class="s">&quot;</span><span class="si">%s</span><span class="s"> is a person&quot;</span><span class="o">%</span><span class="n">s</span>

<span class="k">for</span> <span class="n">s</span><span class="p">,</span><span class="n">p</span><span class="p">,</span><span class="n">o</span> <span class="ow">in</span> <span class="n">g</span><span class="o">.</span><span class="n">triples</span><span class="p">(</span> <span class="p">(</span><span class="bp">None</span><span class="p">,</span>  <span class="n">RDF</span><span class="o">.</span><span class="n">type</span><span class="p">,</span> <span class="bp">None</span><span class="p">)</span> <span class="p">):</span>
   <span class="k">print</span> <span class="s">&quot;</span><span class="si">%s</span><span class="s"> is a </span><span class="si">%s</span><span class="s">&quot;</span><span class="o">%</span><span class="p">(</span><span class="n">s</span><span class="p">,</span><span class="n">o</span><span class="p">)</span>

<span class="n">bobgraph</span> <span class="o">=</span> <span class="n">Graph</span><span class="p">()</span>

<span class="n">bobgraph</span> <span class="o">+=</span> <span class="n">g</span><span class="o">.</span><span class="n">triples</span><span class="p">(</span> <span class="p">(</span><span class="n">bob</span><span class="p">,</span> <span class="bp">None</span><span class="p">,</span> <span class="bp">None</span><span class="p">)</span> <span class="p">)</span>
</pre></div>
</div>
<p>If you are not interested in whole triples, you can get only the bits you want with the methods <a class="reference internal" href="apidocs/rdflib.html#rdflib.graph.Graph.objects" title="rdflib.graph.Graph.objects"><tt class="xref py py-meth docutils literal"><span class="pre">objects()</span></tt></a>, <a class="reference internal" href="apidocs/rdflib.html#rdflib.graph.Graph.subjects" title="rdflib.graph.Graph.subjects"><tt class="xref py py-meth docutils literal"><span class="pre">subjects()</span></tt></a>, <a class="reference internal" href="apidocs/rdflib.html#rdflib.graph.Graph.predicates" title="rdflib.graph.Graph.predicates"><tt class="xref py py-meth docutils literal"><span class="pre">predicates()</span></tt></a>, <tt class="xref py py-meth docutils literal"><span class="pre">predicates_objects()</span></tt>, etc. Each take parameters for the components of the triple to constraint:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="k">for</span> <span class="n">person</span> <span class="ow">in</span> <span class="n">g</span><span class="o">.</span><span class="n">subjects</span><span class="p">(</span><span class="n">RDF</span><span class="o">.</span><span class="n">type</span><span class="p">,</span> <span class="n">FOAF</span><span class="o">.</span><span class="n">Person</span><span class="p">):</span>
   <span class="k">print</span> <span class="s">&quot;</span><span class="si">%s</span><span class="s"> is a person&quot;</span><span class="o">%</span><span class="n">person</span>
</pre></div>
</div>
<p>Finally, for some properties, only one value per resource makes sense (i.e they are <em>functional properties</em>, or have max-cardinality of 1). The <a class="reference internal" href="apidocs/rdflib.html#rdflib.graph.Graph.value" title="rdflib.graph.Graph.value"><tt class="xref py py-meth docutils literal"><span class="pre">value()</span></tt></a> method is useful for this, as it returns just a single node, not a generator:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">name</span> <span class="o">=</span> <span class="n">g</span><span class="o">.</span><span class="n">value</span><span class="p">(</span><span class="n">bob</span><span class="p">,</span> <span class="n">FOAF</span><span class="o">.</span><span class="n">name</span><span class="p">)</span> <span class="c"># get any name of bob</span>
<span class="c"># get the one person that knows bob and raise an exception if more are found</span>
<span class="n">mbox</span> <span class="o">=</span> <span class="n">g</span><span class="o">.</span><span class="n">value</span><span class="p">(</span><span class="n">predicate</span> <span class="o">=</span> <span class="n">FOAF</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="nb">object</span> <span class="o">=</span> <span class="n">bob</span><span class="p">,</span> <span class="nb">any</span> <span class="o">=</span> <span class="bp">False</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="section" id="graph-methods-for-accessing-triples">
<h2><a class="reference internal" href="apidocs/rdflib.html#rdflib.graph.Graph" title="rdflib.graph.Graph"><tt class="xref py py-class docutils literal"><span class="pre">Graph</span></tt></a> methods for accessing triples<a class="headerlink" href="#graph-methods-for-accessing-triples" title="Permalink to this headline"></a></h2>
<p>Here is a list of all convenience methods for querying Graphs:</p>
<dl class="method">
<dt>
<tt class="descclassname">Graph.</tt><tt class="descname">label</tt><big>(</big><em>subject</em>, <em>default=''</em><big>)</big><a class="reference internal" href="_modules/rdflib/graph.html#Graph.label"><span class="viewcode-link">[source]</span></a></dt>
<dd><p>Query for the RDFS.label of the subject</p>
<p>Return default if no label exists or any label if multiple exist.</p>
</dd></dl>

<dl class="method">
<dt>
<tt class="descclassname">Graph.</tt><tt class="descname">preferredLabel</tt><big>(</big><em>subject</em>, <em>lang=None</em>, <em>default=None</em>, <em>labelProperties=(rdflib.term.URIRef(u'http://www.w3.org/2004/02/skos/core#prefLabel')</em>, <em>rdflib.term.URIRef(u'http://www.w3.org/2000/01/rdf-schema#label'))</em><big>)</big><a class="reference internal" href="_modules/rdflib/graph.html#Graph.preferredLabel"><span class="viewcode-link">[source]</span></a></dt>
<dd><p>Find the preferred label for subject.</p>
<p>By default prefers skos:prefLabels over rdfs:labels. In case at least
one prefLabel is found returns those, else returns labels. In case a
language string (e.g., &#8216;en&#8217;, &#8216;de&#8217; or even &#8216;&#8217; for no lang-tagged
literals) is given, only such labels will be considered.</p>
<p>Return a list of (labelProp, label) pairs, where labelProp is either
skos:prefLabel or rdfs:label.</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">rdflib</span> <span class="kn">import</span> <span class="n">ConjunctiveGraph</span><span class="p">,</span> <span class="n">URIRef</span><span class="p">,</span> <span class="n">RDFS</span><span class="p">,</span> <span class="n">Literal</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">rdflib.namespace</span> <span class="kn">import</span> <span class="n">SKOS</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">pprint</span> <span class="kn">import</span> <span class="n">pprint</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">g</span> <span class="o">=</span> <span class="n">ConjunctiveGraph</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">u</span> <span class="o">=</span> <span class="n">URIRef</span><span class="p">(</span><span class="s">u&#39;http://example.com/foo&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">g</span><span class="o">.</span><span class="n">add</span><span class="p">([</span><span class="n">u</span><span class="p">,</span> <span class="n">RDFS</span><span class="o">.</span><span class="n">label</span><span class="p">,</span> <span class="n">Literal</span><span class="p">(</span><span class="s">&#39;foo&#39;</span><span class="p">)])</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">g</span><span class="o">.</span><span class="n">add</span><span class="p">([</span><span class="n">u</span><span class="p">,</span> <span class="n">RDFS</span><span class="o">.</span><span class="n">label</span><span class="p">,</span> <span class="n">Literal</span><span class="p">(</span><span class="s">&#39;bar&#39;</span><span class="p">)])</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">pprint</span><span class="p">(</span><span class="nb">sorted</span><span class="p">(</span><span class="n">g</span><span class="o">.</span><span class="n">preferredLabel</span><span class="p">(</span><span class="n">u</span><span class="p">)))</span>
<span class="go">[(rdflib.term.URIRef(u&#39;http://www.w3.org/2000/01/rdf-schema#label&#39;),</span>
<span class="go">  rdflib.term.Literal(u&#39;bar&#39;)),</span>
<span class="go"> (rdflib.term.URIRef(u&#39;http://www.w3.org/2000/01/rdf-schema#label&#39;),</span>
<span class="go">  rdflib.term.Literal(u&#39;foo&#39;))]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">g</span><span class="o">.</span><span class="n">add</span><span class="p">([</span><span class="n">u</span><span class="p">,</span> <span class="n">SKOS</span><span class="o">.</span><span class="n">prefLabel</span><span class="p">,</span> <span class="n">Literal</span><span class="p">(</span><span class="s">&#39;bla&#39;</span><span class="p">)])</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">pprint</span><span class="p">(</span><span class="n">g</span><span class="o">.</span><span class="n">preferredLabel</span><span class="p">(</span><span class="n">u</span><span class="p">))</span>
<span class="go">[(rdflib.term.URIRef(u&#39;http://www.w3.org/2004/02/skos/core#prefLabel&#39;),</span>
<span class="go">  rdflib.term.Literal(u&#39;bla&#39;))]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">g</span><span class="o">.</span><span class="n">add</span><span class="p">([</span><span class="n">u</span><span class="p">,</span> <span class="n">SKOS</span><span class="o">.</span><span class="n">prefLabel</span><span class="p">,</span> <span class="n">Literal</span><span class="p">(</span><span class="s">&#39;blubb&#39;</span><span class="p">,</span> <span class="n">lang</span><span class="o">=</span><span class="s">&#39;en&#39;</span><span class="p">)])</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">sorted</span><span class="p">(</span><span class="n">g</span><span class="o">.</span><span class="n">preferredLabel</span><span class="p">(</span><span class="n">u</span><span class="p">))</span> 
<span class="go">[(rdflib.term.URIRef(u&#39;http://www.w3.org/2004/02/skos/core#prefLabel&#39;),</span>
<span class="go">  rdflib.term.Literal(u&#39;bla&#39;)),</span>
<span class="go">  (rdflib.term.URIRef(u&#39;http://www.w3.org/2004/02/skos/core#prefLabel&#39;),</span>
<span class="go">  rdflib.term.Literal(u&#39;blubb&#39;, lang=&#39;en&#39;))]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">g</span><span class="o">.</span><span class="n">preferredLabel</span><span class="p">(</span><span class="n">u</span><span class="p">,</span> <span class="n">lang</span><span class="o">=</span><span class="s">&#39;&#39;</span><span class="p">)</span> 
<span class="go">[(rdflib.term.URIRef(u&#39;http://www.w3.org/2004/02/skos/core#prefLabel&#39;),</span>
<span class="go">  rdflib.term.Literal(u&#39;bla&#39;))]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">pprint</span><span class="p">(</span><span class="n">g</span><span class="o">.</span><span class="n">preferredLabel</span><span class="p">(</span><span class="n">u</span><span class="p">,</span> <span class="n">lang</span><span class="o">=</span><span class="s">&#39;en&#39;</span><span class="p">))</span>
<span class="go">[(rdflib.term.URIRef(u&#39;http://www.w3.org/2004/02/skos/core#prefLabel&#39;),</span>
<span class="go">  rdflib.term.Literal(u&#39;blubb&#39;, lang=&#39;en&#39;))]</span>
</pre></div>
</div>
</dd></dl>

<dl class="method">
<dt>
<tt class="descclassname">Graph.</tt><tt class="descname">triples</tt><big>(</big><em>(s</em>, <em>p</em>, <em>o)</em><big>)</big><a class="reference internal" href="_modules/rdflib/graph.html#Graph.triples"><span class="viewcode-link">[source]</span></a></dt>
<dd><p>Generator over the triple store</p>
<p>Returns triples that match the given triple pattern. If triple pattern
does not provide a context, all contexts will be searched.</p>
</dd></dl>

<dl class="method">
<dt>
<tt class="descclassname">Graph.</tt><tt class="descname">value</tt><big>(</big><em>subject=None</em>, <em>predicate=rdflib.term.URIRef(u'http://www.w3.org/1999/02/22-rdf-syntax-ns#value')</em>, <em>object=None</em>, <em>default=None</em>, <em>any=True</em><big>)</big><a class="reference internal" href="_modules/rdflib/graph.html#Graph.value"><span class="viewcode-link">[source]</span></a></dt>
<dd><p>Get a value for a pair of two criteria</p>
<p>Exactly one of subject, predicate, object must be None. Useful if one
knows that there may only be one value.</p>
<p>It is one of those situations that occur a lot, hence this
&#8216;macro&#8217; like utility</p>
<p>Parameters:
subject, predicate, object  &#8211; exactly one must be None
default &#8211; value to be returned if no values found
any &#8211; if True, return any value in the case there is more than one,
else, raise UniquenessError</p>
</dd></dl>

<dl class="method">
<dt>
<tt class="descclassname">Graph.</tt><tt class="descname">subjects</tt><big>(</big><em>predicate=None</em>, <em>object=None</em><big>)</big><a class="reference internal" href="_modules/rdflib/graph.html#Graph.subjects"><span class="viewcode-link">[source]</span></a></dt>
<dd><p>A generator of subjects with the given predicate and object</p>
</dd></dl>

<dl class="method">
<dt>
<tt class="descclassname">Graph.</tt><tt class="descname">objects</tt><big>(</big><em>subject=None</em>, <em>predicate=None</em><big>)</big><a class="reference internal" href="_modules/rdflib/graph.html#Graph.objects"><span class="viewcode-link">[source]</span></a></dt>
<dd><p>A generator of objects with the given subject and predicate</p>
</dd></dl>

<dl class="method">
<dt>
<tt class="descclassname">Graph.</tt><tt class="descname">predicates</tt><big>(</big><em>subject=None</em>, <em>object=None</em><big>)</big><a class="reference internal" href="_modules/rdflib/graph.html#Graph.predicates"><span class="viewcode-link">[source]</span></a></dt>
<dd><p>A generator of predicates with the given subject and object</p>
</dd></dl>

<dl class="method">
<dt>
<tt class="descclassname">Graph.</tt><tt class="descname">subject_objects</tt><big>(</big><em>predicate=None</em><big>)</big><a class="reference internal" href="_modules/rdflib/graph.html#Graph.subject_objects"><span class="viewcode-link">[source]</span></a></dt>
<dd><p>A generator of (subject, object) tuples for the given predicate</p>
</dd></dl>

<dl class="method">
<dt>
<tt class="descclassname">Graph.</tt><tt class="descname">subject_predicates</tt><big>(</big><em>object=None</em><big>)</big><a class="reference internal" href="_modules/rdflib/graph.html#Graph.subject_predicates"><span class="viewcode-link">[source]</span></a></dt>
<dd><p>A generator of (subject, predicate) tuples for the given object</p>
</dd></dl>

<dl class="method">
<dt>
<tt class="descclassname">Graph.</tt><tt class="descname">predicate_objects</tt><big>(</big><em>subject=None</em><big>)</big><a class="reference internal" href="_modules/rdflib/graph.html#Graph.predicate_objects"><span class="viewcode-link">[source]</span></a></dt>
<dd><p>A generator of (predicate, object) tuples for the given subject</p>
</dd></dl>

</div>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
            <p class="logo"><a href="index.html">
              <img class="logo" src="_static/logo.svg" alt="Logo"/>
            </a></p>
  <h3><a href="index.html">Table Of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">Navigating Graphs</a><ul>
<li><a class="reference internal" href="#graphs-as-iterators">Graphs as Iterators</a></li>
<li><a class="reference internal" href="#contains-check">Contains check</a></li>
<li><a class="reference internal" href="#set-operations-on-rdflib-graphs">Set Operations on RDFLib Graphs</a></li>
<li><a class="reference internal" href="#basic-triple-matching">Basic Triple Matching</a></li>
<li><a class="reference internal" href="#graph-methods-for-accessing-triples"><tt class="docutils literal"><span class="pre">Graph</span></tt> methods for accessing triples</a></li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="intro_to_creating_rdf.html"
                        title="previous chapter">Creating RDF triples</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="intro_to_sparql.html"
                        title="next chapter">Querying with SPARQL</a></p>
  <h3>This Page</h3>
  <ul class="this-page-menu">
    <li><a href="_sources/intro_to_graphs.txt"
           rel="nofollow">Show Source</a></li>
  </ul>
<div id="searchbox" style="display: none">
  <h3>Quick search</h3>
    <form class="search" action="search.html" method="get">
      <input type="text" name="q" />
      <input type="submit" value="Go" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    <p class="searchtip" style="font-size: 90%">
    Enter search terms or a module, class or function name.
    </p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="intro_to_sparql.html" title="Querying with SPARQL"
             >next</a> |</li>
        <li class="right" >
          <a href="intro_to_creating_rdf.html" title="Creating RDF triples"
             >previous</a> |</li>
        <li><a href="index.html">rdflib 4.1.2 documentation</a> &raquo;</li> 
      </ul>
    </div>
<div class="footer">
    &copy; Copyright 2009 - 2013, RDFLib Team.
  Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.2.2.
  <br />Theme based on <a href="http://readthedocs.org/">Read The Docs</a>

</div>





  </body>
</html>