I would like to increase the border width of my nodes, but I find that the arrow heads in digraph edges do not respect the added width. Instead, they sink into the border. Here's my simple graph.
strict digraph {
a [penwidth="10.0"];
b [penwidth="10.0"];
a -> b;
}
How could I either increase the node width safely, or distance the edges further back? Reading through the attribute list, I didn't find a way. The closest was peripheries, but it makes multiple narrow peripheries instead of a thick one, but the edges do stick to the outermost periphery.
This is a known bug: https://forum.graphviz.org/t/allign-nodes-stroke-with-end-of-the-arrows-path-width/462
The only work-around I know is to "move" node b or shorten the edge - described in the bug report.
Related
I can't figure out how to control edge placement with dot. I have created a small example to show my question. This may or may not be a MCVE; in the process of making it Minimal and Verifiable, I may have dropped the Complete. Anyway:
digraph stuff {
rankdir=LR;
a->b->c->b->a
}
$ dot -V
dot - graphviz version 2.38.0 (20140413.2041)
dot barfu.dot -Tpng > barfu.png
gives me this:
But I'd like to have the left-to-right arrows consistently on top, to reflect the normal state transitions. (Actually, it would be preferable to have them be straight lines in the middle, and have the right-to-left ones always curve below.)
I tried changing the line weight, the length, adding groups, setting connector directions, etc. Nothing seems to help, at least in the bigger graph this comes from.
This doesn't work in my larger diagram, so other answers are still most welcome, but it appears that, since graphviz starts with a default top-down graph, with the most important (downward pointing edges) on the left, they do a simple rotation when you make the graph go left to right, which rotates the top of the graph to the left, and thus the most important edges from the left to the bottom. So, of course, this really simple test case can be fixed by making the graph go right-to-left instead of left-to-right.
digraph stuff {
rankdir=RL;
c->b->a->b->c;
}
I used word to make this graph, how to make it in dot language? The line style is perpendicular. Thanks very much!
You can use the 'pos' attribute to place your nodes on an imaginary grid:
graph X
{
a [pos="1,1"]
b [pos="2,2"]
c [pos="2,3"]
d [pos="2,4"]
}
and then use the appropriate flag to the layout program to override neato's desire to place your nodes (you may also need to fiddle with the size of your nodes). You probably end up with edges which are not straight. In that case, define invisible nodes for the junction points on your imaginary grid and draw edges from your top node to the invisible ones and from the invisible ones to RIL_Init and so on. If your graphs are big, this will get pretty tedious..still straightforward...and you still get all the output options of graphviz. The need for pos="1,1!" usually comes up too, the bang meaning 'put it exactly there'.
I have a digraph with 4 ranks. I'm attaching a screenshot. Very zoomed out, but conveys the idea.
What I want is to allow the second rank to space out vertically so that the lines between rank 2 and 3 are closer to horizontal. Those long lines a very hard to follow! I suppose what I'm asking is "how can I prioritise shortening edge length over keeping nodes of the same rank close together?".
I would include the source but it's very straightforward. The relevant bit:
digraph tags { rankdir=RL; overlap=false; splines=false;
Thanks!
You can increase the weight of the edges between ranks 2 and 3 to force these edges to be shorter. Help the solver by reducing the corresponding weights of the rank 1 to 2 edges.
Looking again, I see that you have a cluster around the items in ranks 1 and 2. This causes them to be kept as close together as possible. Removing the cluster will allow a more relaxed layout and help with the appearance. If you need the cluster, you could place invisible nodes between the groups to force them to be more spread out, but you would lose future flexibility in the layout as the hidden nodes could result in unexpected changes in layout.
I would like to use graphviz for a project and am unable to get the behaviour I want. I have a graph that I can draw with graphviz just fine, but I also have a version of the same graph that has some extra edges. I would like the second graph to be drawn with the nodes in the same positions as the first one and the edges in the same positions, but the new edges to be drawn without avoiding any overlap with nodes.
To get a better idea of what I want, imagine a Powerpoint slide with a graph and then on the next slide the same graph with these extra edges that appear on top of the first graph, wihtout modifying the look of the old parts of the graph. That is the effect I want.
I think the effect could be achieved by having some edges ignore any overlapping constraints. I could not figure out how to control the overlap between edges and nodes for particular edges (or even for all edges).
Any ideas?
You can get dot to output another .dot file, with positions assigned to all elements, via dot -Tdot (or maybe dot -Txdot). Add your additional edges to that file, and run it through dot again to produce your second graph.
I am creating a family tree program. My question is how do i position the nodes? Originally i positioned the root at the center of my screen and it works fine if it is a perfect binary tree and the levels are very less. However it is not most often the case. This is a sample tree :-
A
B C
D E F I J
K L N O
As you can see, the main problem is regarding the position of the nodes. If a node has many childs and it's adjacent node also has many children, they tend to overlap.(MAIN PROBLEM) I am using absolute positioning of the node using Canvas in Silverlight. You may not bother with the Silverlight and Canvas part if you are not a Silverlight developer. I just need the logic of how to position the nodes.
The height of the tree can be computed fairly easily by knowing the total number of levels of tree but the width of the tree is what is troubling me. How can i calculate the width of the tree (total width of the canvas)
Can somebody give me some general guidelines regarding how to set the width of the canvas and what logic will work perfect for the positioning of the nodes.
NOTE :- I am not asking for the whole algorithm and it is not my homework. I already have the algorithm and database. I just need guideline for the positioning part of the node.
Thanks in advance :)
If you implement a function: width(node) for arbitrary node of this tree, it is easy to positioning each node
This function may be defined recursively:
- for a tree of height 1 it tree this is exactly length of this node
- for a tree of height bigger than 1 this is a sum of lengths of all direct children of this node (plus some spaces between those)
I would recommend starting with the widest level of the tree if you want to guess the width of the canvas. You can calculate by traversing the tree breadth-first. Multiply the number of nodes at that level by the amount of lateral space each node needs and you have the width of canvas you require.
However, that's no guarantee that adjacent nodes on the widest level won't each have many children. So, to perform spacing with no overlap, start by positioning the leaves of the tree at the deepest level and traverse the tree backwards, adding parents above and putting leaves into the gaps and at the sides.
I would suggest to give zoom in and zoom out functionality to unclutter the GUI Real Estate.
A Node with many children can be grouped and a special icon to denote it can be zoomed in to next level would be good i feel, as the family grows, as user can get big picture at first and as then can zoom into any branch he wishes too.
Take cues from google map's UI, might help.