com.sparsity.dex.gdb
Class Graph

Each Database has a Graph associated, which is the persistent graph which contains all data stored into the graph database.

It allows for manipulating the Database as a graph. Especially, it allows for the manipulation of an attributed labeled and directed multigraph (labels represent object types).

A Graph has the following characteristics: (i) It belongs to a Database and a Session. (ii) It has nodes which belong to node types and edges which belong to a edge types. (iii) Nodes and edges both can have attributes. (iv) There is no limit in the number of edges between two nodes, even if they belong to the same edge type. (v) Nodes and edges have an unique identifier (object identifier, OID) in the Graph. (vi) Object types (node and edge types) and attributes have also an unique identifier in the Graph.

Edge types

There are different kind of edge types. They are classified as undirected or directed.

Directed edges have a node which is the tail (the source of the edge) and a node which is the head (the destination of the edge). In case of undirected edges, two nodes at the extreme of the edge play the two roles, head and tail. Whereas undirected edges allow for any kind of navigation, directed edges restrict the navigation to the direction of the edge.

Also, edges can be clasified as restricted or unrestricted. Restricted edges define which must be the type of the tail nodes and the type of the head nodes, thus edges only will be allowed between nodes belonging to the specified types in the restriction. In case of unrestricted edges, there is no restriction and edges are allowed between nodes belonging to any type.

It is important to note that restricted edges are directed edges.

Indexed neighbors

Neighbors for each OID can be indexed in order to significantly increase the performance of the neighbors methods.

Unfortunately, it slightly decreases the performance of the construction of new edge instances. So, only if you will make intensive use of neighbors method should force materialize neighbors. This can be done by means of a parameter at the definition of new edge types.

Attributes

Basically attributes are restricted to a given node or edge type when they are created. That is, only node or edge objects of the corresponding restricting type can set and get values from that attribute identifier.

But also, attributes can be global. That is, all node or edge objects (no matters which type they belong to) can set and get values from that attribute identifier. To do that, Type::GlobalType must be used when creating the attribute.

There are three kind of attributes, but all of them allows for storing a value and run query methods (such as Select): (i) Basic: It allows the same usage as any other type, but the performance at query methods is not the best. (ii) Indexed: Like Basic, but have better performance at query methods. (iii) Unique: it works as Indexed but additionally they have a constraint: two different objects cannot have the same value (but NULL).

Virtual edges

Previous version of Dex (v4.1.x and older) have another type of edges called virtual edges. Check out the documentation of previous version of Dex to have a detailed explanation about the functionality of virtual edges.

Although virtual edges have been removed, the functionality they provided can be simulated as follows.

Let's suppose we have a virtual edge defined between the attributes ATTR_A and ATTR_B. These edges allow for navigating from any object OBJ having an attribute value for the attribute ATTR_A to those objects having the same attribute value for the attribute ATTR_B. That is, this can be done as follows: (i) Getting the value of OBJ for the attribute ATTR_A. (ii) Selecting the objects having the retrieved value for attribute ATTR_B.

getAttributeStatistics

basic - [in] If FALSE all statistics are computed, if TRUE just those statistics marked as basic will be computed (see description of the AttributeStatistics class). Of course, computing just basic statistics will be faster than computing all of them.

getAttribute

The other version of this call, where the Value is an output parameter instead of the return, is better because it allows the user to reuse an existing Value instance, whereas this call always creates a new Value instance to be returned.

It never returns NULL. Thus, in case the OID has a NULL value for the attribute it returns a NULL Value instance.

newSessionAttribute

Session attributes are exclusive for the Session (just its Session can use the attribute) and are automatically removed when the Session is closed (thus, attribute data is not persistent into the database).

Since they are not persistent, they cannot be retrieved from the database, so they do not have an identifier name.

newSessionAttribute

Session attributes are exclusive for the Session (just its Session can use the attribute) and are automatically removed when the Session is closed (thus, attribute data is not persistent into the database).

Since they are not persistent, they cannot be retrieved from the database, so they do not have an identifier name.

newEdge

The tail of the edge will be any node having the given tailV Value for the given tailAttr attribute identifier, and the head of the edge will be any node having the given headV Value for the given headAttr attribute identifier.