GraphViz, fixed layout when clustering - graphviz

I have dot (graphviz) file with given graph which consist several nodes and edges.
I would like to create a copy of that graph and cluster cluster (group) few nodes together.
However whenever I am doing that the layout of the graph is changing (adopting to the cluster).
Is there any way I could fix the position of the graph and then add clustering?

If for instance, you want to show a "before and after" (one graph w/out the cluster and one with), it might be easiest to initially create both graphs with the clusters (so that they look identical). Then for the graph that you want "unclustered", set all of the subgraph parameters so that the cluster annotations are invisible--i.e., with no cluster label and with a color that is the same as the background color of your graph. the cluster will appear invisible.
So for instance, in the code below, the cluster will appear invisible:
subgraph cluster_inv {
node [style=filled];
N1 -> N2 -> N3;
label="";
color="#FFFFFF";
}

Related

Graphviz: Graph with a node common in multiple subgraphs?

The objective is to able to create graphs in which a node can be overlapping between two or more subgraphs. Something like in the (erroneous) image below (A->B and A->C are in different subgraphs):
Something similar has been asked in Graphviz: Node in two subgraph and also in Same node in two subgraphs, but there had been no solution. This is something essential in graphs, and there should be an easy way of achieving that.
Overlapping subgraphs is not supported by GraphViz

Graphviz creates two arrows between subplots

I want to create a graphviz graph which contains two subgraphs containing nodes which are linked to other nodes in the other graph.
Some nodes need to be aligned horizontally to each other.
I've found out about the newrank=true command and I'm using it to achieve my described goal.
For some reason I've found that really weird behaviour:
If I create two nodes in one cluster and an arrow from one to the other and then another arrow pointing towards a third node in another cluster, graphviz will display two arrows.
digraph g{
newrank=true;
subgraph cluster_d{
A -> B
}
subgraph cluster_v{
C
}
{rank=same; A, B, C }
B -> C
}
I know, that I could simply use rankdir=LR and remove the rank=same, but in a larger graph with more nodes and subgraphs I seem to run into this problem sooner or later anyway.
I just created the artificial example above, to narrow the problem down.
Here is the code in use:
https://hackmd.io/s/B1NXAiTk7#
Why does Graphviz create two arrows between the subgraphs and how can I prevent this?
Related to: Why is graphviz drawing two arrows, and using a weird order?
But there was no satisfying answer and I think I narrowed the problem down.

Overlay graph with graphviz neato/fdp

How do I add an edge to a graphviz neato/fdp graph, that has no influence of the layout. I tried especially weight=0 and w=0 as stated in the documentation, and many other combination with the len attribute and different weights .
I'm aming for a map of nodes with "fixed" position/neighborhood and an overlay of additional relations.
This should be achievable by a two-step approach where you first run graphviz with the nodes and subset of edges you want it to use to compute positions and have it output the node positions (for example, use the -Tdot output). Then add the additional edges and rerun graphviz again.
You may need to pin the nodes, see this question: graphviz - fixed node positions

draw edge from node to edge in graphviz

Is it possible to draw an edge from a Node to the center of an existing Edge in graphviz? I would like to duplicate this type of reaction diagram, common in chemical or biological networks.
Thanks!
--Peter
Yes, you can use invisible nodes, like in this example for instance.
Then play with creating subgraphs for A and B where
rank=same
and then an edge where
constraint=false
for the connection from C to the invisible node. This will put the first two above C.

graphviz: Different orientation of the sub graphs

I would like to create graph with 3 sub graphs. Could two of them have left-right orientation and third top-bottom orientation as in this example?
I need also connect a few nodes from one subgraph to another but this should be easy.
This is not possible with graphviz. rankdir is a graph attribute (not subgraph or cluster).

Resources