I've made a tree in the dot language, similar to the one here.
Is there any way I could get the tree to expand to the right, instead of downwards (so the root node is on the left and children go along to the right).
it's very easy, as long as you stick to basic layout: place rankdir="LR" near top definition. Something like
digraph unix {
size="6,6";
rankdir="LR";
...
}
Related
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.
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'm trying to create binary trees using the Graphviz tool but not as I would like.
For example: I would like to draw this tree:
With Graphviz I managed to do this:
In principle is fine but I would like that the nodes were arranged as the sample image. There is more space between nodes brothers.. I wish every time a parent node generates a son (though only child), the latter is or left or right of the father, and not in the middle.
Then I would like that the arrows are more subtle.
Searching the internet I could not find how to change the layout of the nodes nor how to make thinner arrows. I only found how to change the shape of the arrow but it is not what interests me.
Thanks to anyone who can help me!
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'm trying to draw a graph with two kinds of edges, and I want the two kinds of edges to link to each node from opposite sides, as much as possible. I.e. if an edge of type A enters from the left, I want all edges of type B to exit to the right. I know I could specify compass directions, but I'd like graphviz to be able to switch this around to minimize graph clutter.
Is it this, or something similar, possible?
If you don't want to specify compass points, you'll probably not want to use HTML like labels and ports either.
If you're using dot, you still can achieve something similar by using the samehead and the sametail attributes. From the reference:
Edges with the same head and the same
samehead value are aimed at the same
point on the head
This lets you group outgoing and incoming edges. Here's a simple example:
digraph g{
rankdir=LR;
edge[samehead=h1, sametail=t1];
a1->b->c1;
a2->b->c2;
edge[samehead=h2, sametail=t2];
a3->b->c3;
a4->b->c4;
}
This of course is only about grouping heads and tails of edges, and does not guarantee opposite sides for edges of different types.
My current solution is to replace my old nodes with edges, thus creating two nodes - one for each "port" in the graph. I can then my edges between these "port nodes". Eg. instead of
node1 -> node2 [ sametail="b", samehead = "a" ]
I write
node1_a -> node1_b [ dir=none, style=bold ]
node2_a -> node2_b [ dir=none, style=bold ]
node1_a -> node2_b // if I got head and tail right :-)
Although I don't get boxes for my "nodes", this works okay for my purposes.