Graph vs InMemoryGraph


#1

I want to use graph to solve three problems:

  1. topological sort my directed graph
  2. traverse through vertices in topological order and find the incoming and outgoing edges of each vertex
  3. call evalMetrics on incoming and outgoing edges, and on vertices

Should I use Graph or InMemoryGraph?


#2

Use InMemoryGraph! Even if you use normal Graph, behind the scenes it will be using InMemoryGraph to do a topological sort.

There are no built-in functions to perform #2 or #3, but they can be easily written on top of the result of graph.topologicalSort. This method should scale fine to graphs with thousands of nodes, it will likely have trouble for graphs with millions or billions.