I have the following graph:
digraph G {rankdir="LR";
node [fontname = "font-awesome"];
subgraph cluster17 {
2 [id=2, shape=rect;color="#A4A4A4";fillcolor="white";label=<<TABLE BORDER="0">
<TR><TD>1:10</TD></TR>
</TABLE>>, style="filled",fontsize=6,fixedsize=true,width=0.5,height=0.2,shape=Mrecord];
2 -> 4 [id="2t4",color="#717070",arrowsize=.5];
subgraph cluster3 {
4 [id=4,fillcolor="#F5BDA2", shape=rect;label=<<TABLE BORDER="0">
<TR><TD>1:12</TD></TR>
</TABLE>>, style="filled",shape=Mrecord];
5 [id=5,fillcolor="#F5BDA2", shape=rect;label=<<TABLE BORDER="0">
<TR><TD>1:13</TD></TR>
</TABLE>>, style="filled",shape=Mrecord];
6 [id=6,fillcolor="#F5BDA2", shape=rect;label=<<TABLE BORDER="0">
<TR><TD>1:14</TD></TR>
</TABLE>>, style="filled",shape=Mrecord];
7 [id=7,fillcolor="#F5BDA2", shape=rect;label=<<TABLE BORDER="0">
<TR><TD>1:15</TD></TR>
</TABLE>>, style="filled",shape=Mrecord];
8 [id=8,fillcolor="#F5BDA2", shape=rect;label=<<TABLE BORDER="0">
<TR><TD>1:19</TD></TR>
</TABLE>>, style="filled",shape=Mrecord];
6 -> 7 [id="6t7",color="#717070",arrowsize=.5];
4 -> 5 [id="4t5",color="#717070",arrowsize=.5];
8 -> 4[id="8t4",color="#717070",arrowsize=.5];
5 -> 6 [id="5t6",color="#717070",arrowsize=.5];
7 -> 8 [id="7t8",color="#717070",arrowsize=.5];
label=<<TABLE BORDER="0">
<TR><TD>Loop</TD></TR>
<TR><TD>1:11</TD></TR>
</TABLE>>;
style="filled"
fillcolor="#EDF1F2"
color="#028d35"
id=3
}
4 -> 10 [id="4t10",color="#717070",arrowsize=.5];
10 [id=10, shape=rect;color="#A4A4A4";fillcolor="white";label=<<TABLE BORDER="0">
<TR><TD>1:20</TD></TR>
</TABLE>>,fontsize=6,fixedsize=true,width=0.5,height=0.2,shape=Mrecord, style="filled"];
label=<<TABLE BORDER="0">
<TR><TD>1:9</TD></TR>
</TABLE>>;
style="filled"
fillcolor="#EDF1F2"
color="#A4A4A4"
id=17
}
}
which gives the following graph:
I wanted to change the graph of the cluster3 to a rectangle with rounded corner. I tried to insert shape=Mrecord, but it doesn't work.
How can I change the shape of the cluster to a rectangle with rounded corner?
Instead of
style="filled"
you may use
style="rounded"
bgcolor="#028d35"
The style rounded does not use fillcolor, but bgcolor instead.
These are the valid styles for cluster:
Related
I want to draw a clean network graph like this image.
But I couldn't find how can I do this. I have to use css for removing part of cell border line, but, as far as I know, dot file is not supported css. I want to insert ellipse shape node, separate node with vertical bar,
How can I draw a graph that satisfies these conditions? My dot file has self loop, so I can't use networkx. Any other ways are exist? or can I solve use dot file?
My dot file code is
digraph {
// size = "6,8.5";
// ratio = "fill";
// layout = "circo"
forcelabels = True;
graph[overlap=False];
node [shape = ellipse];
node [fontsize = 10];
// node [penwidth = 3];
edge [fontsize = 10];
// A [pos = "0,2"]
// B [pos = "-2,-2"]
// C [pos = "0,1"]
// D [pos = "2,-2"]
// E [pos = "0,-3"]
A
B
C
D
E;
node[shape = point];
x1[style = invis]
{rank=same; A,C}
{rank=same; B,E}
A -> C [label = "4|1.0\l"];
B -> B [label = "1|:0.979\l"];
C:nw -> C:ne [label = "3|0.167\l"];
C -> D [label = "5|0.115\l"];
D:nw -> C:sw [xlabel = "3|0.103\l4|0:0.315\l"];
D:se -> x1 [dir = none]
x1 -> D:sw [xlabel = "5|0.308\l6|0:0.253\l"];
E -> B [label = "4|0.5\l"];
E -> D [label = "6|0.5\l"];
}
Two ways to create your nodes, one fairly close (well to my eyes) and pretty easy to replicate. The other will allow you to recreate your example, but requires using two programs (dot and a program to create individual nodes in svg - like Inkscape)
digraph structs {
// if oblong is good enough, this works
node [shape=none]
try3 [label=<
<TABLE border="1" cellborder="0" cellspacing="0" cellpadding="0" style="rounded" >
<TR><TD width="40">A</TD><VR/><TD width="40">*111<BR/>*101<BR/>*011</TD></TR>
</TABLE>>];
// if you really want a circular node, perfectly split
// create the node images with another program (like Inkscape)
// and include as an image
try5 [image="/tmp/split1.svg" label=""]
}
producing:
Maybe I'm trying to bend graphviz more than I should, but would it
be possible to straighten the arrows? I need the labels to be over the arrow, not to the side as with label/xlabel; I'm using boxes to hold what is essentially label text, since using labels on the edges seems to lead to whacky behavior when the labels are long.
digraph G {
node [shape=rect style=filled
fontcolor=white fontsize=12 fontname="Helvetica Bold"]
edge [style=solid color="#777777"]
// introduce nodes; set fill
a1, a2, a3 [fillcolor="#438dd5"]
c1 [fillcolor="#08427b"]
b1, b2, b3 [fillcolor=white fontcolor=black fontname="Helvetica" shape=plain]
a1 -> b1[dir=none]
a2 -> b2[dir=none]
a3 -> b3[dir=none]
b1 -> c1
b2 -> c1
b3 -> c1
{ rankdir=LR rank=same a1 a2 a3 }
{ rankdir=LR rank=same b1 b2 b3 }
{ rankdir=LR rank=same c1 }
}
What I get:
What I want:
I usually do it using tables with no borders and white background instead of labels. You would probably also need to use headlabel or taillabel, because in this case you can precisely control their position with labeldistance and labelangle:
digraph G {
node [shape=rect style=filled
fontcolor=white fontsize=12 fontname="Helvetica Bold"]
graph [ranksep=1]
edge [style=solid color="#777777"]
a1 [fillcolor="#438dd5"]
a2 [fillcolor="#438dd5"]
a3 [fillcolor="#438dd5"]
c1 [fillcolor="#08427b"]
a1 -> c1 [
labeldistance=5
labelangle=0
headlabel=<
<table bgcolor="white" border="0">
<tr>
<td>b1</td>
</tr>
</table>
>
]
a2 -> c1 [
labeldistance=4
labelangle=0
headlabel=<
<table bgcolor="white" border="0">
<tr>
<td>b2</td>
</tr>
</table>
>
]
a3 -> c1 [
labeldistance=5
labelangle=0
headlabel=<
<table bgcolor="white" border="0">
<tr>
<td>b3</td>
</tr>
</table>
>
]
}
result:
I would like to show the diagram below, except with the two tables on the same horizontal level. I would like the second table to be shown to the right of the first table and not below it like it is currently.
The current code for graphviz that I have is:
digraph G {
node [shape=record, fontname="Arial"];
set1 [label = "{Blue Crosses | B1 | B2 | B3 | B4 }|{ Square |<b1> Left |<b2> Left |<b3> Right | Left }"];
set2 [label = "{Blue Crosses |<b1> B1 |<b2> B2 |<b3> B3 }|{ Coordinates | (1, 1) | (2, 2) | (4, 2) }"];
set1:b1 -> set2:b1;
set1:b2 -> set2:b2;
set1:b3 -> set2:b3;
}
In order to achieve what you want, you need to add the line
{ rank = same; set1 set2 }
to your code after you have created the nodes. However, in this situation, you will find that graphviz gets confused and doesn't recognise the ports anymore. So instead of using record = shape you will need to re-code your graph with HTML-like labels. I have done that for the example provided (thanks for a clear question with code and desired outcome, by the way):
digraph G
{
node[ shape = none, fontname = "Arial" ];
set1[ label=<
<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="4">
<TR>
<TD>Blue Crosses</TD>
<TD>Square</TD>
</TR>
<TR>
<TD>B1</TD>
<TD PORT="b1">Left</TD>
</TR>
<TR>
<TD>B2</TD>
<TD PORT="b2">Left</TD>
</TR>
<TR>
<TD>Right</TD>
<TD PORT="b3">Right</TD>
</TR>
<TR>
<TD>B4</TD>
<TD>Left</TD>
</TR>
</TABLE>>];
set2[ label=<
<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="4">
<TR>
<TD>Blue Crosses</TD>
<TD>Coordinates</TD>
</TR>
<TR>
<TD PORT="b1">B1</TD>
<TD>(1, 1)</TD>
</TR>
<TR>
<TD PORT="b2">B2</TD>
<TD>(2, 2)</TD>
</TR>
<TR>
<TD PORT="b3">B3</TD>
<TD>(4, 2)</TD>
</TR>
</TABLE>>];
# layout
nodesep = 2; /* increase distance between nodes */
{ rank = same; set1 set2 }
set1:b1 -> set2:b1;
set1:b2 -> set2:b2;
set1:b3 -> set2:b3;
}
yields
I have the following simple graph and I want to have only the text GetArea() in italics. Is this possible?
digraph {
rankdir = BT;
node [shape=record];
cPolygon [label="{cPolygon|GetArea()}"];
{rank=same; cSquare cTriangle}
cSquare -> cPolygon;
cTriangle -> cPolygon;
}
I think you should use HTML like labels:
digraph {
rankdir = BT;
node [shape=record];
cPolygon [label=<<table border="0"><tr><td>cPolygon</td></tr><tr><td><i>GetArea()</i></td></tr></table>>];
{rank=same; cSquare cTriangle}
cSquare -> cPolygon;
cTriangle -> cPolygon;
}
yields
edit
a horizontal row:
...
cPolygon [label=<<table border="0"><tr><td>cPolygon</td></tr><hr/><tr><td><i>GetArea()</i></td></tr></table>>];
...
I am trying to avoid the crossing of the lines between 20->40 and 30->70. Does anyone know how to do this? I am using single points to straighten out the edges but I would have expected the rendering engine to avoid these edges to overlap. Here is my dot code:
digraph {
graph [splines="ortho", nodesep = "1", overlap = false];
node [shape=rectangle, color=lightgrey, style=filled ];
10
20
30
40
50
60
70
80
90
node[shape=none, width=0, height=0 label=""];
edge[dir=none];
{rank=same;
p1->10
10->p2
}
p1->20
p2->30
{rank=same;
p3->40
40->p4
}
p3->50
p4->60
{rank=same;
p5->70
70->p6
}
p5->80
p6->90
20->40
30->70
}
I wanted to post an image, but stackoverflow does not allow me to do this... You can see what I mean when you copy the code into: http://stamm-wilbrandt.de/GraphvizFiddle/
I really appreciate your help on this!
You could give graphviz a hint by adding an invisible edge between p4 an dp5:
{
rank=same;
p3 -> 40;
40 -> p4;
p4 -> p5 [style=invis]; // new invisible edge
p5 -> 70;
70 -> p6;
}
If you are not able to add invisible edges (dynamic graph generation), make sure nodes which are part of a subgraph do appear first within the subgraph, and therefore avoid upfront node definitions.
In this example, I removed the node definitions in the beginning of the script and inlined the style of the elbow-joint nodes.
Here's the GraphvizFiddle
digraph {
graph [splines="ortho", nodesep = "1", overlap = false];
node [shape=rectangle, color=lightgrey, style=filled ];
//node[shape=none, width=0, height=0, label=""];
edge[dir=none];
{
rank=same;
p1[shape=none, width=0, height=0, label=""];
p2[shape=none, width=0, height=0, label=""];
p1->10
10->p2
}
p1->20
p2->30
{
rank=same;
p3[shape=none, width=0, height=0, label=""];
p4[shape=none, width=0, height=0, label=""];
p3->40
40->p4
}
p3->50
p4->60
{
rank=same;
p5[shape=none, width=0, height=0, label=""];
p6[shape=none, width=0, height=0, label=""];
p5->70
70->p6
}
p5->80
p6->90
20->40
30->70
}