pyvgx Vertex Rank Methods Description

pyvgx.Vertex.SetRank()

Assign vertex ranking coefficients

pyvgx.Vertex.GetRank()

Return vertex ranking coefficients

1. pyvgx.Vertex.SetRank()

Assign vertex ranking coefficients.

1.1. Syntax

pyvgx.Vertex.SetRank( [ c1[, c0 ] ] ) -> tuple

1.2. Parameters

Parameter Type Default Description

c1

float

1.0

Dynamic ranking coefficient c1

c0

float

0.0

Dynamic ranking coefficient c0

1.3. Return Value

This method returns a tuple (c1, c0) representing the ranking coefficients currently assigned to the vertex.

1.4. Remarks

Ranking coefficients are used by the rank() and georank() functions to compute dynamic rank scores for vertices in ranking expressions.

The ranking coefficients have different meanings depending on the ranking function used.

1.4.1. Linear ranking using rank()

For rank(a,b,c,…​) c1 and c0 are the coefficients of the linear equation y = c1*X + c0 where X is the sum of all arguments a, b, c ,…​ and y is the rank score.

1.4.2. Geographical proximity using georank()

For georank() c1 and c0 represent the geographical coordinates of head vertex (latitude=c1, longitude=c0) expressed in degrees.

1.4.3. As numeric properties

Both c1 and c0 are stored as 32-bit floating point values within a vertex object. It is possible to use these as general purpose numeric properties instead of the normal key/value properties. For some applications, avoiding key/value lookups may provide significantly faster access and keep memory usage to a minimum.

1.5. Example

from pyvgx import *
g = Graph( "graph" )
A = g.NewVertex( "A" )
for n in range( 1000 ):
    r = A.Connect( A, "to", str(n))

A.SetRank( 5.0, 10000 )                     # -> (5.0, 10000.0)
A.c1                                        # -> 5.0
A.c0                                        # -> 10000.0
g.Evaluate( "rank()", head=A )              # -> 10000.0
g.Evaluate( "rank( next.odeg )", head=A )   # -> 15000.0
g.CloseVertex( A )

2. pyvgx.Vertex.GetRank()

Return vertex ranking coefficients.

2.1. Syntax

pyvgx.Vertex.GetRank() -> tuple

2.2. Return Value

This method returns a tuple (c1, c0) representing the ranking coefficients currently assigned to the vertex.

2.3. Remarks

Coefficients c1 and c0 are also available as vertex attributes. The following statements are equivalent:

  • vertex.GetRank()

  • ( vertex.c1, vertex.c0 )

2.4. Example

from pyvgx import *
g = Graph( "graph" )
A.c1 = 5.0                      #
A.c0 = 10000                    #
A.GetRank()                     # -> (5.0, 10000.0)
g.CloseVertex( A )

PYVGX