2

I would love to get to: enter image description here

I try variations on such graph:

digraph G {
    node [shape=circle penwidth=2 fixedsize=true label=""]
    token [shape=point ]
    place [ xlabel="P2" _background="digraph G { e[shape=point ] }"]
}

testable in this online form resulting in:

enter image description here

What shall I do to place a dot (token) inside a circle (place)

DuckQueen
  • 772
  • 10
  • 62
  • 134

2 Answers2

0

Graphviz programs generally don't like intentionally placing nodes on top of other nodes, but allow it under special circumstances - neato -n and neato -n2 allow it (see the FAQ). enter image description here

I added a new attribute (dotme) to this input file:

digraph G {
    node [shape=circle penwidth=2  label=""]
    n1 [ xlabel="P1" dotme=1]
    n2 [ xlabel="P2" ]
    n3 [ xlabel="P3" dotme=1]
  
    n1 -> n2
    n1 -> n3
    n2 -> n3
}

then ran it through this set of Graphviz programs:

dot -Tdot needsadot.gv |gvpr -c -fdotMe.gvpr |neato -n2 -Tpng >needsadot.png

where the gvpr program dotMe.gvpr is here:

BEGIN {

  int nxt=0;

}
N {
  int i;
  string str1, str2;
  node_t n;

  if (hasAttr($, "dotme")){
    if (strcmp($.dotme,"1")==0){
      // create a new node and position it on top of existing node
      str1=sprintf("__dot_%d", ++nxt);
      n=node($G, str1);
      n.pos=$.pos;
      n.shape="point";
    }
  }
}

dotMe.gvpr adds a new node on top of (same pos) every node where dotme==1.
Convoluted, but reusable.

sroush
  • 5,375
  • 2
  • 5
  • 11
  • Wouldn't `n1 [ xlabel="P1" label="."]` do a similar thing, the dot is a bit thin, but maybe there are some possibilities to enlarge it. – albert Jun 28 '20 at 09:38
0

Albert's idea (using unicode symbols) works great (using point size to change the dot size):

digraph G {
    node [shape=circle penwidth=2  label=""]
    n1 [ xlabel="P1" label=<<font point-size="8">&#9899;</font>>]
    n2 [ xlabel="P2" ]
    n3 [ xlabel="P3" label=<<font point-size="6">&#9899;</font>>]
  
    n1 -> n2
    n1 -> n3
    n2 -> n3
}

gives this: enter image description here

sroush
  • 5,375
  • 2
  • 5
  • 11