Draw GitGraph using a topologically sorted graph

27 Views Asked by At

Is it possible to draw a gitgraph i.e. a graph representation using only branch and commit commands if my starting data is a set of topologically sorted nodes and edges?

For example, my nodes could look like:

let nodes = {
  {id: 1},
  {id: 2},
  {id: 3},
  {id: 4},
  {id: 5},
};

and my edges:

let edges = {
  {from: 1, to: 2},
  {from: 2, to: 3},
  {from: 1, to: 4},
  {from: 4, to: 5},
};

The end result would be a gitgraph with the following structure:

 3   5
 ^   ^
 |   |
 2   4
 ^  ^ 
 | /
  1

Essentially what I need is the algorithm that would organize my calls for branch and commit commands.

0

There are 0 best solutions below