# Graphs Part 3: Aigents Graph Analysis for Blockchains and Social Networks

## In the third part of this series, we focus on how to use Aigents Graph Analysis to visualize and better understand Blockchain and Social Networks.

In part one of our four-part series, we started with an introductory overview of different types of graphs, referring to examples rendering these graphs with Aigents graphics framework. Then, in part two, we progressed to examine more closely how graphs are used in SingularityNET, OpenCog, and Aigents. Now, in part three, we continue our discussion on different types of graphs used at SingularityNET and partner projects like OpenCog and Aigents. In this post, we present how Aigent Graphs can help explore interconnections, dependencies and hidden structures in public blockchains and social networks such as Ethereum, Steem and Golos.

## Getting started by linking your blockchain account

The latest release of Aigents Web Service allows you to try out deep graph analytics for the Ethereum, Steem and Golos networks. To begin, users must register, login to Aigents and go to the “Settings” menu (under the icon in the top right corner). It is important to ensure that you have entered your accounts for either the Ethereum, Steem or Golos blockchains. As these blockchains are public and provide access to data without authentication, you can use any account even if you do not have your own account.

## Rendering new Aigents Graphs

Once you have linked the Aigents blockchain(s) account, you can proceed to the “Graphs” menu item and select any of these blockchains by using the icons in the top right corner of the graph area. During your first attempt, the graph may take some time to load. Once it appears, it will replace the “old” version of the Aigents Graph. To view the “new” advanced version, simply right-click your mouse or tap (if you are using a tablet) on the graph area to see the graph query dialog box.

**Navigating the graph query dialog box to create the visualization you want**

After rendering new graphs, you can decide how you would like your graphs to look and what information you would like your graph to represent. This can easily be done through the graph query dialog box. Navigating it is relatively straightforward. The graph query dialog box accepts 6 types of information;

- Under Network, you can select an option between Ethereum, Steem or Golo
- Under ID, you can enter any account ID in any of the networks for the graph to start its search from
- Under Period, you can select the number of days to search the graph. In the demo version, you can select up to 7 days.
- Under Range, you can select the number of “links” that can be followed when the graph expands from the starting point
- Under Limit, you can select the number of nodes to render. It is worth considering that the lower the number of nodes, the faster it is to generate the graph. On the other hand, the higher the number of nodes, the more intricate the network will be. In the demo version, the number of nodes is limited to 500.
- Under Links, you can select the type of link(s) which best allows you to study the network. You can select all the possible kinds of connections between the nodes. Alternatively, you may also choose one link type or specific types of connections to focus on such as currency transfers (pays for spendings, paid for incomes), comments received on posts (commented for received comments, comments for ones written by account owner) and votes or likes (votes for incoming, votes for outgoing).

Next, click on the “Ok” button to submit the graph query. Bear in mind, it takes some time to extract the graph from the database. Once the graph is extracted, it will be rendered with the links represented in different colors.

In this case, comments are represented in blue, votes or likes in grey and financial transactions in green. Also, for Ethereum graphs, calls to smart contracts are represented in red. Using the graph control panel overlaid on top of the graph view, you can select different sorts of links to render.

The following graphs represent the Aigents Graph rendering subgraphs around the selected account with a range of 2 and the different types of links involved in the graph query. It represents links, comments, cryptocurrency transfers, and votes graphically for the Steemit Social Network.

Additionally, the graph control panel provides many other options for graph control. For example, it allows you to change the node radius and control the layout style.

## Applying a force-directed layout

The layout threshold controls can be applied only for a force-directed layout. When the layout threshold is set to “None”, nodes on the graph are displayed in a “natural order”. This means that the nodes are spread out horizontally in an alphabetical order from left to right. The nodes are also spread vertically based on their rank computed by the “liquid rank” (described later in this article). This means that the nodes ranked higher are placed at the top while nodes ranked lower are placed at the bottom.

On the other hand, when the layout threshold is not set to “None”, nodes on the graph are displayed through a force-directed layout. As such, nodes try to push each other apart while the links try to pull linked nodes together. This balance sets the proportion between pulling and pushing forces.

It is also possible to select the direction of the layout forces as either “horizontal”, where the vertical position is stuck to or determined by node rank and nodes are pulled and pushed only along a horizontal axis or “vertical”, where alphabetical order defines the horizontal position while nodes are pulled and pushed only along a vertical axis. You may even select “both”, where forces apply in all directions. The force-directed layout can be applied to position the nodes iteratively until the change of node positions on the next iteration drops below the specified threshold.

## Understanding SingularityNET’s “Liquid Rank” algorithm

The Aigents Graphs system uses the “liquid rank” algorithm to compute the default vertical position of the nodes, color saturation of the nodes and the size of the “halo” surrounding the highly-ranked nodes. Of interest, the algorithm is an extension of Google’s “Page Rank” algorithm and implements a simplified version of SingularityNET’s “liquid reputation” algorithm. This algorithm is described in the following steps (and the current implementation is available in the GraphOrder.directed function).

- For every node in the network, select the initial “rank”. This initial “rank” may either be known by default or set to any random value — same for the same node). Next, the ranks should be normalized to a range of 0.0 to 1.0 within the network.
- Next, for each node in the network, compute the “incremental rank” as a sum of all “weights” of the connected links multiplied by “ranks” of the nodes (as specified above).
- Now, regarding the “direction” of the links, there are two options. Rankings may be “directed”, where only incoming links are counted, or “undirected”, where both incoming and outgoing links are counted. Also, the “weight” of the links may have different meanings based on the graph and link types, such as the amount of currency transferred, voting value associated with vote or length or sentiment of the comment.
- With the “incremental rank” computed as described in the second step for every node in the network, the ranks should be normalised to a range of 0.0 to 1.0 within the network.
- There are two options with respect to the ranking. One option is to replace the initial normalised rank with an incremental rank. Another option is to blend the initial rank with an incremental one in some proportion to obtain a new rank distribution across the network.
- Compute the standard deviation between the initial and new distribution of ranks. If the standard deviation rises above the specified threshold, use the new rank instead of the initial rank. If the standard deviation falls below the threshold, you may stop the iterative process and consider the current distribution of ranks as a final result.

## Applications of SingularityNET’s “Liquid Rank” algorithm

The “liquid rank” algorithm makes it possible to track flows like influence (if applied to votes), opinion (if applied to comments) or financial power (if applied to the flow of financial funds). It can be effectively used with Aigents graph queries specifying the selected type of link with substantial range, having the graphs rendered only in the horizontal force direction so that the vertical position of the nodes on the graph represents their rank.

The following graphs represent the same Ethereum account studied for chains of links connecting other accounts in the far range — incoming “paid” links (first two graphs) and outgoing “paid” links (bottom two graphs). In both cases, the layout may be completely force-directed (first and third graph) or only horizontally force-directed (second and fourth graph) so that the vertical positions correspond to the node rank which indicates accumulators of currency transfers in the given case.

By applying similar graphs for social networks, it becomes more efficient to study top influencers, opinion leaders, social hubs and followers than with the previous version of Aigents Graphs.

The following video presents the newest Aigents Graphs analytics user interface for Ethereum, Steem and Golos. The video demonstrates the capabilities of the recent Aigents graph queries and Aigents Graphs for graph analytics of social networks and blockchains. The Aigents Graphs front-end framework is now available for free. In return, users can evaluate the Aigents Server to provide back-end support for analytics with graph queries to social networks and blockchains.

# Next Steps

In the final part of this series, we will wrap up our discussion by delving deeper into Hyper-Graphs and Meta-Graphs in OpenCog. It’s been a long journey since we started our discussion in part one, but like myself, I hope you enjoyed the learning process.

If this post has left you in absolute wonder about Aigents Graph Analysis or if it has raised further questions, you will find a good environment for discussion in our Community Forum. Beyond Aigents Graph Analysis, our community is always eager to engage on any research topics we have covered so far. Over the coming weeks, we seek to continually grant our community greater insider access to SingularityNET’s groundbreaking AI research and share insights on the specifics of our development.

For any additional information, please refer to our roadmaps and subscribe to our newsletter to stay informed regarding all of our developments.