question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Implement possibility of choosing git graph rendering algorithm

See original GitHub issue

Is your feature request related to a problem? Please describe.

I was analysing the problem mentioned in feature request https://github.com/nicoespeon/gitgraph.js/issues/290 and I realised this is bigger change and demands more discussion and proper planning and design so I decided to open a proper feature proposal issue.

Briefly for those unfamiliar with https://github.com/nicoespeon/gitgraph.js/issues/290, every time we branch a new column gets assigned to new branch even if there is available space. For projects with many short-lived branches layout grows really large pretty quickly. I prepared an example that demonstrates it pretty clearly:

Screenshot 2019-09-10 at 11 48 04 AM

Describe the solution you’d like

I came across the article commit graph drawing algorithms by @pvigier the developer of Gitamine who written a master thesis about this subject.

It appears like the process of rendering git graph consists of three steps

  1. finding appropriate order of commits (x-coordinate of each commits)
  2. finding appropriate column (compute y-coordinates)
  3. optimise the layout

I propose to isolate those steps and implement separate functions for them so that user can select which algorithm would like to use

const options = {
  "sorting": "topological",
  "algorithm": "curved",
  "optimisation": "all-nodes-and-all-edges"
}

that gives full customisation regarding the output layout, for less advanced users who would want to replicate the behaviour of their favourite software we could prepare pre-defined layout, each consisting of sorting and column order algorithm and eventual optimisation, such as

const options = {
  "layout": "SourceTree"
}

would replicate the output as similar to SourceTree as we can reproduce

the disadvantage is, there would be a lot of code to take into account all those algorithms and possibly not enough contributors to implement all of those, so I also suggest and alternative solution

Describe alternatives you’ve considered

We could also adapt some code from Gitamine which is GPL-3.0 licenced, I briefly researched it and it looks like it is possible to include GPL-3.0 code in MIT licence project as stated here.

My alternative proposal is to still abstract out part of the code that assigns order to columns and keep the layout option proposed earlier as

const options = {
  "layout": "gitamine"
}

would use the Gitamine-based algorithm and

const options = {
  "layout": "regular"
}

would render everything exactly as it is now, also regular would be the default value so update would not break backwards compatibility and in the future we could consider using different layout as default if community demands it.

Additional context

I attach some figures from article by @pvigier, they demonstrate quite nicely the possible variety of layouts.

Also, I’d like to mention that I already forked and briefly researched the source and if there would be positive feedback on proposal I’ll be happy to discuss techy details based on my notes and I can take care of the implementation.

I’d like to mention that the adapted algorithm by @pvigier I would commit separately and set him as the author of that commit.

Git_Cola GitCola GitExtensions GitExtension
gitk gitk GitKraken GitKraken
SmartGit SmartGit SourceTree SourceTree

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:3
  • Comments:13 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
pvigiercommented, Oct 11, 2019

Hi,

If you need my code to be under MIT license, I can change the license. And if you need more information concerning the algorithm, I can help.

Best, Pierre

1reaction
joliebigcommented, Apr 21, 2020

Hi,

I’m also interested in such a feature, not a configurable graph-rendering algorithm as suggested by @marekyggdrasil , but at least a fix that addresses the one-column-can-have-only-one-branch problem.

Best regards jl

Read more comments on GitHub >

github_iconTop Results From Across the Web

Commit Graph Drawing Algorithms - pvigier's blog
It describes the algorithm I designed to draw the commit graph in my own prototype git client called gitamine. I have adapted the...
Read more >
algorithm - How does 'git log --graph' or 'hg graphlog' work?
First, one obtains a list of commits (as with git rev-list ), and parents of each commit. A "column reservation list" is kept...
Read more >
19 Graph Algorithms You Can Use Right Now - Memgraph
Here is the list of 19 algorithms that we support. You can use these algorithms immediately with Memgraph (graph DB) and Mage (graph...
Read more >
Graph Visualization - Developer Guides - Neo4j
With visualization tools, a full or partial graph can come to life and allow the user to explore it, setting various rules or...
Read more >
JavaScript: Graph Visualization using Cytoscape JS - iSquared
Finally, we need to specify the layout, which algorithmically infers the positions of the nodes. Such an example is the force-directed algorithm ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found