How to draw the result of git merge -no-ff using the tikz-based package gitdags? - tikz

This source
\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\usepackage{gitdags}
\begin{document}
\begin{tikzpicture}
\gitDAG{
A -- {B, C} -- D
};
\end{tikzpicture}
\begin{tikzpicture}[
commit/.style={circle, draw=green!30!blue, fill=green!20!white, thick, text=black, font=\ttfamily},
]
\node (a) [commit] {A};
\node (c) [commit, below right = 0.8cm of a] {C};
\node (d) [commit, right = 1.3cm of a] {D};
\draw (d) edge [->] (a)
(d) edge [->] (c)
(c) edge [->] (a);
\end{tikzpicture}
\end{document}
compiles to the following image:
How can gitdags (the package used to create the first image) be persuaded to draw a graph with the topology shown in the second image?
As A is the parent of both C and D, both C and D should be braced together following A. As D is the child of both A and C, both A and C should be braced together before D. Thus C must be braced together with A while at the same time being in separate braces following A. I don't see how this is possible.
Is there some gitdag syntax that I am missing?

Here is one possible solution:
\documentclass[]{article}
\usepackage{tikz}
\usepackage{gitdags}
\begin{document}
\begin{tikzpicture}
\gitDAG{
A -- C[yshift=-10mm] -- D,
A -- D
};
\end{tikzpicture}
\end{document}
Any node in the DAG may be mentioned more than once. This solution mentions A once to establish its link to D via C, then mentions A again to establish the direct link between A and D.
By default C would be placed in line with A and D, so its height is manually adjusted with yshift.

Related

Writing numbers only each second and third line in Fortran

I am fighting with trying to get numbers 1 and 2 only on each second and third line in the second column.
I have a file tisk2 with
O
H
H
O
H
H
And I need to get to file tisk this:
O
H1
H2
O
H1
H2
I mean I want no number no text after O. I tried to write this code:
program cislo
implicit none
integer :: i, sum, j, k
character :: t*10, m*10
open(10,file="tisk2",status='old')
open(12,file="tisk",status='old')
do k=0,5
read(10,*) m
enddo
do j=1,3
do i = 0,0
t=" "
print*, t
exit
enddo
sum=0
do i=1,2
write(12,fmt='(a2,i2)') m, i
enddo
enddo
end program cislo
I can print only i and I get nothing, second line 1 and third line 2. Then alone print m. But when I want to put both to one file, it skips O and writes to file only H1, H2 and then again. Does anyone has an idea how to get what I need? Thank you for help.

Networkx and graphviz. How to suppress node and edge positions in dot output?

Take this simple networkx script.
import networkx as nx
g = nx.DiGraph()
g.add_edge("a","b")
g.add_edge("a","c")
g.add_node("D")
dotter = nx.nx_agraph.to_agraph(g)
dotter.layout("dot")
dot = dotter.to_string()
with open("test_w_pos.dot","w") as fo:
fo.write(dot)
The output is:
strict digraph "" {
graph [bb="0,0,162,108"];
node [label="\N"];
a [height=0.5,
pos="63,90",
width=0.75];
b [height=0.5,
pos="27,18",
width=0.75];
a -> b [pos="e,35.634,35.269 54.285,72.571 50.04,64.081 44.846,53.693 40.134,44.267"];
c [height=0.5,
pos="99,18",
width=0.75];
a -> c [pos="e,90.366,35.269 71.715,72.571 75.96,64.081 81.154,53.693 85.866,44.267"];
D [height=0.5,
pos="135,90",
width=0.75];
}
I'd like to not have any of the pos, height and width attributes as they vary from run to run and make it hard to compare to previous runs on complex graphs.
desired output
strict digraph "" {
node [label="\N"];
a;
b;
a -> b;
c;
a -> c;
D;
}
Both dot files give substantially the same output in svg (see below), so I find the positioning unnecessary and in fact I've never seen this information put into dot files previously.
I could not find anything in to_agraph or dotter.to_string, but I did not notice extra arguments are possible in dotter.layout(dot):
agraph.py
def layout(self, prog="neato", ๐Ÿ‘‰args=""๐Ÿ‘ˆ):
"""Assign positions to nodes in graph.
Yes, with this very simplistic file, I could drop the positioning data afterwards. But in a real graph, there will be a lot of other color and label attributes mixed in with the positions.
image with position attributes:
image without position attributes:
If you are only interested in the dot file you can use the pydot interface of networkx and call write_dot, e.g.
drawing.nx_pydot.write_dot(g, "test.dot")
Try dotter.layout("canon") (https://graphviz.org/docs/outputs/canon/). This will provide a (pretty printed) version of your graph without any positioning.

need a Maple program

Write a Maple code in order to find all the at most three digits Pythagorean triples (a, b, c), for
a, b, c > 0. We say that an integer triple(a, b, c) is a Pythagorean triple if a^2+b^2=c^2.
Hint: You might need to use the command type(sqrt(x),integer) as it returns true if x is a complete square. Get help for type from the help center.
one possibility. You can try to make it more efficient if needed.
result:=Array(1..999);
n:=0;
for a from 1 to 999 do
for b from a to 999 do
c:=sqrt(a^2+b^2);
if type(c,integer) and length(c)<=3 then
n:=n+1;
result(n):=[a,b,c];
fi;
od;
od;
result:=result(1..n);
To print them
for item in result do
print(item[1]^`2`+item[2]^`2`=item[3]^`2`)
od
....
Consider this:
isolve(a^2+b^2=c^2);

Dimension too large error with small number

I get a "Dimension too large" error because of \tmp but I don't understand why, because the result is not that large (around 1).
\begin{tikzpicture}[y=0.80pt, x=0.80pt, yscale=-0.10000, xscale=0.10000, inner sep=0pt, outer sep=0pt]
\def\xxpl{834.5599}
\def\yxpl{-46.1934}
\def\xxpr{1567.4944}
\def\yxpr{723.6958}
\def\tmp{(\yxpr-\yxpl)/(\xxpr-\xxpl)}
\draw[black] (0,0) -- ++({10*\tmp},{-1*10}); % Works
\draw[black] (0,0) -- ++({100*\tmp},{-1*100}); % Doesn't work
\end{tikzpicture}
Do you know why ?
Thank's in advance
With \def, the expression defined is just replace in the subsequent code. Unfortunately, it looks like tikz cannot compute a complex expression such as (\yxpr-\yxpl)/(\xxpr-\xxpl). You can use \pgfmathsetmacro instead of \def:
\begin{tikzpicture}[y=0.80pt, x=0.80pt, yscale=-0.10000, xscale=0.10000, inner sep=0pt, outer sep=0pt]
\def\xxpl{834.5599}
\def\yxpl{-46.1934}
\def\xxpr{1567.4944}
\def\yxpr{723.6958}
\pgfmathsetmacro\tmp{(\yxpr-\yxpl)/(\xxpr-\xxpl)}
%\draw[black] (0,0) -- ++({10*\tmp},{-1*10}); % Works
\draw[black] (0,0) -- ++({100*\tmp},{-1*100}); % Now work!
\end{tikzpicture}

Emacs auctex inserts line breaks after inline math in an ugly way

I got problems with emacs/auctex fill paragraph which insert linebreaks after each $blabla$ block, resulting in a poorly readable code. For exemple, hitting M-q on the following long line:
a $1$ b $2$ c $3$ d $4$ e $5$ f $6$ g $7$ h $8$ i $9$ j $10$ k $11$ l $12$ m $13$ n $14$ o $15$
Gives:
a $1$
b $2$
c $3$
d $4$
e $5$
f $6$ g $7$ h $8$ i $9$ j $10$ k $11$ l $12$ m $13$ n $14$ o $15$
I would like to have something like:
a $1$ b $2$ c $3$ d $4$ e $5$ f $6$ g $7$ h $8$ i $9$ j $10$ k
$11$ l $12$ m $13$ n $14$ o $15
Note: I have the impression that fill-paragraph didn't have this ugly behavior when I didn't use auctex but the built-in latex mode...
Any ideas?
Many thanks!
This can be fixed by changing the AUCTeX user option LaTeX-fill-break-at-separators (see AUCTeX Manual [Filling]).
Hit M-x and type customize-group in the minibuffer, then type LaTeX.
Now you should be able to see the option LaTeX Fill Break At Separators in the newly created buffer. Click on it (expanding it) and uncheck the box next to Closing Inline Math Switches. Don't forget to save.