如何在节点上绘制 Home 符号?

如何在节点上绘制 Home 符号?
\begin{tikzpicture}[->,level 1/.style={sibling distance=3cm},auto]
\tikzstyle{vertex}=[draw,circle,minimum size=0.8cm]
\tikzstyle{selected vertex}=[]
\tikzstyle{edge}=[->,node distance=3cm,thick,auto]
\node[vertex](v1)at(0,0){1};
\node[vertex](v2)at(3,-0.5){3};
\node[vertex](v3)at(3,2){2};
\node[vertex](v4)at(2,-1.5){4};
\node[vertex](v5)at(5,2){5};
\node[vertex](v6)at(6,0.5){6};
\node[vertex](v7)at(8,-1.5){7};
\node[vertex](v8)at(8,2){8};
\node[vertex](v9)at(11,2){9};

\draw[edge](v1)--(v2);
\draw[edge](v1)--(v3);
\draw[edge](v1)--(v4);
\draw[edge](v3)--(v5);
\draw[edge](v2)--(v6);
\draw[edge](v2)--(v7);
\draw[edge](v4)--(v7);
\draw[edge](v6)--(v8);

\path[midway,above]node{}(v1)edge node{B}(v2);
\path[midway,above]node{}(v1)edge node{A}(v3);
\path[midway,below]node{}(v1)edge node{C}(v4);
\path[midway,above]node{}(v3)edge node{D}(v5);
\path[midway,above]node{}(v2)edge node{E}(v6);
\path[midway,above]node{}(v2)edge node{F}(v7);
\path[midway,below]node{}(v4)edge node{G}(v7);
\path[midway,above]node{}(v6)edge node{I}(v8);
\path[midway,above]node{}(v5)edge node{H}(v8);
\path[midway,above]node{}(v8)edge node{J}(v9);
\path[midway,above]node{}(v7)edge node{K}(v9);
\end{tikzpicture}

在此处输入图片描述

我已经画好了上面的图,,,,但我想画下面这样的图,,,我希望得到帮助,在节点上画出那些像主页一样的符号,以及特定节点之间的双箭头,如下图所示,请指导。

在此处输入图片描述

答案1

这是一个可能的解决方案。house是一个带有上部标签的节点(作为参数传递给 house style)。您可以使用positioning标签将它们放置在周围vertexs

顶点 4 和 7 之间还有双箭头的示例。

\documentclass[tikz,border=2mm]{standalone}
\usetikzlibrary{positioning, arrows.meta}

\begin{document}
\begin{tikzpicture}[
    house/.style={
        draw, minimum width=8mm, minimum height=6mm, 
        label={[name=labelaux, inner sep=1mm, distance=0pt]#1}, 
        append after command={%
            \pgfextra \draw ([xshift=.5\pgflinewidth]\tikzlastnode.north west)--(labelaux.north)
                --([xshift=-.5\pgflinewidth]\tikzlastnode.north east);\endpgfextra
        }
    },
    vertex/.style={draw,circle,minimum size=0.8cm},
    ]

\node[vertex](v1)at(0,0){1};
\node[vertex](v3)at(3,-0.5){3};
\node[vertex](v2)at(3,2){2};
\node[vertex](v4)at(2,-1.5){4};
\node[vertex](v5)at(5,2){5};
\node[vertex](v6)at(6,0.5){6};
\node[vertex](v7)at(8,-1.5){7};
\node[vertex](v8)at(8,2){8};
\node[vertex](v9)at(11,2){9};

\path[->, auto] (v1) edge node {A} (v2)
           edge node {B} (v3)
           edge node {C} (v4)
      (v2) edge node {D} (v5)
       (v3) edge node {E} (v6)
            edge node {F} (v7)
      (v4) edge[double equal sign distance, -Implies] node {G} (v7)
      (v5) edge node {H} (v8)
      (v6) edge node {I} (v8)
      (v7) edge node {K} (v9)
      (v8) edge node {J} (v9);

\node[house=3, left=1mm of v1] {0};
\node[house=4, above right=2mm and 1mm of v2] {9};
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容