- Get Started
- Framework
- Get Started
- Framework
Basic Example Graph
You can visualize a network as a bipartite graph representing producers and buyers as nodes, with weighted edges capturing transactions between them. Edge weights track the cumulative fees contributed by producer from transactions with buyer .
To capture both the economic activity and the network influence of each node, we introduce a graph value metric that incorporates eigenvector centrality. For each producer , we define the graph value as:
Where:
- is the absolute value of the eigenvector centrality of node
- is a tunable parameter between 0 and 1
- is the sum of all edge weights connected to
Using the absolute value in the calculation:
Ensures Non-negativity: This approach guarantees that all centrality measures contribute positively to the graph value, aligning with the typical requirements of token distribution mechanisms where negative contributions are not practical.
Preserves the Interpretative Integrity: While taking the absolute value can sometimes mask the directionality (if relevant), in many network applications, especially those involving token distributions or influence measures, the magnitude of centrality is more critical than its direction.
The eigenvector centrality is calculated by solving the eigenvector equation:
Where:
- is the adjacency matrix of the graph
- is the largest eigenvalue
- is the corresponding eigenvector
The eigenvector centrality of a node is its corresponding value in the normalized eigenvector .
This graph value metric combines the node's economic activity (represented by the sum of edge weights) with its structural importance in the network (represented by its eigenvector centrality). The parameter allows for tuning the balance between these two factors.
Simple Example of a Dynamic Graph
Let's simulate a small network with 2 producers (P1, P2) and 3 buyers (B1, B2, B3). We'll use for our calculations.
In Python, we can define a function calculate_graph_values
that performs our calculations with the NetworkX package.
1import numpy as np2import networkx as nx3 4def calculate_graph_values(G, alpha=0.5):5 # Ensure consistent node ordering6 node_order = ['P1', 'P2', 'B1', 'B2', 'B3']7 8 # Create adjacency matrix9 A = nx.to_numpy_array(G, nodelist=node_order)10 11 # Calculate eigenvector centrality12 eigenvalues, eigenvectors = np.linalg.eig(A)13 largest_index = np.argmax(eigenvalues)14 eigenvector = eigenvectors[:, largest_index].real15 16 # Normalize eigenvector17 eigenvector = np.abs(eigenvector) / np.linalg.norm(eigenvector)18 19 # Calculate graph values for producers20 graph_values = {}21 for i, node in enumerate(node_order):22 if node.startswith('P'):23 economic_activity = sum(G[node][neighbor]['weight'] for neighbor in G[node])24 graph_values[node] = alpha * eigenvector[i] + (1 - alpha) * economic_activity25 26 return A, eigenvector, graph_values
Initial transaction graph:#
We will define an initial graph:
When we run the graph through our calculate_graph_values
function as:
we produce the following results.
P1 | P2 | B1 | B2 | B3 | |
---|---|---|---|---|---|
P1 | 0 | 0 | 2 | 0 | 0 |
P2 | 0 | 0 | 0 | 3 | 1 |
B1 | 2 | 0 | 0 | 0 | 0 |
B2 | 0 | 3 | 0 | 0 | 0 |
B3 | 0 | 1 | 0 | 0 | 0 |
Solving , we get the normalized absolute eigenvector value for each node:
Node | Value |
---|---|
P1 | 0.0000 |
P2 | 0.7071 |
B1 | 0.0000 |
B2 | 0.6708 |
B3 | 0.2236 |