<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Jeffrey Lovitz on Medium]]></title>
        <description><![CDATA[Stories by Jeffrey Lovitz on Medium]]></description>
        <link>https://medium.com/@jeffrey.lovitz?source=rss-f043278a20d4------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*5lS6QTz2Vc-o0BGKOIJ-0w.png</url>
            <title>Stories by Jeffrey Lovitz on Medium</title>
            <link>https://medium.com/@jeffrey.lovitz?source=rss-f043278a20d4------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 10:30:36 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@jeffrey.lovitz/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[On the release of RedisGraph v1.0 Preview]]></title>
            <link>https://medium.com/@jeffrey.lovitz/on-the-release-of-redisgraph-v1-0-beta-ff51010ad9ba?source=rss-f043278a20d4------2</link>
            <guid isPermaLink="false">https://medium.com/p/ff51010ad9ba</guid>
            <category><![CDATA[database]]></category>
            <category><![CDATA[redis]]></category>
            <category><![CDATA[nosql]]></category>
            <category><![CDATA[graph-database]]></category>
            <category><![CDATA[linear-algebra]]></category>
            <dc:creator><![CDATA[Jeffrey Lovitz]]></dc:creator>
            <pubDate>Tue, 31 Jul 2018 11:48:05 GMT</pubDate>
            <atom:updated>2018-08-12T16:00:40.815Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/346/1*sAl5RjA9-jltbyeBzhq1sQ.png" /></figure><p><em>TLDR: We’ve been developing a graph database that transforms queries into linear algebra problems, and the result is very fast.</em></p><p>Nearly two years after starting development, RedisGraph reached a major release milestone today. RedisGraph is a graph database architecture implemented as a Redis module, using GraphBLAS sparse matrices for internal data representation and linear algebra for query execution. It is implemented purely in C, and has been tested on Linux and OS X distros. We are using Cypher as our query language, and look forward to working toward GQL with the graph database community!</p><h3>Matrix representations of graphs</h3><h4>Building for speed and sparsity</h4><p>Matrices are a classic means of encoding graph data, starting from the pleasantly intuitive adjacency matrix — a square table with all nodes along each axis, and a value for each connected pair. Naively implemented, this approach scales terribly for graphs that model real-world problems, which tend to be very sparse. The space and time complexity for a matrix are governed by its dimensions (<strong>O<em>(n²)</em></strong> for square matrices), making alternatives like adjacency lists more appealing for most practical applications with scaling requirements.</p><h4>Enter GraphBLAS</h4><p>For RedisGraph, we’ve employed the GraphBLAS library to gain the benefits of matrix representations while optimizing for sparse data sets. (Special thanks to <a href="http://faculty.cse.tamu.edu/davis/suitesparse.html">Tim Davis</a>, who has worked closely with us to integrate his work as effectively as possible!)</p><p>GraphBLAS encodes matrices in compressed sparse column (CSC) form, which has a cost determined by the number of nonzero elements contained. In total, the space complexity of a matrix is:</p><p><em>(# of columns + 1) + (2 * # of nonzero elements)</em></p><p>Which for a dense graph will still be bounded by <strong>O<em>(n²)</em></strong>​, but for a complete diagonal — the identity matrix — is only <strong><em>3n + 1</em></strong>​.</p><p>This encoding is highly space-efficient, and also allows us to treat graph matrices as mathematical operands, so that database operations can be executed as algebraic expressions without needing to first translate data out of a form like a series of adjacency lists.</p><h3>Solving graph problems with linear algebra</h3><p>The GraphBLAS interface allows the majority of our library invocations to be direct mathematical operations, such as matrix multiplications and transposes — these calls are evaluated lazily and optimized behind the scenes.</p><p>As an example, let’s take a simple graph that has 6 nodes, 4 of which have the label Person and 2 of which have the label Country.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/792/1*Y5YWIQQ4RorMMP6fPoyVQw.png" /></figure><p>The Cypher query we’ll run is:</p><p>MATCH (:person {name: ‘Jeff’})-[:friend]-&gt;(:person)-[:visited]-&gt;(c:country) RETURN c</p><p>To find out which countries have been visited by my friends.</p><p>This query will have a filter operation to only select Person nodes with a matching Name property. We will have to traverse two adjacency matrices, friend and visited.</p><p>Thanks to the minimal impact of values in the CSC encoding, our adjacency matrices can contain always columns for all node IDs, as opposed to matrices that save space by representing the relevant subset of nodes. As such, all matrices have the same dimensions and row/column indices always describe the same entities, so we can use any of these matrices together without needing to transition them into comparable forms.</p><p>Our starting point will be the friend adjacency matrix:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Y9bWCAzMVll4elT6RbBlOQ.png" /><figcaption>‘Friend’ relationships in database</figcaption></figure><p>I have Node ID 0, so entries in the first row of this matrix denote the IDs of individuals I am friends with. At the moment, filters are applied node-by-node. An optimization we’re developing currently is applying them to the matrix at this stage — the result will be a modified adjacency matrix in which only my friends are represented.</p><p>Now we take the visited matrix, which has the same dimensions and describes all nodes in the same order.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Jm5lDuOhm4gnI_2_GNT9iQ.png" /><figcaption>‘Visited’ relationships in database</figcaption></figure><p>By multiplying the filtered friend matrix against visited, we obtain a matrix which connects my node (as a row) to the countries that my friends have visited (as columns).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/791/1*x68J5uCXVf8cPE0ckiYLBA.png" /><figcaption>(As a space optimization, we actually use boolean matrices here, so both entries will be 1 in practice.)</figcaption></figure><h3>Benchmarks</h3><p>All below values were built on the <a href="https://snap.stanford.edu/data/wiki-topcats.html">Wikipedia network of top categories</a> dataset on a 2016 Macbook Pro (2 GHz i5, 16gb RAM). The resulting graph contains 1,791,489 nodes and 28,511,807 edges.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/614/1*ACgsSuwFtILzKIT_eq3UlA.png" /></figure><p>A few notes on these:</p><ul><li>Create Graph — the in-module architecture invoked here is effective, though this process will be substantially faster once we improve the additional tooling. The CSV files are passed to RedisGraph in batches on the standard Redis pipeline, which takes 55 queries that are currently blocking operations. We’ll work on this soon!</li><li>Who’s connected / Find two hops neighbors —This is what the matrix optimizations are most easily suited for, which definitely shows. A major factor in the drastic difference between the two hops queries is that the destination-provided query requires us to extract many more rows from our edge matrices, where the source-provided query can instead use CSC-friendly column scans.</li><li>Self-referencing nodes and memory consumption — one of our upcoming improvements is implementing a centralized property store, which I expect to improve both of these.</li></ul><h3>Roadmap</h3><p>Development on RedisGraph is still highly active. The most significant tasks ahead of us at the moment are:</p><ul><li>Support properties on edges</li><li>Support index optimizations on label-property pairs</li><li>Parallelism (GraphBLAS has many features for this that we haven’t started to invoke yet, and there is a lot of room to optimize the execution plan we construct and enact from queries)</li><li>Allow for graphs distributed across multiple clusters</li><li>Add a visualization utility</li><li>Additional clients (we have made Python and Ruby interfaces so far)</li><li>Optimization, optimization, optimization (this is a task without end, but we have some ideas that will be very fun to play out)</li></ul><p>This is very much a wishlist, incidentally! RedisGraph is an open-source project in the spirit of Redis, and contributors are always welcome. Feel free to reach out to us on GitHub if you have any comments, or if you’re interested in becoming involved.</p><h3>Further Reading</h3><ul><li><a href="https://github.com/RedisLabsModules/redis-graph/">Project Home</a></li><li><a href="https://oss.redislabs.com/redisgraph/">Documentation</a></li><li><a href="https://www.youtube.com/watch?v=9h3Qco_x0QE">The Next-Generation RedisGraph</a>(RedisConf)</li><li><a href="https://youtu.be/xnez6tloNSQ">Lower Latency Graph Queries in Cypher with Redis</a> (RedisConf)</li><li><a href="http://istc-bigdata.org/GraphBlas/">GraphBLAS homepage</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ff51010ad9ba" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>