These constants are used to specify the kind of value stored or searched in a relationship arc. For any given relationship type it is possible to store a separate arc for each of the available modifiers.

Constant Description Value Range Default Value Behavior I Q R Comment

pyvgx.M_ANY

Wildcard

N/A

y

For use in queries only

pyvgx.M_STAT

Static

1

1

Default

y

y

y

Relationship has no numeric value

pyvgx.M_SIM

Similarity

0.0 − 1.0

0.0

y

y

Pre-computed similarity score

pyvgx.M_DIST

Distance

0.0 − 3.4e+38

0.0

y

y

Measure for vertex distance, application defined

pyvgx.M_LSH

LSH bit pattern

0x00000000 − 0xFFFFFFFF

0

y

y

y

Bit pattern subject to approximate match by hamming distance

pyvgx.M_INT

32-bit Integer

-2,147,483,648 − 2,147,483,647

0

y

y

y

Generic signed integer value

pyvgx.M_UINT

32-bit Unsigned Integer

0 − 4,294,967,295

0

y

y

y

Generic unsigned integer value

pyvgx.M_FLT

Single Precision Floating Point

-3.4e+38 − 3.4e+38

0.0

y

y

y

Generic floating point value

pyvgx.M_CNT

Counter

0 − 4,294,967,295

1

Auto Increment

y

y

y

Repeated insertions of the same connection will increment the arc value with a specified delta (default 1)

pyvgx.M_ACC

Accumulator

-3.4e+38 − 3.4e+38

1.0

Auto Increment

y

y

y

Repeated insertions of the same connection will reinforce or diminish the arc value with a specified delta

pyvgx.M_INTAGGR

Integer aggregation

-2,147,483,648 − 2,147,483,647

1

Aggregation result value

y

Aggregated integer value in result returned by aggregation query

pyvgx.M_FLTAGGR

Float aggregation

-3.4e+38 − 3.4e+38

1.0

Aggregation result value

y

Aggregated floating point value in result returned by aggregation query

pyvgx.M_TMC

Created Timestamp

1 − 4,102,444,799

Current number of seconds since 1970

Cannot be modified once set (delete and re-create to modify)

y

y

y

Not automatic, must create explicitly to set

pyvgx.M_TMM

Modified Timestamp

1 − 4,102,444,799

Current number of seconds since 1970

y

y

y

Not automatic, must create explicitly to set

pyvgx.M_TMX

Expiration Timestamp

1 − 4,102,444,800

pyvgx.T_NEVER

All arcs with same relationship type are removed when expiration timestamp passes

y

y

y

Set timestamp when arcs of specified relationship type are automatically removed

pyvgx.M_AUTOTM

Auto timestamp (bitmask)

N/A

Creates multiple arc including M_TMC and M_TMM

y

Shortcut for creating three arcs with one Connect()

pyvgx.M_FWDONLY

Forward arc only (bitmask)

N/A

Prevent reverse arc from terminal

y

y

Eliminating reverse arc saves memory but prevents inarc traversal

1. pyvgx.M_ANY

pyvgx.M_ANY = 0

Arc filter modifier wildcard used in queries.

Example:

# Return all arcs of type 'knows' regardless of modifier
graph.Neighborhood( "Alice", arc=("knows", D_OUT, M_ANY) ) )

2. pyvgx.M_STAT

pyvgx.M_STAT = 1

Arc modifier for valueless (static) relationship. This is the default for arcs created without a specified modifier.

Type Min Max Comment

int

N/A

N/A

always 1

Example:

# These are equivalent
graph.Connect( "Alice", "knows", "Bob" )  # M_STAT, value=1 implied
graph.Connect( "Alice", ("knows", M_STAT), "Bob" ) # value=1 implied

# This is illegal, will raise pyvgx.ArcError
graph.Connect( "Alice", ("knows", M_STAT, 123), "Bob" )

3. pyvgx.M_SIM

pyvgx.M_SIM = 18

Used for setting explicit similarity score between two vertices.

Type Min Max Comment

float

0.0

1.0

Similarity measure

Currently this modifier is provided for manual use and expresses similarity between vertices only by convention. There is no relation between this modifier and query filters using vector similarity. Vertices with vectors are not automatically connected. If a connection is manually created using this modifier it is not updated when a vertex vector is changed. This modifier simply offers a way to explicitly connect two vertices with a value range compatible with similarity scores. The vertices do not require vectors.

Example:

graph.Connect( "Alice", ("skillset", M_SIM, 0.8), "Bob" )
graph.Connect( "Alice", ("skillset", M_SIM, 0.3), "Charlie" )

4. pyvgx.M_DIST

pyvgx.M_DIST = 19

A generic measure for distance between two vertices. Semantics are application defined.

Type Min Max Comment

float

0.0

3.4e+38

Generic distance measure

Example:

# Some distances, relationship type should indicate unit
graph.Connect( "Boston", ("kilometers", M_DIST, 306.0), "New York" )
graph.Connect( "Earth", ("lightyears", M_DIST, 8.611), "Sirius" )
graph.Connect( "coffee", ("edit", M_DIST, 3), "kaffe" )

5. pyvgx.M_LSH

pyvgx.M_LSH = 4

Bit pattern subject to approximate match by hamming distance

Type Min Max Comment

unsigned int

0x00000000

0xFFFFFFFF

Bit pattern (32 bits)

Example:

graph.Connect( "A", ("lsh", M_LSH, 0xFFFFFFFF), "B" )
graph.Connect( "A", ("lsh", M_LSH, 0x000FFFFF), "C" )
graph.Connect( "A", ("lsh", M_LSH, 0xFFFFF000), "D" )

graph.Neighborhood( "A", arc=("lsh", D_OUT, M_LSH, V_LTE, (0xFFFFFF33, 4)) )
# -> ['B']

graph.Neighborhood( "A", arc=("lsh", D_OUT, M_LSH, V_LTE, (0xFFFFFF33, 12)) )
# -> ['B', 'D']

6. pyvgx.M_INT

pyvgx.M_INT = 5

General purpose signed integer value.

Type Min Max Comment

int

-2,147,483,648

2,147,483,647

General purpose

Example:

graph.Connect( "A", ("boost", M_INT, -50), "B" )

7. pyvgx.M_UINT

pyvgx.M_UINT = 6

General purpose unsigned integer.

Type Min Max Comment

unsigned int

0

4,294,967,295

General purpose

Example:

graph.Connect( "A", ("related", M_UINT, 1000), "B" )

8. pyvgx.M_FLT

pyvgx.M_FLT = 23

General purpose floating point.

Type Min Max Comment

float

-3.4e+38

3.4e+38

General purpose

Example:

graph.Connect( "A", ("weight", M_FLT, 5.471), "B" )

9. pyvgx.M_CNT

pyvgx.M_CNT = 8

Automatic counter which will increment the arc value by a delta each time a connection is made for the same relationship.

Type Min Max Comment

unsigned int

0

4,294,967,295

Automatic counter

When inserting a relationship with this modifier multiple times (updating an existing arc), the value of the existing arc is incremented by a delta amount which defaults to 1. A positive value will increment the arc’s value by the specified amount. A negative value will decrement the arc’s value by the specified amount.

+ If no previous arc exists a new arc is created and its value is set to the specified increment value.

+ Counting beyond 4,294,967,295 or below 0 will have no effect.

Example:

graph.Connect( "Alice", ("called", M_CNT), "Bob" ) # -> 1
graph.Connect( "Alice", ("called", M_CNT), "Bob" ) # -> 2
graph.Connect( "StoreA", ("inventory", M_CNT, 100), "ItemX" ) # -> 100
graph.Connect( "StoreA", ("inventory", M_CNT, -1), "ItemX" ) # -> 99

10. pyvgx.M_ACC

pyvgx.M_ACC = 25

Automatic accumulator which will

Type Min Max Comment

float

-3.4e+38

3.4e+38

Automatic accumulator

When inserting a relationship with this modifier multiple times (updating an existing arc), the value of the existing arc is modified rather than overwritten. By default the added value is 1.0 if no value is specified. The specified value will be added to the arc’s value. A positive value will be added to the arc. A negative value will be subtracted from the arc. If no previous arc exists a new arc is created and its value is set to the specified value.

Example:

graph.Connect( "QueryA", ("boost", M_ACC, 14.0), "ItemX" )  # -> 14.0
graph.Connect( "QueryA", ("boost", M_ACC, -3.5), "ItemX" )  # -> 10.5
graph.Connect( "QueryA", ("boost", M_ACC, 2.37), "ItemX" )  # -> 12.87

11. pyvgx.M_INTAGGR

pyvgx.M_INTAGGR = 10

This modifier is used in aggregation queries. It specifies that aggregation should be performed only for arcs whose modifier value type is int or unsigned int.

Type Min Max Comment

int

-2,147,483,648

2,147,483,647

For display of computed integer aggregation

Example:

# Populate graph with different types of arcs
for n in range(4):
    via = "via_%d" % n
    graph.Connect( "A", "to", via)
    for m in range(4):
        leaf = "leaf_%d" % m
        graph.Connect( via, ("score",M_INT,n*m), leaf )
        graph.Connect( via, ("score",M_UINT,n), leaf )
        graph.Connect( via, ("score",M_DIST,n/float(m+1)), leaf )

# Sum up all integer values terminating at leaf nodes.
# Returns four values, one for each aggregated leaf node.
# Values for integer type arcs are summed, i.e. M_INT and M_UINT in this case.
graph.Neighborhood(
    A",
    "to",
    sortby   = S_VAL,
    result   = R_LIST,
    fields   = F_ID|F_VAL,
    collect  = False,
    neighbor = {
        'arc'     : ("*",D_OUT,M_ANY),
        'collect' : True
    },
    aggregate = {
        'mode':'sum',
        'arc':("*",D_ANY,M_INTAGGR)
    }
)

12. pyvgx.M_FLTAGGR

pyvgx.M_FLTAGGR = 27

This modifier is used in aggregation queries. It specifies that aggregation should be performed only for arcs whose modifier value type is float.

Type Min Max Comment

int

-3.4e+38

3.4e+38

For display of computed float aggregation

Example:

# Populate graph with different types of arcs
for n in range(4):
    via = "via_%d" % n
    graph.Connect( "A", "to", via)
    for m in range(4):
        leaf = "leaf_%d" % m
        graph.Connect( via, ("score",M_INT,n*m), leaf )
        graph.Connect( via, ("score",M_UINT,n), leaf )
        graph.Connect( via, ("score",M_DIST,n/float(m+1)), leaf )

# Sum up all float values terminating at leaf nodes.
# Returns four values, one for each aggregated leaf node.
# Values for float type arcs are summed, i.e. only M_DIST in this case.
graph.Neighborhood(
    "A",
    "to",
    sortby   = S_VAL,
    result   = R_LIST,
    fields   = F_ID|F_VAL,
    collect  = False,
    neighbor = {
        'arc'     : ("*",D_OUT,M_ANY),
        'collect' : True
    },
    aggregate = {
        'mode' : 'sum',
        'arc'  : ("*",D_ANY,M_FLTAGGR)
    }
 )

13. pyvgx.M_TMC

pyvgx.M_TMC = 12

Arc modifier for a relationship representing arc creation time. Once set this value cannot be modified. To modify creation time the arc has the be deleted first, then re-inserted.

Type Min Max Comment

unsigned int

1

Thu Jan 01 00:00:01 1970

4,102,444,799

Thu Dec 31 23:59:59 2099

Arc creation time

If no value (or zero) is specified the current graph time is assigned to the arc.
By default, the creation time arc is not automatically added when creating a relationship. This is to avoid unnecessary memory and computation overhead in the graph for situations where creation time is not needed. However, it is possible to enable automatic arc timestamps by first calling pyvgx.AutoArcTimestamps( True ). This is a global setting that will remain in effect until later disabled with pyvgx.AutoArcTimestamps( False ). When automatic timestamps are enabled, creating a new relationship will set creation time to current graph time. It is not possible to manually override creation time in this case.

Example:

# creation time = now
graph.Connect( "Alice", ("called",M_TMC), "Bob" )  # -> now ts

graph.Connect( "Alice", ("called",M_CNT), "Bob" )  # -> 1
graph.Connect( "Alice", ("called",M_CNT), "Bob" )  # -> 2

# illegal, will raise pyvgx.ArcError
graph.Connect( "Alice", ("called",M_TMC), "Bob" )

14. pyvgx.M_TMM

pyvgx.M_TMM = 13

Arc modifier for a relationship representing arc modification time.

Type Min Max Comment

unsigned int

1

Thu Jan 01 00:00:01 1970

4,102,444,799

Thu Dec 31 23:59:59 2099

Arc modification time

If no value (or zero) is specified the current graph time is assigned to the arc.
By default, the modification time arc is not automatically added when creating or updating a relationship. This is to avoid unnecessary memory and computation overhead in the graph for situations where modification time is not needed. However, it is possible to enable automatic arc timestamps by first calling pyvgx.AutoArcTimestamps( True ). This is a global setting that will remain in effect until later disabled with pyvgx.AutoArcTimestamps( False ). When automatic timestamps are enabled, creating or updating a relationship will set modification time to current graph time. It is not possible to manually override modification time in this case.

Example:

graph.Connect( "Alice", ("called",M_CNT), "Bob" )  # -> 1
graph.Connect( "Alice", ("called",M_TMM), "Bob" )  # -> now ts
graph.Connect( "Alice", ("called",M_CNT), "Bob" )  # -> 2
graph.Connect( "Alice", ("called",M_TMM), "Bob" )  # -> now ts

15. pyvgx.M_TMX

pyvgx.M_TMX = 14

Arc TTL modifier, representing the expiration time for this relationship. When inserting a M_TMX arc from (A) to (B) all arcs from (A) to (B) sharing the same relationship type as the inserted expiration arc will be removed when the expiration time passes.

Type Min Max Never Comment

unsigned int

1

Thu Jan 01 00:00:01 1970

4,102,444,799

Thu Dec 31 23:59:59 2099

4,102,444,800

Infinity

Absolute arc expiration time

A positive value sets the absolute expiration time in seconds since 1970. A negative number of seconds is interpreted as being relative to current graph time, i.e. a more negative value schedules expiration further into the future. If no value (or zero) is specified expiration is canceled, i.e. the M_TMX arc remains but with a value set to pyvgx.T_NEVER.

Example:

# Create relationships that will automatically expire in two minutes

# Manual
now = int( time.time() )
ttl = 120
graph.Connect( "Alice", ("query", M_CNT, 5), "shoes" )
graph.Connect( "Alice", ("query", M_TMX, now + ttl), "shoes" )

# Automatic
graph.Connect( "Bob", ("query", M_CNT, 3), "pants" )
graph.Connect( "Bob", ("query", M_TMX, -120), "pants" )

# wait 2 minutes...
graph.Adjacent( "Alice", "query", "shoes" )  # -> False
graph.Adjacent( "Bob", "query", "pants" )  # -> False

16. pyvgx.M_AUTOTM

pyvgx.M_AUTOTM = 256 (0x100)

Bitmask to combine with arc modifier (with OR-operator) to automatically create timestamp arcs along with the specified arc.

Example:

# A -[link M_INT 123]-> B
# A -[link M_TMC 1749156031]-> B
# A -[link M_TMM 1749156031]-> B
graph.Connect( "A", ("link", M_INT|M_AUTOTM, 123), "B" )

graph.Neighborhood("A", neighbor="B", fields=F_AARC )
# ['( A )-[ to <M_TMC> 1749156031 ]->( C )',
#  '( A )-[ to <M_TMM> 1749156031 ]->( C )',
#  '( A )-[ to <M_INT> 200 ]->( C )']

17. pyvgx.M_FWDONLY

pyvgx.M_FWDONLY = 2048 (0x800)

Bitmask to combine with arc modifier (with OR-operator) to prevent implicit creation of reverse arc from terminal back to initial.

Normally all arcs have "implicit reverse arcs" to allow neighborhood traversal from terminals back to their initial. Creating an arc with the M_FWDONLY bitmask saves up to 50% memory in highly connected graphs where reverse traversal is never needed.

Terminal vertices cannot have a mix of regular inarcs and forward-only inarcs. Trying to create an arc to a terminal that already has inarc(s) of the other kind raises pyvgx.ArcError.
If the terminal vertex will only ever have a single inarc the reverse implicit arc has no memory cost (all vertices include slots for one outarc and one inarc "for free") and using M_FWDONLY in this case has no benefit.

Example:

# A -> B (regular arc)
# A -> C (without implicit reverse arc)
graph.Connect( "A", ("to", M_INT, 100), "B" )
graph.Connect( "A", ("to", M_INT|M_FWDONLY, 200), "C" )

# A connects to B and C
graph.Neighborhood( "A", arc=D_OUT, fields=F_AARC )
# -> ['( A )-[ to <M_INT> 100 ]->( B )',
#     '( A )-[ to <M_INT|M_FWDONLY> 200 ]->( C )']

# B has a normal reverse implicit arc to A
graph.Neighborhood( "B", arc=D_IN, fields=F_AARC )
# -> ['( B )<-[ to <M_INT> 100 ]-( A )']

# C has no implicit arc back to A
graph.Neighborhood( "C", arc=D_IN, fields=F_AARC )
# -> []

# C still records indegree
graph.Degree( "C", arc=D_IN )
# -> 1

PYVGX