What is the most canonical way to represent relationships in GraphEngine

125 views Asked by At

I'm trying to figure out how to best model my data in my TSL. In the Friends example, relationships are implied by storing the cell id (or a List of cell ids) in the related nodes. In the Freebase example, though, there's the notion of a [GraphEdge] that's introduced. I was hoping the documentation (and perhaps here), we could get a clear understanding of how to properly model relationships/edges using GraphEngine.

1

There are 1 answers

0
L. H. On BEST ANSWER

To my knowledge, there is no such standard way according to the documents, and the best practice also depends on our own requirements, e.g., performance or convenience. Here are my choices in different situations:

  1. For a directed unlabeled graph which is a very common situation, I just use neighbors' cell ids (adjacency list) as a field. And I find it is very efficient for most graph operations;
  2. For a directed graph with properties on the edges, there are two choices: use a list of values of self-defined struct, or set an individual cell for the edges and connecting the edges to the source/target node cells. The former one is practically faster than the latter one for most graph operations. But the cost is that it does not allow to access an edge without visiting the node cell, which is the benefit of the latter one;
  3. For an undirected graph without properties on edges, for each edge (u, v), I place their cell ids in each other's adjacency lists;
  4. For an undirected graph with properties on edges, a separate edge cell is set up for each edge, storing all the information on it including the associated nodes and properties;
  5. For a hypergraph where an edge may connecting more than one nodes, my choice is the same as 4.

The introduced notion [GraphEdge] is used to recognize the edges by Language Integrated Knowledge Query (LIKQ), however, it will not affect our usages if our applications are not built on top of LIKQ.