pyvgx Vertex Miscellaneous Methods Description

pyvgx.Vertex.SetType()

Set or change the vertex type

pyvgx.Vertex.GetType()

Get the vertex type

pyvgx.Vertex.GetTypeEnum()

Get the vertex type enumeration code

pyvgx.Vertex.Commit()

Commit all vertex modifications

pyvgx.Vertex.IsVirtual()

Check if vertex is virtual

pyvgx.Vertex.AsDict()

Return a dictionary representation of the vertex

pyvgx.Vertex.Descriptor()

Return a human readable formatted string representing the pyvgx.Vertex.descriptor

1. pyvgx.Vertex.SetType()

Set or change the vertex type.

1.1. Syntax

pyvgx.Vertex.SetType( type )

1.2. Parameters

type: Vertex type (str) or None

1.3. Remarks

This method changes the vertex type. If type is None or empty string the vertex becomes typeless.

1.4. Return Value

None

1.5. Example

from pyvgx import *
g = Graph( "g1" )
A = g.NewVertex( "A" )            # A is typeless
B = g.NewVertex( "B", "node" )    # B type = "node"
A.SetType( "thing" )              # A type now = "thing"
B.SetType( None )                 # B now typeless

2. pyvgx.Vertex.GetType()

Return the vertex type.

2.1. Syntax

pyvgx.Vertex.GetType()

2.2. Return Value

Return the type name set at vertex creation or the most recent call to SetType(). The reserved type name "vertex" is returned for typeless vertices.

2.3. Example

from pyvgx import *
g = Graph( "g1" )
A = g.NewVertex( "A" )            # A is typeless
B = g.NewVertex( "B", "node" )    # B type = "node"
A.GetType()                       # -> "__vertex__"
B.GetType()                       # -> "node"

3. pyvgx.Vertex.GetTypeEnum()

Return the vertex type enumeration code.

3.1. Syntax

pyvgx.Vertex.GetTypeEnum()

3.2. Return Value

Return the type enumeration (int) code representing the vertex type.

3.3. Example

from pyvgx import *
g = Graph( "g1" )
A = g.NewVertex( "A" )            # A is typeless
B = g.NewVertex( "B", "node" )    # B type = "node"
A.GetTypeEnum()                   # -> 17
B.GetTypeEnum()                   # -> 132

4. pyvgx.Vertex.Commit()

Commit all vertex modifications and mark vertex object as dirty. This has the same effect as CloseVertex() but without releasing the lock. Returns the graph operation id.

4.1. Syntax

pyvgx.Vertex.Commit()

4.2. Return Value

Graph operation id.

4.3. Example

from pyvgx import *
g = Graph( "g1" )
A = g.NewVertex( "A" )
A.Commit()          # -> 10000000000000002
A.Writable()        # True
A['x'] = 123
A.Commit()          # -> 10000000000000003
g.CloseVertex( A )  # True

5. pyvgx.Vertex.IsVirtual()

Return True if vertex is virtual, otherwise False.

6. pyvgx.Vertex.AsDict()

Return a dictionary representation of the vertex.

6.1. Syntax

pyvgx.Vertex.AsDict()

6.2. Return Value

A Python dictionary of the vertex attributes, flags and states.

6.3. Example

from pyvgx import *
import pprint
A = g.NewVertex( "Alice", type="person" )
g.Connect( "Alice", "knows", "Bob" )
A["occupation"] = "Software Engineer"
A["age"] = 29
A.SetVector( [("java",1.2), ("c++",0.89), ("python",0.73)] )
pprint.pprint( A.AsDict() )
# Prints:
# {'allocator': {'aidx': 2,
#                'bidx': 0,
#                'flags.invl': 0,
#                'flags.ovsz': 0,
#                'offset': 0,
#                'refc': 4,
#                'size': 1},
#  'created-time': 1504225659,
#  'degree': 1,
#  'descriptor': 122513461082088878,
#  'expires-time': 4294967295,
#  'id': 'Alice',
#  'indegree': 0,
#  'internalid': '10384b2187cd857b78e02fdc859c4864',
#  'man': 'REAL',
#  'modified-time': 1504225659,
#  'outdegree': 1,
#  'properties': {'age': 29, 'occupation': 'Software Engineer'},
#  'type': 'person',
#  'vector': [('java', 1.125), ('c++', 0.875), ('python', 0.6875)]}
g.CloseVertex( A )

7. pyvgx.Vertex.Descriptor()

Return a human readable formatted string representing the pyvgx.Vertex.descriptor.

7.1. Syntax

pyvgx.Vertex.Descriptor()

7.2. Return Value

The descriptor is returned as a string:

[semaphore.count]   [type]   [ [<MAN> <PRE>]  [<YIB> <INY> <WRQ> <RWL> <LCK>] ]   [ [<IN> <OUT>] [<CTR> <VEC>] [<FLD>] [0] ]   [writer.threadid]

Please see pyvgx.Vertex.descriptor for a detailed explanation of the different values.

7.3. Example

from pyvgx import *
g = Graph("graph")
V = g.NewVertex( "x", type="node" )
V.Descriptor() # '[1] [node] [[REAL NORMAL] [IDLE NORMAL - WRITABLE LOCKED]] [[- -] [- -] [-] [0]] [2356]'
g.CloseVertex( V )

PYVGX