我当然缺乏图论、计算、优化或可能只是几何方面的知识!但我只想问一下这里的智囊,是否存在解决标题中问题的方法(无需外部程序?)。如果没有,自动化和谐思维导图的下一步是什么?
到目前为止的答案顺序
基于关于思维导图形状自动化的多个问题(生长周期 4 或 5 级的圆形,3 级圆形, 矩形旁边的节点 ),薛定谔的猫对这个话题给出了多种变体,并产生了多个复杂的增长函数。通过 2 个编译,它们会自动计算每个级别的节点数,并根据 360/该级别的节点数自动调整兄弟角度。
什么有效
正如之前的文章中提到的,当思维导图平衡良好(节点和子节点数量相对相等)时,增长功能可以很好地发挥作用,并达到以下理想目标:注重内容,而不是节点的组织(这不是 TeX 最初的目标之一吗?)。
什么效果较差...
问题来自于不平衡的思维导图,例如,只有第 2 级而没有第 3 级或第 4 级。节点看起来扭曲了,感觉就像制表机制,您想将第 2 级顺时针移动 X%,将第 3 级逆时针移动 Y%(如下所示)以使事情变得更美好。
迄今为止的结论(薛定谔的猫)
“如果有人能提出一个具体的想法(比如说一个具体的算法),并以此为基础,那么进步就更大。人们可以探索上述许多可能的修改。一个特别有希望的可能是将思维导图故事与图形绘制算法结合起来。”
我运行了以下代码(基于适合 4 级或 5 级的形状对极限情况下的形状有一个概念,我得到了一个节点之间距离的奇怪行为(而且没有的话会更加奇怪[clockwise from=0]
,我对进行了硬编码sibling angles
,我无法适应level distance
)
\documentclass[tikz,border=9]{standalone}
\usetikzlibrary{mindmap,decorations}
\makeatletter
\newcount\tikzcountchildi
\newcount\tikzcountchildii
\newcount\tikzcountchildiii
\newcount\tikzcountchildiv
\newcount\tikzcountchildv
\newcount\tikzcountchildvi
\tikzset{garlic growth/.style={growth function=\tikz@grow@garlic,
/tikz/mmap/name=#1,mmap/#1/.is family,
mmap/initialize counts,
execute at end scope={%
\tikz@mmap@store@aux{n-i}{\the\tikzcountchildi}%
\tikz@mmap@store@aux{n-ii}{\the\tikzcountchildii}%
\tikz@mmap@store@aux{n-iii}{\the\tikzcountchildiii}%
\tikz@mmap@store@aux{n-iv}{\the\tikzcountchildiv}%
\tikz@mmap@store@aux{n-v}{\the\tikzcountchildv}%
\tikz@mmap@store@aux{n-vi}{\the\tikzcountchildvi}}},
mmap/.cd,initialize counts/.code={\tikzcountchildi=0%
\tikzcountchildii=0%
\tikzcountchildiii=0%
\tikzcountchildiv=0%
\tikzcountchildv=0%
\tikzcountchildvi=0%
}
}
\def\tikz@mmap@store@aux#1#2{%
\immediate\write\@mainaux{\string\expandafter\xdef\noexpand\csname pgfk@/tikz/mmap/\pgfkeysvalueof{/tikz/mmap/name}/#1\string\endcsname{#2}}}%
\def\tikz@mmap@get@from@aux#1#2{%
\ifcsname pgfk@/tikz/mmap/\pgfkeysvalueof{/tikz/mmap/name}/#1\endcsname
\edef#2{\csname pgfk@/tikz/mmap/\pgfkeysvalueof{/tikz/mmap/name}/#1\endcsname}%
\else
\edef#2{0}%
\fi
}
\newcount\tikzcountgrandchild
\def\tikz@grow@garlic{%
\pgfmathsetmacro{\pgfutil@tempa}{\pgfkeysvalueof{/tikz/mmap/overall rotation}}%
\ifcase\tikztreelevel
\or
\global\advance\tikzcountchildi by1\relax%
\tikz@mmap@get@from@aux{n-i}{\myni}%
\tikz@mmap@get@from@aux{n-ii}{\mynii}%
\tikz@mmap@get@from@aux{n-1-\the\tikzcountchildi}{\mynall}%
\tikz@mmap@get@from@aux{p-1-\the\tikzcountchildi}{\mypi}%
\ifnum\mynii>0
\pgfmathsetmacro{\pgfutil@tempa}{\pgfutil@tempa+\pgfkeysvalueof{/tikz/mmap/sign}%
*(\pgfkeysvalueof{/tikz/mmap/child weight}*(\mypi)*360/\mynii+%
(1-\pgfkeysvalueof{/tikz/mmap/child weight})*(\tikzcountchildi-1)*360/\myni)}%
\fi
\or
\global\advance\tikzcountchildii by1\relax%
\tikz@mmap@get@from@aux{n-ii}{\mynii}%
\tikz@mmap@get@from@aux{n-1-1}{\mynall}%
\ifnum\mynii>0
\pgfmathsetmacro{\pgfutil@tempa}{\pgfutil@tempa+\pgfkeysvalueof{/tikz/mmap/sign}%
*(\tikzcountchildii-1-\mynall/2)*360/\mynii}%
\fi
\ifnum\tikznumberofcurrentchild=1\relax
\tikz@mmap@store@aux{n-1-\the\tikzcountchildi}{\the\tikznumberofchildren}%
\tikz@mmap@store@aux{p-1-\the\tikzcountchildi}{\the\numexpr\tikzcountchildii-1}%
\tikz@mmap@store@aux{a-1-\the\tikzcountchildi-\the\tikzcountchildii}{\pgfutil@tempa}%
\fi
\or
\global\advance\tikzcountchildiii by1\relax%
\ifnum\tikznumberofcurrentchild=1\relax
\tikz@mmap@store@aux{n-1-\the\tikzcountchildi-\the\tikzcountchildii}{\the\tikznumberofchildren}%
\tikz@mmap@store@aux{p-1-\the\tikzcountchildi-\the\tikzcountchildii}{\the\numexpr\tikzcountchildiii-1}%
\fi
\tikz@mmap@get@from@aux{n-iii}{\myniii}%
\tikz@mmap@get@from@aux{a-1-1-1}{\bettera}%
\tikz@mmap@get@from@aux{n-1-1-1}{\mynall}%
\ifdim\bettera pt=0pt\relax
\else
\pgfmathsetmacro{\pgfutil@tempa}{\bettera}%
\fi
\ifnum\myniii>0
\pgfmathsetmacro{\pgfutil@tempa}{\pgfutil@tempa+\pgfkeysvalueof{/tikz/mmap/sign}%
*(\tikzcountchildiii-1-\mynall/2)*360/\myniii}%
\fi
\or
\global\advance\tikzcountchildiv by1\relax%
\tikz@mmap@get@from@aux{n-iv}{\myniv}%
\ifnum\myniv>0
\pgfmathsetmacro{\pgfutil@tempa}{\pgfutil@tempa+\pgfkeysvalueof{/tikz/mmap/sign}*(\tikzcountchildiv-1)*360/\myniv}%
\fi
\or
\tikz@mmap@get@from@aux{n-v}{\mynv}%
\pgfmathsetmacro{\pgfutil@tempa}{\pgfutil@tempa+\pgfkeysvalueof{/tikz/mmap/sign}*(\tikzcountchildv-1)*360/\mynv}%
\ifnum\mynv>0
\global\advance\tikzcountchildv by1\relax%
\fi
\or
\global\advance\tikzcountchildvi by1\relax%
\tikz@mmap@get@from@aux{n-vi}{\mynvi}%
\ifnum\myvi>0
\pgfmathsetmacro{\pgfutil@tempa}{\pgfutil@tempa+(\tikzcountchildvi-1)*360/\mynvi}%
\fi
\fi
\pgftransformreset%
\pgftransformshift{\pgfpoint{\pgfkeysvalueof{/tikz/mmap/overall xshift}}%
{\pgfkeysvalueof{/tikz/mmap/overall yshift}}}%
\pgftransformrotate{\pgfutil@tempa}%
\pgftransformxshift{\the\tikzleveldistance}%
}
\makeatother
\begin{document}
\tikzset{mmap/.cd,
name/.initial=undef,
overall rotation/.initial=00,
overall xshift/.initial=0pt,
overall yshift/.initial=0pt,
sign/.initial=1,
child weight/.initial=0,
/tikz/.cd,
Xshift/.style={xshift=#1,mmap/overall xshift=#1},
Yshift/.style={yshift=#1,mmap/overall yshift=#1},
branch color/.style={
concept color=#1!80,ball color=#1!50,
every child/.append style={concept color=#1!50},
}
}
\begin{tikzpicture}
\begin{scope}[
mindmap,garlic growth=A,
mmap/child weight=0,
mmap/overall rotation=00,
mmap/sign=-1,
root concept/.append style={ball color=blue!50, line width=1.5ex,text=red!80!black,font=\Large\bfseries\scshape,minimum size=2.5cm,text width=2.5cm,},
nodes={concept,align=center, text width=2cm,inner sep=1mm,minimum size=1.0cm,execute at begin node=\hskip0pt},
concept color=blue!50!black,
level 1/.style={nodes=concept,
every child/.append style={concept color=blue!90},
level distance=4cm,
},
level 2/.style={%opacity=0,
% nodes=concept,
every child/.append style={concept color=blue!70},
level distance=8cm,
% minimum size=1.0cm
},
level 3/.style={%opacity=0,
% nodes=concept,
every child/.append style={concept color=blue!50},
level distance=12cm,
% minimum size=1.0cm,
},
level 4/.style={%opacity=0,
% nodes=concept,
every child/.append style={concept color=blue!30},
level distance=14cm,
% minimum size=1.0cm,text width=1.0cm
}
level 5/.style={%opacity=0,
nodes=concept,
% every child/.append style={concept color=white},
level distance=16cm,
% minimum size=1.0cm,text width=1.0cm
}
]
\node [root concept]{}
child foreach \A in {1,2,3,4}{
node[] {\A}
child foreach \B in {1,2,3}{
node[] { \A-\B}
child foreach \C in {1,2,3}{
node { \A-\B-\C}
child[clockwise from=0,sibling angle=10] foreach \D in {1,2}{
node {\A-\B-\C-\D}
child[clockwise from=0,sibling angle=10] foreach \E in {1,2}{
node {\footnotesize \A-\B-\C-\D-\E}
}
}
}
}
};
\end{scope}
\end{tikzpicture}
\end{document}