Skip to content

Several implementations of graph algorithms that could be added to ubergraph.alg namespace #56

@jafingerhut

Description

@jafingerhut

A few months ago when using Ubergraph for a project, I was working with graphs that had hundreds of thousands of nodes and edges, and wrote a few graph algorithms using Ubergraph that are perhaps of more wide interest than only for my project.

I also found a few inefficiencies in the pre-traverse algorithm implemented in Loom, and exposed from ubergraph.alg. I have submitted a PR to Loom, but wanted to offer it for possible addition to Ubergraph as well, in case Loom is not updated.

The main new graph algorithm implementation is:

Strongly connected components - Loom has one, too, but this one has been tested with Ubergraph multigraphs, and has been implemented using mutable data structures internally (but taking immutable values as args, and returning immutable values as results) for better performance, achieving almost 5x faster run time on one large sample graph I have used for speed testing against Loom's implementation.

There are some more minor things, like functions for returning a "strongly connected equivalent graph" (I should check the graph algorithms literature to see if there is a standard/widely-used name for this), which, given a digraph G=(V,E), returns a graph that has one node representing each set of nodes in the same strongly connected component of G, and edges (u,v) if there is at least one edge from the strongly connected component represented by u, to the one represented by v. This can be useful as a starting point for algorithms that care about which nodes are reachable from others, and you want to reduce the size of a graph with many cycles, but preserve reachability.

Also functions for returning which sets of nodes are reachable from all nodes, construct an induced subgraph, and probably one or two other minor things.

I am planning on writing some code that calculates a transitive reduction of a graph, too, which I'd be happy to add to Ubergraph.alg if that is of interest.

I guess the first pass of questions is:

  • Which of these algorithms sounds of interest for inclusion in ubergraph.alg, if any?

  • For any you do find of interest, I have APIs that I have implemented so far that have been useful for me, but it seems best to start by reviewing what they take as input, and return as output, before getting into the internal implementation. The functions are all defined in this file: https://github.com/jafingerhut/cljol/blob/master/src/clj/cljol/ubergraph_extras.clj

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions