Graphviz: How to include multiple graphs in the same graph? - jupyter-notebook

In Jupyter notebook, I am writing code that deals with a graph. It involves a series of transformations on the given graph. I am using graphviz to render the graphs inline. I can only render one graph at a time.
How do I render more than one graph side by side so that I can see successive transformations of the graph?
I know that 'subgraph' can be used to cluster different components of the graph. But I can't use it because it draws connections between all those subgraphs.

But I can't use it because it draws connections between all those subgraphs.
Sounds like the problem is that you have nodes with the same names across different subgraphs.
GraphViz has no per-subgraph namespacing mechanism. Therefore, you will need to somehow make all node names unique, even across subgraphs. You could do this by, for example, prefixing every node name with an unique subgraph ID.
Note that node labels don't need to be the same as node names. For more information, see:
graphviz: subgraph has same node, how to unique

Related

What is this type of graph called and how can it be plotted in R

A graph to indicate the percentage of elements from one node that are transferred to another node in two different stages. In principle, the number of nodes in one stage need not be equal to the number of nodes in the next stage. I would like to know the name of this type of graph and if it is possible to create it in R.
This is sankey diagram:
https://r-graph-gallery.com/sankey-diagram.html
You could find more info how to do it here:
https://plotly.com/r/sankey-diagram/

Visualisation for hierarchically clustered graph on map in python

I am starting a new project in python (to be used through jupyter-notebooks), where I'll need to visualise some hierarchically clustered graphs.
I have looked for existing packages, but so far I am not convinced by what I have seen.
I am not interested in the clustering process in itself, because this will be another part of the project and I know (roughly) how the graphs will be built up progressivelly.
What I am looking for are:
an appropriate data structure for storing hierarchically clustered graphs,
visualisation tools that would allow to represent the graph on a map (based on X and Y coordinates of the nodes) and either represent the subparts of the clusters, or simplify the clusters depending on their type or depth in the graph structure,
ideally, bring some interactivity, for example the ability to zoom-in or-out, or click on some clustered nodes to expand the nodes that were hidden in the cluster.
It looks pretty specific and despite some cool packages I have seen I am not sure which one would help without having too much to reimplement. So far, NetworkX looks like a cool starting point, especially with some D3.js (as shown here), but it is still far from what I have in mind.
Any advice about where to start digging?
Thanks a lot.
Gautier
For Python, Seaborn's clustermaps are nice. Seaborn is mainly meant to be used with Pandas dataframes; however, the documentation for clustermap says it can be rectangular data, and so I think it means other arrays will wor.
See also:
Dendrogram with heat map
SciPy Hierarchical Clustering and Dendrogram Tutorial
Hierarchical Clustering in Python

Loosen the graph layout in igraph

I'm drawing graphs using ggraph that uses layout functions from igraph package. However, the layouts I get are not entirely visually pleasing. In particular I have a graph with very strong connected components and some unconnected nodes. The result looks like this below:
So the nodes in the connected component are so close together that the edges are not even visible. Right now this used the fr layout, but other layouts give similar results. I seem to be unable to find a parameter that would loosen the graph up a bit that the connected component would not look like such a ball. Would be grateful for any suggestions.

How do I visualise an arbitrary directed acyclic graph?

I'm looking for an algorithm to automatically visualise a large DAG. It needs to scale well to hundreds or even thousands of nodes and connections (without turning unreadable). Connections should avoid crossing over each other where possible, and should especially avoid crossing over nodes that they aren't connected to.
Is there any standard algorithm I can adapt for this purpose?
You could check out the scalable force-directed placement algorithm. Graphviz implements this, so if you'd like to preview it before implementing, create a Graphviz file and run sfdp my_dag.gv (or fdp which might be easier to implement).
If that doesn't work for you, you might want something like Circos or Hive Plots. Hive Plots work really well for thousands of nodes for both directed and undirected graphs. The algorithm is described at a high level on the homepage, but there's an accompanying journal article too.
You can try Gephi a graph viz software.
You can feed it with different file type (.gexf, .gdf).
As this is a open source software, you can look inside spatialization algorithms.
url: http://gephi.org/

Graphviz: break flat but sparsely connected graph into multiple rows?

Howto break a flat but sparsely connected graphviz graph into multiple rows?
Graphviz yields a graph of about 4 ranks, but over 9000 nodes wide. However since the graph is sparsely connected we could break it in to rows, for example each 1000 nodes, and thus make it fit on nine rows one page. How can this be done?
Not looking for unflatten, but rather something like line breaks in a text editor (is it clear what I am looking for?).
Edit: PDF with example graph here
Like GraphViz Documentation, section 2.5: Node and Edge Placement, like Figure 9: Graph with constrained ranks?
http://www.graphviz.org/pdf/dotguide.pdf

Resources