Graphviz nodes rendering - graphviz

I have a simple graphviz graph that is drawn as shown in the following image:
digraph G {
"Model" -> "Task";
"Task" -> "Worker 1" -> "Sink";
"Task" -> "Worker 2" -> "Sink";
"Task" -> "Worker 3" -> "Sink";
}
Adding and edge between the sink and task nodes, the graph output is shown the following image:
"Sink" -> "Model";
How could I add this edge and keep the original symmetric node layout shown in the first image?

(Edited to improve my original answer)
Building on the answer to How to control subgraphs' layout in dot?, if we start by laying out the core digraph with dot, we can then use neato to add the additional edge. neato allows nodes that already have defined positions to be pinned using the -n parameter so one could do something like this (where symmetric.dot contains the original GraphViz digraph with the addition of graph [splines = true]):
#!/bin/bash
dot -Tdot symmetric.dot >symmetric1.dot
neato -n2 -Tpng symmetric1.dot -osymmetric1.png
sed 's/^}/"Sink" -> "Model";}/' <symmetric1.dot >symmetric2.dot
neato -n2 -Tdot symmetric2.dot >symmetric3.dot
neato -n2 -Tpng symmetric3.dot -osymmetric3.png
This script:
Uses dot to lay out the original digraph into a new .dot file.
Uses neato -n2 to plot the original digraph. The -n2 option prevents neato from moving nodes that already have positions.
Uses sed to insert the "Sink" -> "Model" edge.
Uses neato -n2 to lay out the new edge (which is the only one without pos defined, and thus the only one not pinned) and plot it as a .png file.
symmetric1.png looks like this:
... and symmetric3.dot with the additional edge looks like this:

Related

Rendering of a graph using dot program

I am trying to display a graph with the dot program with an example taken from https://graphs.grevian.org/example#example-2 .
I should get this output:
Instead I get this one.
How is it possible to generate the second one?
Here is the code I used:
dot graph_path.dot -Tpdf > vis.pdf
graph {
a -- b;
b -- c;
c -- d;
d -- e;
e -- f;
a -- f;
a -- c;
a -- d;
a -- e;
b -- d;
b -- e;
b -- f;
c -- e;
c -- f;
d -- f;
}
Edit
In the man page of dot in my terminal (under MacOS 11.6.1), the following is written:
...
OUTPUT FORMATS
Graphviz uses an extensible plugin mechanism for its output renderers, so to see what output formats your
installation of dot supports you can use ``dot -T:'' and check the warning message. Also, The plugin mechanism
supports multiple implementations of the output formats, allowing variations in the renderers and formatters.
To see what variants are available for a particular output format, use, for example: ``dot -Tpng:'' and to
force a particular variant, use, for example: ``dot -Tpng:gd''
...
So I assume that Graphviz is used
EDIT 2
thanks to the answer of sroush, there are several commands to create graphs such as:
dot graphK6.dot -Tpdf > vis1.pdf
sfdp graphK6.dot -Tpdf > vis2.pdf
neato graphK6.dot -Tpdf > vis3.pdf
circo graphK6.dot -Tpdf > vis4.pdf
Indeed, this is a Graphviz result, but it was not produced by the dot layout engine. It was produced by the circo layout engine.
Graphviz has 6 primary engines (and more related programs) that all take the same input language.
Circo is not well documented, but here is the common "man" page. (http://www.graphviz.org/pdf/dot.1.pdf)
Here is the same input run through the 6 primary engines:

xmgrace: changing color of the XY graph in batch execution

I am using gracebat integrated into my bash script to make simple XY graph from 2D numerical data
gracebat input.xvg -hdevice PNG -fixed 800 600 -world 0 0.02 610 0.5 -printfile output.png -hardcopy
This simple execution without GUI produces the XY graph totally in black color!
would it be possible to quickly change to color of the line (I guess should be s0 color in the batch file) without using batch file for gracebat: e.g. via some option of gracebat or alternatively via editing of the input.xvg (via sed or any shell utility) specifying color or the line:
# s0 line color 2
Alternatively, if the grace has not good possibilities for graph customization, I would be grateful for simple example of the gnuplot batch execution.
What does xmgrace -help say? Please check the corresponding manuals and homepages and do a search on SO and the web before asking such questions. I don't now xmgrace and its documentation.
But a gnuplot command line would be using the command line option -e: (check help command line options).
gnuplot -e "set term pngcairo size 800,600; set output 'myFile.png'; plot 'myFile.dat' u 1:2 w l lc 'red' "

Can't rotate in pdftk

I am following the online instructions and trying to rotate all pages of a PDFs 90 degrees clockwise like so
pdftk in.pdf cat 1E output out.pdf
But then I get the following error
Error: Unexpected text in page range end, here:
1
Exiting.
Acceptable keywords, for example: "even" or "odd".
To rotate pages, use: "north" "south" "east"
"west" "left" "right" or "down"
Errors encountered. No output created.
Done. Input errors, so no output created.
I can't imagine what I'm doing wrong
The compass direction should be given in full (EAST rather than E).
To rotate the first page:
pdftk t/helloworld.pdf cat 1EAST output out.pdf
To rotate all pages (page range 1-end):
pdftk t/helloworld.pdf cat 1-endEAST output out.pdf

Is it possible to infer the edit distance using a unified diff?

I have 2 files with contents spanning multiple lines. I'd like to find the edit distance; i.e. how many changes are required to transform A to B assuming only insertions and deletions are possible.
> cat > A
A
B
C
D
E
> cat > B
A
B
D
D
F
E
> diff -u A B
--- A 2015-05-12 16:09:31.000000000 +0200
+++ B 2015-05-12 16:09:42.000000000 +0200
## -1,5 +1,6 ##
A
B
-C
D
+D
+F
E
Would it be accurate to say that the total number of + and - give me the edit distance?
Going by your definition of edit distance (similiar to "Longest common subsequence problem"), you will first need to define what a single change is.
a single character?
a line?
a file?
The longest common subsequence problem is a classic computer science
problem, the basis of data comparison programs such as the diff
utility, and has applications in bioinformatics. It is also widely
used by revision control systems such as Git for reconciling multiple
changes made to a revision-controlled collection of files.
Assuming you want lines to define a change (based on your example), then yes, the total number of + and - using the diff command would suffice. This is because an update/substitution will show up as both a deletion (-) and an insertion (+).
See also http://en.wikipedia.org/wiki/Diff_utility#Unified_format

DOT gives "triangulation failed" error

I have a .dot file and I am using command line to plot a graph using the dot file in pdf format using the following command
$ dot -Tpdf -O output_model.dot
I am getting the following error:
libpath/shortest.c:315: triangulation failed
libpath/shortest.c:183: source point not in any triangle.
Any ideas why am I seeing this error?
Without seeing the contents of your .dot file it is difficult to know. But, I've had a similar error when using the constraint=false parameter on the edges in a graph.

Resources