How to improve TikZ diagram with a lot of edges?
like this?
edit
in comparison to your code the code in mwe, by which the above image was drawm, has the following changes/improvements:
- by introducing library
quotes
writing of edge labels is simplified and much shorter. for example, instead of
\draw (H) edge[bend right=10,geldstrom] node[left] {3} (B);
is possible obtain the same result with
\draw (H) edge ["3"] (B)
where for edge i define style, which determine edge color, thickness, shortness and bending angle:
every edge/.style = {draw=SlateGrey, -Stealth, line width=2pt,
shorten <=5pt, shorten > = 5pt,
bend right=8},
- the angle of bending is essentially determined by trial and error method. however there i exploit my experiences from drawing of the similar diagrams and knowledge of geometry (already my first trial was successful). in the edge style i determine the most common angle, exceptions for four edges are determined locally.
- since edges style is defined, there is no more need to write
\draw ... :
for each edge. it is sufficient write it ones and then list all edges (see mwe below). - with style
edge quotes
is determined font size and position of edge labels. - size of nodes shapes is also changed. used bigger height (and also with shortening of edges) prevent edges overlaps.
- with library
arrows.meta
is defined on decent ways arrows heads summary of
tikzpicture
changes are:- style
subjekt
is renewed - styles
strom
,gueterstrom
andgeldstrom
are replaced byevery edge
andevery edge quotes
- style
\documentclass[parskip=half]{scrreprt}
\usepackage[svgnames]{xcolor}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,
positioning,
quotes,
shapes}
\begin{document}
\begin{tikzpicture}[auto=right,
node distance = 44mm,
subjekt/.style = {draw, semithick, minimum height=12mm, minimum width=24mm},
every edge/.style = {draw=SlateGrey, -Stealth, line width=2pt,
shorten <=5pt, shorten > = 5pt,
bend right=8},
every edge quotes/.append style = {inner sep=2pt, font=\small, pos=0.6},
]
\node (H) [subjekt] {Haushalt};
\node (U) [subjekt,below right=of H] {Unternehmen};
\node (S) [subjekt,above right=of U] {Staat};
\node (B) [subjekt,below left =of U] {Banken};
\node (A) [subjekt,below right=of U] {Ausland};
%
\draw (H) edge ["3"] (B)
(B) edge ["9"] (H)
(H) edge ["1"] (S)
(S) edge ["13"] (H)
(H) edge ["2"] (U)
(U) edge ["6"] (H)
%
(H) edge [bend right=24, "4"] (A)
(A) edge [bend right=24, "20"] (H)
%
(B) edge ["10"] (U)
(U) edge ["7"] (B)
(B) edge ["12"] (A)
(A) edge ["19"] (B)
%
(B) edge [bend right=24, "11"] (S)
(S) edge [bend right=24, "16"] (B)
%
(A) edge ["18"] (U)
(U) edge ["8"] (A)
(A) edge ["17"] (S)
(S) edge ["14"] (A)
(S) edge ["15"] (U)
(U) edge ["5"] (S);
\end{tikzpicture}
\end{document}
The arrangement you chose is very suboptimal for a fully connected graph. It is better to arrange things in a circular layout.
TikZ graphdrawing
requires LuaTeX.
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{graphs,graphdrawing,quotes}
\usegdlibrary{circular}
\begin{document}
\begin{tikzpicture}
\graph[
simple necklace layout,
edges={bend right=10},
edge quotes={fill=white,inner sep=1pt,font=\tiny},
nodes={draw},
node sep=5em,
] {
Haushalt -> {Staat [>"1"], Unternehmen [>"2"], Banken [>"3"], Ausland [>"4"]},
Unternehmen -> {Haushalt [>"6"], Staat [>"5"], Banken [>"7"], Ausland [>"8"]},
Banken -> {Haushalt [>"9"], Staat [>"11"], Unternehmen [>"10"], Ausland [>"12"]},
Staat -> {Haushalt [>"13"], Unternehmen [>"15"], Banken [>"16"], Ausland [>"14"]},
Ausland -> {Haushalt [>"20"], Staat [>"17"], Unternehmen [>"18"], Banken [>"19"]}
};
\end{tikzpicture}
\end{document}
How to improve the situation in the corners? Get rid of the corners! I also changed the arrow tips and tightened things up a bit.
\documentclass[parskip=half]{scrreprt}
\usepackage[svgnames]{xcolor}
\usepackage{tikz}
\usetikzlibrary{positioning,shapes}
\tikzset{subjekt/.style={circle,draw,minimum height=.7cm, minimum width=2.2cm, align=center},
strom/.style={line width=2pt, shorten >=2pt,shorten <=2pt},
gueterstrom/.style={strom,Goldenrod,->},
geldstrom/.style={strom,SlateGrey,->}}
\begin{document}
\begin{tikzpicture}[node distance=4cm,>=stealth]
\node[subjekt] (H) at (0,0) {Haushalt};
\node[subjekt] (U) [below right= of H] {Unternehmen};
\node[subjekt] (S) [above right= of U] {Staat};
\node[subjekt] (B) [below left= of U] {Banken};
\node[subjekt] (A) [below right= of U] {Ausland};
\draw (H) edge[bend right=10,geldstrom] node[left] {3} (B);
\draw (B) edge[bend right=10,geldstrom] node[right] {9} (H);
\draw (H) edge[bend right=10,geldstrom] node[below] {1} (S);
\draw (S) edge[bend right=10,geldstrom] node[above] {13} (H);
\draw (H) edge[bend right=10,geldstrom] node[below left] {2} (U);
\draw (U) edge[bend right=10,geldstrom] node[above right] {6} (H);
\draw (H) edge[bend right=22,geldstrom, near end] node[below left] {4} (A);
\draw (A) edge[bend right=22,geldstrom, near end] node[above right] {20} (H);
\draw (B) edge[bend right=10,geldstrom] node[below right] {10} (U);
\draw (U) edge[bend right=10,geldstrom] node[above left] {7} (B);
\draw (B) edge[bend right=10,geldstrom] node[below] {12} (A);
\draw (A) edge[bend right=10,geldstrom] node[above] {19} (B);
\draw (B) edge[bend right=22,geldstrom, near end] node[below right] {11} (S);
\draw (S) edge[bend right=22,geldstrom, near end] node[above left] {16} (B);
\draw (A) edge[bend right=10,geldstrom] node[above right] {18} (U);
\draw (U) edge[bend right=10,geldstrom] node[below left] {8} (A);
\draw (A) edge[bend right=10,geldstrom] node[right] {17} (S);
\draw (S) edge[bend right=10,geldstrom] node[left] {14} (A);
\draw (S) edge[bend right=10,geldstrom] node[above left] {15} (U);
\draw (U) edge[bend right=10,geldstrom] node[below right] {5} (S);
\end{tikzpicture}
\end{document}