pyvgx.Graph

class pyvgx.Graph( name[, path[, local[, timeout ]]] )

The pyvgx.Graph type represents the Python layer’s view of VGX graph objects. Objects of this class are wrappers that enable Python code to access core VGX graphs.

Parameters

Parameter Type Default Description

name

str

Unique graph ID

path

str or bytes

name

Directory storage path relative to vgxroot

local

bool

False

Set local=True to prevent graph operations from being broadcast to remote instances when attached.

timeout

int

0

Time (in milliseconds) to block while waiting for access to VGX graph

Remarks

The pyvgx.Graph type represents VGX core graph objects. The returned Python object is a wrapper around the internal VGX graph object.

name

This constructor creates a new VGX graph or opens an existing VGX graph with the specified name. A reference to the graph is entered into the graph registry both in memory and on disk.

path

If path is not specified graph data is stored in a subdirectory called name relative to vgxroot. If the system has not yet been initialized, it is implicitly initialized with vgxroot set to the current working directory.

If path is specified it is used instead of name as the subdirectory on disk. Custom paths must be relative, otherwise an exception is raised.

local

If local is not specified (or set to False) the graph will broadcast operations performed on it when the system is attached to a remote destination. To keep the graph private to the local VGX instance even when the system is attached to a remote destination the graph can be instantiated with local = True.

timeout

The core VGX graph object is owned by the thread calling the constructor. Ownership is in effect for as long as the pyvgx.Graph object is in scope. If another thread already owns the VGX graph an exception is raised. Use the timeout parameter (in milliseconds) to block while waiting for access. The default timeout is 0, i.e. nonblocking. Pass -1 to block indefinitely.

It is possible (and safe) for a thread to share access to a pyvgx.Graph it owns with other threads. Sharing a graph object reference across multiple threads enables concurrent work to be performed on the same graph by many threads.

Example

import pyvgx
pyvgx.system.Initialize( "home" )
g = pyvgx.Graph( "graph1" )
g.name                      # "graph1"
g.path                      # "home/graph1"
pyvgx.system.Registry()     # {'graph1': (0, 0)}

Extending pyvgx.Graph

It is possible to extend pyvgx.Graph to provide specialized functionality:

import pyvgx
import random

pyvgx.system.Initialize()

class RandomGraph( pyvgx.Graph ):
    def populate( self, N ):
        for n in range( N ):
            a = self.NewVertex( str( random.random() ) )
            b = self.NewVertex( str( random.random() ) )
            self.Connect( a, ("n", pyvgx.M_INT, n), b )


r = RandomGraph( "r" )
r.populate( 10000 )
r.size                  # -> 10000
r.order                 # -> 20000

pyvgx.Graph API

pyvgx.Graph API Section Description

Graph Members

Graph object members

Graph Vertex Methods

Methods for creating, deleting and acquiring vertices

Graph Arc Methods

Methods for creating and removing relationships

Graph Query Methods

Methods for searching and retrieving information from the graph

Graph Management Methods

Methods for performing global graph operations

Graph Enumeration Methods

Methods for managing enumerations

Graph Event Methods

Methods for managing the TTL event processor

Graph Miscellaneous Methods

Methods for debugging and showing various information


PYVGX