I have a directed graph that concentrates overlapping edges on to one edge. A sample .dot file is given below:
strict digraph Test {
concentrate=true
A -> B;
A -> B;
A -> B;
}
I would like to display the number of overlapping edges as the edge label. This sounds pretty trivial, but I haven't been able to figure out how to do this. Is this possible? If possible how do I do it?
Thank you.
Only way is to do some post-processing yourself on the .gv file before feeding it to dot. You'd have to modify the output to explicitly include the text you want, such as:
strict digraph Test
{
concentrate=true
A -> B [label="3 connections between A and B"];
}
Related
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.
My question is - is it possible to force a diagonal between two nodes in a diagram?
Assume there is only one link between two nodes.
digraph G {
rankdir=TB
a -> b;
}
This is what is rendered :
This (mocked up) is what I would like:
Assume that the rankdir should stay in tact (TB = Top to bottom). I just want to control the direction of the angle of one edge.
I don't see anything in the documentation about how to achieve this (looking here).
So my question is, is this behaviour possible, if so how, or am I asking for the impossible?
With a hidden node, hidden connection, and proper spline settings, you can get this:
digraph G {
splines=line
rankdir=TB
a:s -> b:n;
i->b [style=invis]
a-> i [style=invis]
{rank= same b i [style=invis]}
}
A closer match to your original mock-up, I think. Is it worth it? You decide. :)
Probably there a different ways to solve this, but without having a clear understanding about your needs in detail, I'm not sure if this would be really helpfull.
For e.g. you can try with the north-east-south-west extension:
digraph G {
rankdir=TB
a:se -> b:nw;
}
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.
I'm using neato to output a graph, which works nicely. But neato merges edges between the same node pairs, and now I need to display multiple edges (arcs) with different properties (color, weight, possibly length) - is this possible?
I've tried to experiment with strict, splines=true/false, and different edge id and color, but nothing seems to work.
Have you tried to simply define multiple edges? For example,
graph G {
A -- B;
A -- B;
}
produces
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";
}