pyvgx Vertex Access Methods Description

pyvgx.Vertex.Writable()

Check if a vertex is open in a writable state

pyvgx.Vertex.Readonly()

Check if a vertex is open in readonly mode

pyvgx.Vertex.Readable()

Check if a vertex is accessible

pyvgx.Vertex.Close()

Release vertex access lock

pyvgx.Vertex.Escalate()

Promote vertex access from readonly to writable

pyvgx.Vertex.Relax()

Relax vertex access from writable to readonly

1. pyvgx.Vertex.Writable()

Check if a vertex is open in a writable state.

1.1. Syntax

pyvgx.Vertex.Writable()

1.2. Return Value

This method returns True if the vertex is currently open and writable by the calling thread, otherwise False is returned.

1.3. Remarks

The vertex must be writable by the calling thread for this method to return True. If the vertex was formerly held in a writable state by the current thread, then closed, then opened writable by another thread, this method will return False when called on the (still valid) Python object in the current thread.

1.4. Example

from pyvgx import *
g = Graph( "graph" )
A = g.NewVertex( "A" )
A.Writable()           # True
g.CloseVertex( A )
A.Writable()           # False
A = g.OpenVertex( "A", mode="r" )
A.Writable()           # False
g.CloseVertex( A )
A = g.OpenVertex( "A", mode="w" )
A.Writable()           # True
g.CloseVertex( A )

2. pyvgx.Vertex.Readonly()

Check if a vertex is open in readonly mode.

2.1. Syntax

pyvgx.Vertex.Readonly()

2.2. Return Value

This method returns True if the vertex is currently open in readonly mode by the calling thread, otherwise False is returned.

2.3. Example

from pyvgx import *
g = Graph( "graph" )
A = g.NewVertex( "A" )
A.Readonly()           # False
g.CloseVertex( A )
A = g.OpenVertex( "A", mode="r" )
A.Readonly()           # True
g.CloseVertex( A )

3. pyvgx.Vertex.Readable()

Check if a vertex is accessible.

3.1. Syntax

pyvgx.Vertex.Readable()

3.2. Return Value

This method returns True if the vertex is accessible, either writable or readonly, otherwise False is returned.

3.3. Example

from pyvgx import *
g = Graph( "graph" )
A = g.NewVertex( "A" )
A.Readable()           # True
g.CloseVertex( A )
A.Readable()           # False
A = g.OpenVertex( "A", mode="r" )
A.Readable()           # True
g.CloseVertex( A )

4. pyvgx.Vertex.Close()

Release vertex lock.

4.1. Syntax

pyvgx.Vertex.Close() -> None

4.2. Remarks

This method releases the vertex and commits any changes if no other pyvgx.Vertex object(s) reference the same vertex in the graph.

The closed pyvgx.Vertex instance can no longer access the vertex.

4.3. Example

from pyvgx import *
g = Graph( "graph" )
g.CreateVertex( "A" )
A = g.OpenVertex( "A", "w" )    # open
A['x'] = 123                    # modify
A.Close()                       # close (and commit)
A['y'] = 456                    # AccessError

5. pyvgx.Vertex.Escalate()

Promote vertex acquisition status from readonly to writable.

5.1. Syntax

pyvgx.Vertex.Escalate( [ timeout ] ) -> None

5.2. Parameters

Parameter Type Default Description

timeout

int

0

Maximum milliseconds to wait for write-lock

5.3. Remarks

Promote vertex acquisition status from readonly to writable. An optional timeout (in milliseconds) allows blocking while waiting for writable access to be obtained. The default is nonblocking. If the vertex is already writable or the readonly vertex cannot be acquired writable AccessError is raised.

5.4. Example

from pyvgx import *
g = Graph( "graph" )
g.CreateVertex( "A" )
A = g.OpenVertex( "A", "r" )    # readonly
A.Writable()                    # -> False
A.Escalate()                    # become writable
A.Writable()                    # -> True

6. pyvgx.Vertex.Relax()

Relax vertex acquisition status from writable to readonly

6.1. Syntax

pyvgx.Vertex.Relax() -> bool

6.2. Return Value

Return True if vertex is readonly. Return False if vertex is still writable.

6.3. Remarks

Calling this method on a vertex that is already readonly has no effect and will return True.

Calling this method on a recursively write-locked vertex V (i.e. V.xrecursion > 1) has the same effect as releasing one level of write recursion and the vertex will still be writable. The return value is False in this case.

6.4. Example

from pyvgx import *
g = Graph( "graph" )
g.CreateVertex( "A" )
A = g.OpenVertex( "A", "w" )    # writable
A.Writable()                    # -> True
A.Relax()                       # -> True
A.Writable()                    # -> False

PYVGX