【问题标题】:Drawing sorting networks [closed]绘图排序网络[关闭]
【发布时间】:2015-09-02 16:46:15
【问题描述】:

有什么好方法可以画出类似于本文底部的排序网络?非常感谢 python 包或 LaTeX 排版包。

【问题讨论】:

    标签: python drawing latex graph-drawing sorting-network


    【解决方案1】:

    很可能存在一些更具体的 LaTeX 包来绘制这样的网络,但您可以从查看 TikZ 包 (manual) 开始。这就是我(快速)使用 TikZ 复制您问题中两个图像中更简单的一个的方式:

    \documentclass[tikz,border=5mm]{standalone}
    
    \begin{document}
    
    \begin{tikzpicture}
    %\fill [gray!15] (1.5,1.5) -- (2.5,1.5) -- (2.5,2.5) -- (1.5,2.5) -- cycle;
    \foreach \a in {1,...,4}
      \draw[thick] (0,\a) -- ++(5,0);
    \foreach \x in {{1,2},{1,4},{2,1},{2,3},{3,1},{3,2},{3,3},{3,4},{4,2},{4,3}}
      \filldraw (\x) circle (1.5pt);
    \draw[thick] (1,2) -- (1,4);
    \draw[thick] (2,1) -- (2,3);
    \draw[thick] (3,1) -- (3,2);
    \draw[thick] (3,3) -- (3,4);
    \draw[thick] (4,2) -- (4,3);
    \end{tikzpicture}
    
    \end{document}
    

    注释行(以% 开头)将为您提供背景上的浅灰色矩形样本,如您的第一张图片所示。

    【讨论】:

      猜你喜欢
      • 2010-09-09
      • 1970-01-01
      • 2018-06-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-08-03
      • 2011-09-15
      • 2019-04-14
      相关资源
      最近更新 更多