Property Graph implementation in Julia

Property Graph implementation in Julia

Problem Statement

During the development of ArbX, we encountered the challenge of representing token-pair relationships across markets in a graph format. Among the available options, Neo4j provided the most adaptable solution. However, it proved to be inefficient when it came to performing cyclical computations and real-time read/write operations. Therefore, we required a property graph implementation that offered both flexibility and real-time, native performance.

We opted to develop our own Graph data structure using the Julia programming language. Julia offers a efficient and reliable type system that allows us to gradually introduce more complex features. Additionally, we can leverage the Graphs.jl library, which provides a solid Graph interface.

However, the current implementations of the interface were inadequate for our specific needs. We required a graph that supported bidirectional connections and multiple weighted edges, but none of the existing interfaces met these requirements. MetaGraphs supported weighted edges, but did not allow multiple edges between the same pair of vertices. On the other hand, Multigraphs allowed multiple edges, but with uniform weight. We needed a solution that combined the capabilities of both interfaces.

Solution

We created a modified version of Multigraphs that emulates the features of MetaGraphs in order to incorporate custom weights for multiple edges. This approach enabled us to represent relationships between the same token-pair across various markets, such as BTC-USDT, which is traded on multiple platforms with distinct bid and ask prices.

With the current solutions, it would be necessary to use multiple graphs to monitor various markets. Our solution stands out as it enables the consolidation of information from multiple markets into a single graph with extremely low latencies (~2ms for a graph of 513 vertices with 4456 edges). This makes it highly efficient for identifying arbitrage opportunities.

The solution is open-source and available under MIT License.