Graph Class Reference
from PyKDE4.soprano import *
Namespace: Soprano
Detailed Description
\class Graph graph.h Soprano/Graph
A simple collection of statements.
A Graph is a simple in-memory collection of Statements. It is supposed to be used where one needs a quick way to exchange or store a small number of statements. It is basically a fancy QSet of statements.
In comparision to Model it does not support queries, it does not use a specific backend plugin, and it is not optimized in any way.
One graph does not represent one named graph, i.e. one context, it can contain Statements with different context nodes.
- Since:
- 2.3
Method Documentation
| __init__ | ( | self ) |
Create an empty graph.
| __init__ | ( | self, | ||
| Soprano.Graph | a0 | |||
| ) |
Copy constructor.
| __init__ | ( | self, | ||
| [Soprano.Statement] | a0 | |||
| ) |
Create a graph from a list of statements.
\sa operator=(const QList<Statement>&)
| addStatement | ( | self, | ||
| Soprano.Statement | statement | |||
| ) |
Add the Statement to the Graph.
- Parameters:
-
statement The Statement to add.
| addStatement | ( | self, | ||
| Soprano.Node | subject, | |||
| Soprano.Node | predicate, | |||
| Soprano.Node | object, | |||
| Soprano.Node | context=Soprano.Node() | |||
| ) |
| addStatements | ( | self, | ||
| [Soprano.Statement] | statements | |||
| ) |
| bool containsAnyStatement | ( | self, | ||
| Soprano.Statement | statement | |||
| ) |
Check if the graph contains certain statements.
- Parameters:
-
statement A partially defined statement that serves as a pattern.
- Returns:
- true if the Graph contains a Statement matching the given statement pattern.
| bool containsAnyStatement | ( | self, | ||
| Soprano.Node | subject, | |||
| Soprano.Node | predicate, | |||
| Soprano.Node | object, | |||
| Soprano.Node | context=Soprano.Node() | |||
| ) |
- Parameters:
-
subject The subject node to match. Can be empty as a wildcard.
- Parameters:
-
predicate The predicate node to match. Can be empty as a wildcard.
- Parameters:
-
object The object node to match. Can be empty as a wildcard.
- Parameters:
-
context The context node to match. Can be empty as a wildcard.
| bool containsContext | ( | self, | ||
| Soprano.Node | context | |||
| ) |
Convenience method which is based on containsAnyStatement
| bool containsStatement | ( | self, | ||
| Soprano.Statement | statement | |||
| ) |
Check if the graph contains a statements.
- Parameters:
-
statement The statement in question. This has to be a valid statement, i.e. subject, predicate, and object need to be defined. If the context node is empty the default graph is searched.
- Returns:
- true if the Graph contains the Statement, false otherwise or is statement is invalid.
| bool containsStatement | ( | self, | ||
| Soprano.Node | subject, | |||
| Soprano.Node | predicate, | |||
| Soprano.Node | object, | |||
| Soprano.Node | context=Soprano.Node() | |||
| ) |
| bool isEmpty | ( | self ) |
- Returns:
- true if the Graph doesn't contains any Statement.
| Soprano.NodeIterator listContexts | ( | self ) |
List all contexts in the graph, i.e. all named graphs.
- Returns:
- An iterator over context Nodes, on error an invalid iterator is returned.
| Soprano.StatementIterator listStatements | ( | self, | ||
| Soprano.Statement | partial=Soprano.Statement() | |||
| ) |
Return an iterator over Graph Statements that "partial" match the input Statement.
- Parameters:
-
partial The partial Statement to match.
- Returns:
- An iterator for all the matched Statements, on error an invalid iterator is returned.
| Soprano.StatementIterator listStatements | ( | self, | ||
| Soprano.Node | subject, | |||
| Soprano.Node | predicate, | |||
| Soprano.Node | object, | |||
| Soprano.Node | context=Soprano.Node() | |||
| ) |
- Parameters:
-
subject The subject node to match. Can be empty as a wildcard.
- Parameters:
-
predicate The predicate node to match. Can be empty as a wildcard.
- Parameters:
-
object The object node to match. Can be empty as a wildcard.
- Parameters:
-
context The context node to match. Can be empty as a wildcard.
- Returns:
- An iterator for all the matched Statements, on error an invalid iterator is returned.
| Soprano.StatementIterator listStatementsInContext | ( | self, | ||
| Soprano.Node | context | |||
| ) |
Convenience method which lists all statements in context.
- Returns:
- An iterator for all the matched Statements, on error an invalid iterator is returned.
| bool operator != | ( | self, | ||
| Soprano.Graph | g | |||
| ) |
Comparision operator.
- Returns:
- true if this graph contains a statement
| Soprano.Graph operator + | ( | self, | ||
| Soprano.Graph | g | |||
| ) |
Returns a graph containing all statements from this graph and from g.
| Soprano.Graph operator + | ( | self, | ||
| Soprano.Statement | s | |||
| ) |
Returns a graph containing all statements from this graph and from s.
| Soprano.Graph operator += | ( | self, | ||
| Soprano.Graph | g | |||
| ) |
Inserts the statements in graph g into this graph and returns a reference to this graph.
| Soprano.Graph operator += | ( | self, | ||
| Soprano.Statement | s | |||
| ) |
Inserts the statement s into this graph and returns a reference to this graph.
| Soprano.Graph operator - | ( | self, | ||
| Soprano.Graph | a0 | |||
| ) |
Substracts all statements in g from this graph and returns a reference to this graph.
| Soprano.Graph operator - | ( | self, | ||
| Soprano.Statement | s | |||
| ) |
Substracts s from this graph and returns a reference to this graph.
| Soprano.Graph operator -= | ( | self, | ||
| Soprano.Graph | g | |||
| ) |
Removes the statements in graph g from this graph and returns a reference to this graph.
| Soprano.Graph operator -= | ( | self, | ||
| Soprano.Statement | s | |||
| ) |
Removes the statement s from this graph and returns a reference to this graph.
| Soprano.Graph operator << | ( | self, | ||
| Soprano.Graph | a0 | |||
| ) |
\sa operator+=
| Soprano.Graph operator << | ( | self, | ||
| Soprano.Statement | a0 | |||
| ) |
\sa operator+=
| bool operator == | ( | self, | ||
| Soprano.Graph | g | |||
| ) |
Comparision operator.
- Returns:
- true if this graph and g contain the same statements, false otherwise.
| removeAllStatements | ( | self, | ||
| Soprano.Statement | statement=Soprano.Statement() | |||
| ) |
Remove all statements that match the partial statement. For removing one specific statement see removeStatement().
- Parameters:
-
statement A possible partially defined statement that serves as a filter for all statements that should be removed.
| removeAllStatements | ( | self, | ||
| Soprano.Node | subject, | |||
| Soprano.Node | predicate, | |||
| Soprano.Node | object, | |||
| Soprano.Node | context=Soprano.Node() | |||
| ) |
- Parameters:
-
subject The subject node to match. Can be empty as a wildcard.
- Parameters:
-
predicate The predicate node to match. Can be empty as a wildcard.
- Parameters:
-
object The object node to match. Can be empty as a wildcard.
- Parameters:
-
context The context node to match. Can be empty as a wildcard.
| removeContext | ( | self, | ||
| Soprano.Node | a0 | |||
| ) |
Convenience method that removes all statements in the context.
| removeStatement | ( | self, | ||
| Soprano.Statement | statement | |||
| ) |
Remove one statement. For removing statements with wildward matching see removeAllStatements().
- Parameters:
-
statement The statement that should be removed. This has to be a valid statement.
- Returns:
- Error.ErrorNone on success and an error code if statement was invalid or an error occured.
| removeStatement | ( | self, | ||
| Soprano.Node | subject, | |||
| Soprano.Node | predicate, | |||
| Soprano.Node | object, | |||
| Soprano.Node | context=Soprano.Node() | |||
| ) |
| removeStatements | ( | self, | ||
| [Soprano.Statement] | statements | |||
| ) |
Convenience method which removes all %statements in statements.
| int statementCount | ( | self ) |
The number of statements stored in this Graph.
- Returns:
- The size of the Graph.
| [Soprano.Statement] toList | ( | self ) |
Convert the Graph into a list
KDE 4.3 PyKDE API Reference