Change Password

Please enter the password.
Please enter the password. Between 8-64 characters. Not identical to your email address. Contain at least 3 of uppercase, lowercase, numbers, and special characters (such as @*&#).
Please enter the password.
Submit

Change Nickname

Current Nickname:
Submit

v4.2
Search
中文EN
v4.2

    Graph Centrality

    ✓ File Writeback ✓ Property Writeback ✓ Direct Return ✓ Stream Return ✕ Stats

    Overview

    Graph centrality of a node is measured by the maximum shortest distance from the node to all other reachable nodes. This measurement, along with other measurements like closeness centrality and graph diameter, can be considered jointly to determine whether a node is literally located at the very center of the graph.

    Graph centrality takes on values between 0 to 1, nodes with higher scores are closer to the center.

    Concepts

    Shortest Distance

    The shortest distance of two nodes is the number of edges contained in the shortest path between them. Please refer to Closeness Centrality for more details.

    Graph Centrality

    Graph centrality score of a node defined by this algorithm is the inverse of the maximum shortest distance from the node to all other reachable nodes. The formula is:

    where x is the target node, y is any node that connects with x along edges (x itself is excluded), d(x,y) is the shortest distance between x and y.

    In this graph, the green number and red number next to each node is the shortest distance between the node and the green node and red node. Graph centrality scores of the green and red nodes are 1/4 = 0.25 and 1/3 = 0.3333 respectively.

    Regarding closeness centrality, the green node has score 8/(1+1+1+1+2+3+4+3) = 0.5, the red node has score 8/(3+3+3+2+1+1+2+1) = 0.5. When two nodes have the same closeness centrality score, graph centrality can be viewed as the subsidiary basis to determine which node is closer to the center.

    Considerations

    • The graph centrality score of isolated nodes is 0.
    • Graph Centrality algorithm ignores the direction of edges but calculates them as undirected edges.

    Syntax

    • Command: algo(graph_centrality)
    • Parameters:
    Name
    Type
    Spec
    Default
    Optional
    Description
    ids / uuids []_id / []_uuid / / Yes ID/UUID of the nodes to calculate, calculate for all nodes if not set
    limit int ≥-1 -1 Yes Number of results to return, -1 to return all results
    order string asc, desc / Yes Sort nodes by the centrality score

    Examples

    The example graph is as follows:

    File Writeback

    Spec Content
    filename _id,centrality
    algo(graph_centrality).params().write({
      file:{ 
        filename: "res"
      }
    })
    

    Results: File res

    J,0
    I,0.25
    H,0.2
    F,0.333333
    G,0.25
    D,0.2
    E,0.333333
    C,0.2
    A,0.25
    B,0.2
    

    Property Writeback

    Spec Content Write to Data Type
    property centrality Node property float
    algo(graph_centrality).params().write({
      db:{ 
        property: "gc"
      }
    })
    

    Results: Centrality score for each node is written to a new property named gc

    Direct Return

    Alias Ordinal
    Type
    Description
    Column Name
    0 []perNode Node and its centrality _uuid, centrality
    algo(graph_centrality).params({
      ids: ["A", "B", "C"],
      order: "asc"
    }) as gc
    return gc
    

    Results: gc

    _uuid centrality
    2 0.20000000
    3 0.20000000
    1 0.25000000

    Stream Return

    Alias Ordinal
    Type
    Description
    Column Name
    0 []perNode Node and its centrality _uuid, centrality

    Example: Calculate graph centrality for all nodes, return the results with centrality scores greater than 0.25

    algo(graph_centrality).params().stream() as gc
    where gc.centrality > 0.25
    return gc
    

    Results: gc

    _uuid centrality
    6 0.33333299
    5 0.33333299
    Please complete the following information to download this book
    *
    公司名称不能为空
    *
    公司邮箱必须填写
    *
    你的名字必须填写
    *
    你的电话必须填写
    *
    你的电话必须填写