Attribute Description

pyvgx.Vertex.id

Vertex unique identifier string

pyvgx.Vertex.internalid

A digest of the identifier string

pyvgx.Vertex.type

Vertex type name

pyvgx.Vertex.isolated

True when degree is zero

pyvgx.Vertex.deg

Total number of arcs incident on vertex

pyvgx.Vertex.ideg

Number of vertex inarcs

pyvgx.Vertex.odeg

Number of vertex outarcs

pyvgx.Vertex.vector

Vertex vector represented as a Python list of 2-tuples

pyvgx.Vertex.properties

A new dictionary representing the stored properties of a vertex

pyvgx.Vertex.tmc

Vertex creation timestamp

pyvgx.Vertex.tmm

Vertex modification timestamp

pyvgx.Vertex.tmx

Vertex expiration timestamp

pyvgx.Vertex.rtx

Vertex remaining time until expiration

pyvgx.Vertex.c1

Dynamic rank 1st order coefficient (writable)

pyvgx.Vertex.c0

Dynamic rank 0th order coefficient (writable)

pyvgx.Vertex.b1

Special internal: ANN seed number (readonly)

pyvgx.Vertex.b0

Special internal: ANN arc LSH rotate (readonly)

pyvgx.Vertex.virtual

Vertex is VIRTUAL if True, REAL if False

pyvgx.Vertex.address

Vertex memory address

pyvgx.Vertex.index

Vertex object location index based on its memory address

pyvgx.Vertex.bitindex

Vertex bitvector quadword offset

pyvgx.Vertex.bitvector

Vertex bitvector quadword

pyvgx.Vertex.op

Operation ID of the most recent graph operation modifying this vertex

pyvgx.Vertex.refc

Vertex object reference count

pyvgx.Vertex.bidx

Vertex object allocator block index

pyvgx.Vertex.oidx

Vertex object allocator block offset

pyvgx.Vertex.handle

Vertex object allocator handle (long)

pyvgx.Vertex.enum

Vertex object enumeration (int)

pyvgx.Vertex.descriptor

Integer value representing internal state of vertex

pyvgx.Vertex.readers

Number of readonly acquisitions

pyvgx.Vertex.owner

ID of thread holding one or more write-locks for this vertex

pyvgx.Vertex.xrecursion

Number of write-locks held by vertex owner.

1. pyvgx.Vertex.id

Vertex unique identifier string.

This is a read-only attribute.

Alias: pyvgx.Vertex.identifier

1.1. Example

from pyvgx import *
g = Graph( "test" )
A = g.NewVertex( "A" )
A.id             # "A"
g.CloseVertex( A )

2. pyvgx.Vertex.internalid

Vertex internal id is a digest of the identifier string.

This is a read-only attribute.

2.1. Example

from pyvgx import *
g = Graph( "test" )
A = g.NewVertex( "A" )
A.id             # 'A'
A.internalid     # '7fc56270e7a70fa81a5935b72eacbe29'
g.CloseVertex( A )

3. pyvgx.Vertex.type

Vertex type name.

This is a read-only attribute.

3.1. Example

from pyvgx import *
g = Graph( "test" )
A = g.NewVertex( "A" )
B = g.NewVertex( "B", type="thing" )
A.type                       # '<vertex>' (typeless)
B.type                       # 'thing'
g.CloseVertex( A )
g.CloseVertex( B )

4. pyvgx.Vertex.isolated

True when no arcs incident on vertex, False otherwise.

This is a read-only attribute.

4.1. Example

from pyvgx import *
g = Graph( "test" )
A = g.NewVertex( "A" )
B = g.NewVertex( "B" )
C = g.NewVertex( "C" )
g.Connect( B, "to", C)
A.isolated  # -> True
B.isolated  # -> False
C.isolated  # -> False

5. pyvgx.Vertex.deg

Total number of arcs incident on vertex.

This is a read-only attribute.

5.1. Example

from pyvgx import *
g = Graph( "test" )
A = g.NewVertex( "A" )
B = g.NewVertex( "B" )
C = g.NewVertex( "C" )
g.Connect( A, None, B )
g.Connect( B, None, C )
A.deg                    # -> 1
B.deg                    # -> 2
C.deg                    # -> 1
g.CloseVertex( A )
g.CloseVertex( B )
g.CloseVertex( C )

6. pyvgx.Vertex.ideg

Number of vertex inarcs.

This is a read-only attribute.

6.1. Example

from pyvgx import *
g = Graph( "test" )
A = g.NewVertex( "A" )
B = g.NewVertex( "B" )
C = g.NewVertex( "C" )
g.Connect( A, None, B )
g.Connect( B, None, C )
A.ideg                   # -> 0
B.ideg                   # -> 1
C.ideg                   # -> 1
g.CloseVertex( A )
g.CloseVertex( B )
g.CloseVertex( C )

7. pyvgx.Vertex.odeg

Number of vertex outarcs.

This is a read-only attribute.

7.1. Example

from pyvgx import *
g = Graph( "test" )
A = g.NewVertex( "A" )
B = g.NewVertex( "B" )
C = g.NewVertex( "C" )
g.Connect( A, None, B )
g.Connect( B, None, C )
A.odeg                   # -> 1
B.odeg                   # -> 1
C.odeg                   # -> 0
g.CloseVertex( A )
g.CloseVertex( B )
g.CloseVertex( C )

8. pyvgx.Vertex.vector

Vertex vector represented as a Python list of 2-tuples.

This is a read-only attribute.

The list produced by reading this attribute is a new, independent Python object, disassociated from the actual vertex object. Modifying the list has no effect on the vertex vector.

To modify a vertex vector, use pyvgx.Vertex.SetVector().

8.1. Example

from pyvgx import *
g = Graph( "test" )
A = g.NewVertex( "A" )
A.SetVector( [("this",1.5),("is",1.1),("our",0.9),("vector",0.7)] )
V = A.vector
print( V )         # [('this', 1.5), ('is', 1.0), ('our', 0.875), ('vector', 0.6875)]
# NOTE: Modifying the list returned by SetVector is allowed but has no effect on the vertex!
V.append( "zzz" )  # modifying the
del V[0]           #   list has no effect
V[0] = 123         #      on the vertex vector
print( V )         # [123, ('our', 0.875), ('vector', 0.6875), 'zzz']
# Vector in vertex has not changed
print( A.vector )  # [('this', 1.5), ('is', 1.0), ('our', 0.875), ('vector', 0.6875)]

9. pyvgx.Vertex.properties

A new dictionary representing the stored properties of a vertex.

Modifying the returned dictionary has no effect on the vertex stored properties.

This is a read-only attribute.

9.1. Example

from pyvgx import *
g = Graph( "test" )
A = g.NewVertex( "A", type="node" )
A.SetProperty( "name", "something" )
A.SetProperty( "value", 123 )
A.properties              # {'name': 'something', 'value': 123}
A.RemoveProperties()
A.properties              # {}
g.CloseVertex( A )

10. pyvgx.Vertex.tmc

Vertex creation timestamp (seconds since 1/1/1970 UTC).

This is a read-only attribute.

10.1. Example

from pyvgx import *
g = Graph( "test" )
A = g.NewVertex( "A" )
A.tmc              # 1504631589
g.CloseVertex( A )

11. pyvgx.Vertex.tmm

Vertex modification timestamp (seconds since 1/1/1970 UTC).

This is a read-only attribute.

The vertex modification timestamp is updated when the vertex is committed using pyvgx.Graph.CloseVertex().

11.1. Example

from pyvgx import *
import time
g = Graph( "test" )
A = g.NewVertex( "A" )
A.tmc                      # 1504631589
A.tmm                      # 1504631589
# Wait a little bit then perform some modifying operations
time.sleep(5)
A.SetProperty( "x", 123 )  # Setting a property modifies the vertex
g.Connect( A, "to", "B" )  # Creating a connection modifies the vertex
A.tmm                      # 1504631589, not updated yet since we have not committed
# Commit the vertex and check the tmm
g.CloseVertex( A )         # Commit A
A = g.OpenVertex( "A" )    # Reopen A
A.tmm                      # 1504631594, now updated
g.CloseVertex( A )

12. pyvgx.Vertex.tmx

Vertex expiration timestamp (seconds since 1/1/1970 UTC).

This is a read-only attribute.

A vertex is guaranteed to exist and be valid (unless explicitly deleted) until the expiration timestamp passes. Once a vertex expires it may be deleted from the graph at any time.

The expiration timestamp does not guarantee deletion at any particular time. It only guarantees the vertex will exist before this timestamp is reached (i.e. there may be a delay in removing the vertex after it expires). This delay is system dependent and has no absolute definition.
The maximum value for tmx is 4102444800 (Fri Jan 01 00:00:00 2100 UTC) representing no expiration time.

12.1. Example

from pyvgx import *
import time
g = Graph( "test" )
A = g.NewVertex( "A" )
A.tmx                         # 4102444800, never expires by default
now = int( time.time() )      # Get current time
A.SetExpiration( now + 3600 ) # Set "A" to expire one hour from now
A.tmx                         # 1504639328
g.CloseVertex( A )

13. pyvgx.Vertex.rtx

Vertex remaining seconds until expiration.

This is a read-only attribute.

13.1. Example

from pyvgx import *
import time
g = Graph( "test" )
A = g.NewVertex( "A", lifespan=60 )
A.rtx                         # 60
time.sleep(10)
A.rtx                         # 50

14. pyvgx.Vertex.c1

Dynamic rank coefficient for use with rank() and georank() in evaluator expressions. This vertex attribute is writable.

Default value: c1 = 1.0

When used with rank() it represents the 1st order coefficient in the equation y = c1·X + c0.

When used with georank() it represents geographic latitude in degrees.

It is possible to use c1 as a general purpose numeric property (single precision float), which is faster and more memory efficient than regular vertex properties

14.1. Example

from pyvgx import *
g = Graph( "test ")
A = g.NewVertex( "A" )
A.c1 = 5.0
A.c0 = 1000.0
g.Evaluate( "rank(1)", head=A )      # -> 1005.0
g.Evaluate( "rank(100,10)", head=A ) # -> 1550.0

15. pyvgx.Vertex.c0

Dynamic rank coefficient for use with rank() and georank() in evaluator expressions. This vertex attribute is writable.

Default value: c0 = 0.0

When used with rank() it represents the 0th order coefficient in the equation y = c1·X + c0.

When used with georank() it represents geographic longitude in degrees.

It is possible to use c0 as a general purpose numeric property (single precision float), which is faster and more memory efficient than regular vertex properties

15.1. Example

from pyvgx import *
g = Graph( "test ")
B = g.NewVertex( "Boston" )
B.SetRank( 42.3601, -71.0589 )
T = g.NewVertex( "Tokyo" )
T.SetRank( 35.6762, 139.6503 )
g.Evaluate( "georank( vertex )", tail=B, head=T )  # -> 0.46071
#
# NOTE: georank = (20015090 - geodist) / 20015090
#       where 20015090 is the max distance between two points on Earth

16. pyvgx.Vertex.b1

For special internal use with ANN search. This is the ANN seed number.

Internal details subject to change and are thus intentionally undocumented.

16.1. Example

from pyvgx import *
g = Graph("g1")
g.sim.CreateProjectionSets( 2, 10 ) # -> [0, 1087]
# Projections from the first and second seeds
g["_1FFF|000"].b1  # -> 0
g["_1234|43F"].b1  # -> 1

17. pyvgx.Vertex.b0

For special internal use with ANN search. This is the ANN arc LSH rotation amount.

Internal details subject to change and are thus intentionally undocumented.

17.1. Example

from pyvgx import *
g = Graph("g1")
g.sim.CreateProjectionSets( 2, 10 ) # -> [0, 1087]
# Projections from the first and second seeds
g["_1FFF|000"].b0  # -> 45
g["_1234|43F"].b0  # -> 30

18. pyvgx.Vertex.virtual

Vertex VIRTUAL flag.

This is a read-only attribute.

The manifestation of a vertex is either REAL or VIRTUAL.

A vertex that is created explicitly is REAL.

A vertex that is created implicitly as a terminal for a relationship is VIRTUAL.

If a REAL vertex is deleted it will be converted to VIRTUAL if its indegree is greater than zero.

A VIRTUAL vertex whose indegree goes to zero as a result of a graph operation will be deleted.

18.1. Example

from pyvgx import *
g = Graph( "test" )
A = g.NewVertex( "A" )    # "A" is created explicitly as a REAL vertex
g.Connect( A, "to", "B" ) # "B" is created implicitly and becomes VIRTUAL
A.virtual                 # False
g['B'].virtual            # True
g.Connect( "C", "to", A ) # "A" becomes a terminal and has indegree=1
g.DeleteVertex( "A" )     # "A" is converted to VIRTUAL
g['A'].virtual            # True
g.DeleteVertex( "C" )     # When "C" is deleted "A" is automatically deleted
g.HasVertex( "A" )        # False

19. pyvgx.Vertex.address

Memory address of the vertex object.

19.1. Example

from pyvgx import *
g = Graph( "test ")
A = g.NewVertex( "A" )
A.address              # -> 902775776

20. pyvgx.Vertex.index

Vertex object location index based on its memory address.

20.1. Example

from pyvgx import *
g = Graph( "test ")
A = g.NewVertex( "A" )
A.index                 # -> 4701957

21. pyvgx.Vertex.bitindex

Vertex bitvector quadword offset, i.e. the nth quadword in an array of quadwords containing bitmask for vertex memory location.

This can be used together with pyvgx.Vertex.bitvector to construct vertex set bitmaps.

If array[ bitindex ] & bitvector == 1 then the vertex is present in the array.

21.1. Example

from pyvgx import *
g = Graph( "test ")
A = g.NewVertex( "A" )
A.bitindex              # -> 73468

22. pyvgx.Vertex.bitvector

Vertex bitvector quadword. This is a 64-bit number with one bit set.

See pyvgx.Vertex.bitindex for more information.

22.1. Example

from pyvgx import *
g = Graph( "test ")
A = g.NewVertex( "A" )
A.bitvector             # -> 32

23. pyvgx.Vertex.op

Operation ID of the most recent graph operation modifying this vertex.

The operation ID is a built-in graph property that is incremented each time an object is modified. When modifying a vertex the operation ID is captured and stored in the vertex.

23.1. Example

from pyvgx import *
g = Graph( "test ")
A = g.NewVertex( "A" )
A.op                   # -> 10000000015013808
A['score'] = 100
A.Commit()
A.op                   # -> 10000000015013809

24. pyvgx.Vertex.refc

Vertex object reference counter. This is an internal attribute which may be useful for diagnostics and debugging.

24.1. Example

from pyvgx import *
g = Graph( "test ")
A = g.NewVertex( "A" )
A.refc                  # -> 4

25. pyvgx.Vertex.bidx

Vertex object allocator block index. This is an internal attribute which may be useful for diagnostics and debugging.

25.1. Example

from pyvgx import *
g = Graph( "test ")
A = g.NewVertex( "A" )
A.bidx                  # -> 0

26. pyvgx.Vertex.oidx

Vertex object allocator block offset. This is an internal attribute which may be useful for diagnostics and debugging.

26.1. Example

from pyvgx import *
g = Graph( "test ")
A = g.NewVertex( "A" )
A.oidx                  # -> 476229

27. pyvgx.Vertex.handle

Vertex object allocator handle. This is a long type (42 significant bits) which uniquely identifies a vertex independent of the current process, as opposed to the vertex address which will generally differ between processes.

27.1. Example

from pyvgx import *
g = Graph( "test ")
A = g.NewVertex( "A" )
A.handle               # -> 2199023256641

28. pyvgx.Vertex.enum

Vertex object enumeration. This is an int type (31 significant bits) which uniquely identifies a vertex independent of the current process, as opposed to the vertex address which will generally differ between processes. In large graphs (with > 2 billion vertices), this may return -1. If so, use pyvgx.Vertex.handle instead.

28.1. Example

from pyvgx import *
g = Graph( "test ")
A = g.NewVertex( "A" )
A.enum                  # -> 1089

29. pyvgx.Vertex.descriptor

Integer value representing internal flags and codes describing current state of vertex.

This is a read-only attribute.

The vertex descriptor may be useful for analyzing problems related to concurrency (threading) or other issues where visibility into the vertex internal state is required.

29.1. Example

from pyvgx import *
g = Graph( "test" )
A = g.NewVertex( "A", type="node" )
g.Connect( A, None, "B" )
A.descriptor                    # 109286233120702464
g['B'].descriptor               # 76987254421061632
g.CloseVertex( A )

29.2. Format

A vertex descriptor is a 64-bit value of flags and state information.

Field Bit Range Bits Value Range Description

ZERO

63

1

always 0

semaphore.count

62-56

7

0-127

0-63 (usable)

Reentrancy count for vertex lock. Counts the total lock acquisition for either multiple simultaneous readers or a single writer. Total reentrancy cannot exceed 63.

type.enumeration

55-48

8

0-255

17, 32-239 (usable)

Internally assigned code representing the vertex type mapping. This value defaults to 17 (11h) for typeless vertices and will otherwise be in the range 32 - 239 (20h - EFh) for vertices with an assigned type. This limits the vertex type-space to 208 distinct mappings.

state.context.manifestation (MAN)

47-46

2

0 = NULL

1 = REAL

2 = VIRTUAL

3 = ANY

Vertices always be either REAL (1) or VIRTUAL (2). The two other codes NULL (0) and ANY (3) are sometimes used internally but will never appear in the vertex descriptor.

state.context.pre_active (PRE)

45

1

0 = normal, 1 = pre-active

Will always be 0 for vertices that have been fully constructed and gone through initial commit. The only time PRE=1 is prior to the initial commit, which occurs at the time the vertex construction completes and the write lock is released for the first time.

state.lock.yielded_inarcs_busy (YIB)

44

1

0 = idle, 1 = busy

Will be set to 1 only when a thread has locked the vertex writable but has yielded its inarcs (INY=1) due to the thread expecting to become blocked, and those yielded inarcs have been acquired by another thread which is about to create an arc inbound on the vertex which requires modification of the vertex inarcs.

state.lock.inarcs_yielded (INY)

43

1

0 = normal, 1 = yielded

Will be set to 1 when a thread has locked the vertex writable and the thread is about to become blocked. This signals availability of the vertex’s inarcs for other thread that may need to modify the vertex inarcs while the actual owner of the vertex write lock is blocked.

state.lock.write_requested (WRQ)

42

1

0 = none, 1 = write requested

Will be set to 1 by the first thread that fails to acquire a write lock on the vertex because the vertex is currently locked readonly by one or more other threads.

state.lock.read_write (RWL)

41

1

0 = writable, 1 = readonly

Only has meaning when LCK = 1, and in that case RWL = 0 means writable and RWL = 1 means readonly.

state.lock.locked (LCK)

40

1

0 = open, 1 = locked

When 0 the vertex is not locked and should not be accessed. A thread needs to lock the vertex before it can safely access members and call methods. For non-modifying access a readonly lock should be acquired. For modifying access a writable lock should be acquired. In both cases LCK = 1 after the lock as been acquired, and RWL will indicate the type of lock.

property.degree.has_inarcs (IN)

39

1

0 = no inarcs, 1 = has inarcs

Will be 1 if the vertex has one or more inarcs.

property.degree.has_outarcs (OUT)

38

1

0 = no outarcs, 1 = has outarcs

Will be 1 if the vertex has one or more outarcs.

property.vector.is_centroid (CTR)

37

1

0 = standard, 1 = centroid

Will be 1 if the vertex has a vector and that vector is a centroid.

property.vector.has_vector (VEC)

36

1

0 = no vector, 1 = has vector

Will be 1 if the vertex has a vector.

property.fields.has_fields (FLD)

35

1

0 = no fields, 1 = has fields

Will be 1 if the vertex has one or more properties set.

property.reserved.rsv

34-32

3

reserved

writer.threadid

31-0

32

0 - 4294967295

Will be set to the operating system’s numeric ID assigned to the thread currently holding a write lock on the vertex, or has requested write access while one or more readers threads hold the readonly lock.

30. pyvgx.Vertex.readers

The number of readonly acquisitions (by all threads) for this vertex.

30.1. Example

from pyvgx import *
g = Graph( "test ")
g.CreateVertex( "A" )
A = g.OpenVertex( "A", "r" )
A.readers                       # -> 1
x = g.OpenVertex( "A", "r" )
A.readers                       # -> 2

31. pyvgx.Vertex.owner

Thread ID of thread owning one or more write-locks for this vertex. Thread ID is a positive integer when vertex is write-locked, or 0 when vertex is not write-locked.

31.1. Example

from pyvgx import *
g = Graph( "test ")
g.CreateVertex( "A" )
g.CreateVertex( "B" )
A = g.OpenVertex( "A", "w" )
B = g.OpenVertex( "B", "r" )
A.owner                     # -> current thread ID
A.owner == threadid()       # -> True
B.owner                     # -> 0

32. pyvgx.Vertex.xrecursion

Number of write-locks held by vertex owner thread.

32.1. Example

from pyvgx import *
g = Graph( "test ")
g.CreateVertex( "A" )
A = g.OpenVertex( "A" )
A.xrecursion                # -> 1
A2 = g.OpenVertex( "A" )
A.xrecursion                # -> 2
A2.xrecursion               # -> 2
g.CloseVertex( A )
A2.xrecursion               # -> 1
A.xrecursion                # AccessError

PYVGX