# Million-node Graphs

**URL:** <https://root-forum.cern.ch/t/million-node-graphs/50902>\
**Category:** Evolution Proposals, Apps & Ideas\
**Tags:** jsroot, root\
**Created:** [July 21, 2022, 4:45pm UTC](https://root-forum.cern.ch/t/million-node-graphs/50902 "2022-07-21T16:45:00Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![jacobfriedman](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/jacobfriedman/32/30361_2.png) [@jacobfriedman](https://root-forum.cern.ch/u/jacobfriedman)\
**Post date:** [July 21, 2022, 4:45pm UTC](https://root-forum.cern.ch/t/million-node-graphs/50902/1 "2022-07-21T16:45:00Z")

</div>

Greetings,

I’m looking to render graphs - that is, mathematical graphs (e.g. directed) - and have done exhaustive research combing through the different libraries available on the web. I’m familiar with three.js and was going to lean towards babylon when I found ROOT. It’s great to see the team implementing D3.

I’d like to work with the ROOTJS/ROOT team towards visualizing and manipulating large graphs (2d+3d). It may be that the naming conventions of the examples provided with JSRoot may have to change (Chart vs. Graph). There are numerous algorithms I’ve found to provide (node) graph layouts.

I believe I can provide some help with making large-scale graph visualizations a reality, and am willing and able to help CERN with this.

Please contact me at jfriedman ‘at’ graphstax ‘dot’ com or through github. In the meanwhile, I’ll be looking through the examples.

Regards  
Jacob

p.s. Whether or not this foray takes advantage of the C++ library at this time isn’t a concern.

---

<div class="post-metadata">

**Author:** ![jalopezg](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/jalopezg/32/25844_2.png) [@jalopezg](https://root-forum.cern.ch/u/jalopezg)\
**Post date:** [July 21, 2022, 7:06pm UTC](https://root-forum.cern.ch/t/million-node-graphs/50902/2 "2022-07-21T19:06:20Z")

</div>

Hi @jacobfriedman,

First of all, welcome to the ROOT forum! I am CC’ing a couple of people that might further discuss that topic with you: @linev, @couet.

Cheers,  
J.

---

<div class="post-metadata">

**Author:** ![jacobfriedman](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/jacobfriedman/32/30361_2.png) [@jacobfriedman](https://root-forum.cern.ch/u/jacobfriedman)\
**Post date:** [July 21, 2022, 7:25pm UTC](https://root-forum.cern.ch/t/million-node-graphs/50902/3 "2022-07-21T19:25:40Z")

</div>

Thanks for the quick response, Javier, and it’s nice to make your acquaintance!

This is a burning issue on my end and I’m ready to dive in and offer my support where I can.

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [July 21, 2022, 7:31pm UTC](https://root-forum.cern.ch/t/million-node-graphs/50902/4 "2022-07-21T19:31:15Z")

</div>

I’m not sure what you mean by a “graph”.

See: [Graph classes](https://root.cern/doc/master/group__Graphs.html)

Two simple examples:  
1-d graph: [TGraph](https://root.cern/doc/master/classTGraph.html)  
2-d graph: [TGraph2D](https://root.cern/doc/master/classTGraph2D.html)

Then, some “[computation graphs](https://root.cern/doc/master/classROOT_1_1RDataFrame.html#callgraphs)” are internally used by the [RDataFrame](https://root.cern/doc/master/classROOT_1_1RDataFrame.html) framework.

@Axel I’m not sure if [ROOT](https://root.cern.ch/) provides any methods to deal with [directed graphs (digraphs)](https://en.wikipedia.org/wiki/Directed_graph) or for the [graph theory](https://en.wikipedia.org/wiki/Graph_theory) in general.

---

<div class="post-metadata">

**Author:** ![linev](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/l/2bfe46/32.png) [@linev](https://root-forum.cern.ch/u/linev)\
**Post date:** [July 22, 2022, 6:47am UTC](https://root-forum.cern.ch/t/million-node-graphs/50902/5 "2022-07-22T06:47:20Z")

</div>

Hi Jacob,

JSROOT already provides a lot of optimizations to be able to show large datasets - as histograms or graphs in 2D and 3D. If there are too many points - it tries to show only most significant ones. In addition, `RCanvas` class of ROOT implements special technique to pre-select such points already on C++ side - see `rh1_large1.cxx`, `rh2_large1.cxx`, `rh3_large1.cxx` examples in `tutorials/rcanvas` subfolder.

Of course, any contributions from your side are welcome.

Regards,  
Sergey

---

<div class="post-metadata">

**Author:** ![jacobfriedman](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/jacobfriedman/32/30361_2.png) [@jacobfriedman](https://root-forum.cern.ch/u/jacobfriedman)\
**Post date:** [July 22, 2022, 10:51am UTC](https://root-forum.cern.ch/t/million-node-graphs/50902/6 "2022-07-22T10:51:50Z")

</div>

Hello Sergey, Coyote,

Thanks for pointing me to those examples! Ill have a look.

Mathematical vs. Display-Graph (perhaps call it a ‘Chart’)… here’s a chart of a graph: https observablehq com/@d3/force-directed-graph

I’ll play around with the examples and see if I can get an algorithm for a graph in the examples. If youd like to work together live, pergaps we can schedule an introduction- let me know if either of you have some time.

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [July 22, 2022, 12:17pm UTC](https://root-forum.cern.ch/t/million-node-graphs/50902/7 "2022-07-22T12:17:33Z")

</div>

@Axel I don’t think [ROOT](https://root.cern.ch) knows [force-directed graphs](https://en.wikipedia.org/wiki/Force-directed_graph_drawing).

In [ROOT](https://root.cern.ch), a graph is an object made of two or three arrays `X`, `Y`, and `Z`, holding the `x`, `y`, and `z` coordinates of some `n` points:  
[ROOT Primer → Graphs](https://root.cern/primer/#graphs)  
[ROOT Manual → Functional parts → Graphs](https://root.cern/manual/graphs/)

---

<div class="post-metadata">

**Author:** ![jacobfriedman](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/jacobfriedman/32/30361_2.png) [@jacobfriedman](https://root-forum.cern.ch/u/jacobfriedman)\
**Post date:** [July 22, 2022, 4:45pm UTC](https://root-forum.cern.ch/t/million-node-graphs/50902/8 "2022-07-22T16:45:45Z")

</div>

That’s fine as it’s merely a visualization library (a Graph of a mathematical graph is fine). I would, then, provide the logic for the display and let ROOT take it from there). It may be a semantic collision in future, but seeing as there’s no demand from the ROOT team, for graphs (as I’m aware of), the mathematical graph may be a sub-type of the actual Graph(ic) as provided in ROOT.

---

<div class="post-metadata">

**Author:** ![jacobfriedman](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/jacobfriedman/32/30361_2.png) [@jacobfriedman](https://root-forum.cern.ch/u/jacobfriedman)\
**Post date:** [July 26, 2022, 2:17pm UTC](https://root-forum.cern.ch/t/million-node-graphs/50902/9 "2022-07-26T14:17:46Z")

</div>

I’ll post here, as well as the github just in case:

Is there an option for users to modify the ROOT file in the Browser- and does that modification instantly update to the main display?

For instance, say we want to take a GraphViz tree and modify it in the browser as a direct transformation on the object for rendering- is it at all possible?

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [July 26, 2022, 2:58pm UTC](https://root-forum.cern.ch/t/million-node-graphs/50902/10 "2022-07-26T14:58:02Z")

</div>

ROOT can be built with optional [support for Graphviz (“`cmake -Dgviz=ON`”)](https://root.cern/install/build_from_source/#external-libraries):

[ROOT Reference Guide → Functional parts → Graphics → 2D Graphics → graphviz interface](https://root.cern/doc/master/group__gviz.html)

---

<div class="post-metadata">

**Author:** ![jacobfriedman](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/jacobfriedman/32/30361_2.png) [@jacobfriedman](https://root-forum.cern.ch/u/jacobfriedman)\
**Post date:** [July 26, 2022, 3:12pm UTC](https://root-forum.cern.ch/t/million-node-graphs/50902/11 "2022-07-26T15:12:27Z")

</div>

Correct- I’m aware but am particularly interested in how the manipulation of the output connects with its generators (either GraphViz or internal ROOT structures).

Given a graphviz input, manipulated in the ROOT interface, what guarantees are there that I can manipulate it once again in graphviz, or (for instance) manipulate (add/remove) nodes using the ROOTJS interface, keeping the structure of the graph (both visually and structurally) intact?

P.s. thank you very much for fielding the questions

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [July 27, 2022, 6:46am UTC](https://root-forum.cern.ch/t/million-node-graphs/50902/12 "2022-07-27T06:46:39Z")

</div>

The ROOT GraphViz interface allows to generate graphs and uses the graphical ROOT machinery to render them. The graph computation is delegated to GraphViz. Also, you can dump a [ROOT TGraphStruct (“graph structure”)](https://root.cern/doc/master/classTGraphStruct.html) as a “dot” file. That’s basically all you can do. This part of ROOT is not developed anymore.

---

<div class="post-metadata">

**Author:** ![jacobfriedman](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/jacobfriedman/32/30361_2.png) [@jacobfriedman](https://root-forum.cern.ch/u/jacobfriedman)\
**Post date:** [July 27, 2022, 10:33am UTC](https://root-forum.cern.ch/t/million-node-graphs/50902/15 "2022-07-27T10:33:53Z")

</div>

Thank you, Olivier; that answers my question.

An issue still remains under the jsroot github for large graphs (manipulating in the browser, socket-event vs polling).

For million-node graphs, the transfer could be quite slow. I’m not sure how the saved root file is saved (patched?) for large files. A simple diff coul save quite a bit of bandwidth and permit large-geometry browser updates.

I may have to provide this solution myself in the buffer class, but is there any work done or being done towards this?

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [July 27, 2022, 12:34pm UTC](https://root-forum.cern.ch/t/million-node-graphs/50902/16 "2022-07-27T12:34:41Z")

</div>

> [@jacobfriedman](#):
>
> An issue still remains under the jsroot github

For the jsroot side of it, I guess @linev is the best person to help you.

---

<div class="post-metadata">

**Author:** ![linev](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/l/2bfe46/32.png) [@linev](https://root-forum.cern.ch/u/linev)\
**Post date:** [August 9, 2022, 7:55am UTC](https://root-forum.cern.ch/t/million-node-graphs/50902/17 "2022-08-09T07:55:22Z")

</div>

As long as `GraphViz` is no longer developed inside ROOT, I see no good reasons to add support for it in JSROOT. But if somebody wants to implement it - one can discuss it
