# Stupid Dot tricks

**URL:** https://forum.graphviz.org/t/stupid-dot-tricks/31
**Category:** Show and Tell
**Created:** [April 10, 2020, 7:03pm UTC](https://forum.graphviz.org/t/stupid-dot-tricks/31 "2020-04-10T19:03:29Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![steveroush](https://avatars.discourse-cdn.com/v4/letter/s/a9adbd/32.png) [@steveroush](https://forum.graphviz.org/u/steveroush)
#### Post date: [April 10, 2020, 7:03pm UTC](https://forum.graphviz.org/t/stupid-dot-tricks/31/1 "2020-04-10T19:03:29Z")

</div>

Experimenting with stylized diagrams, I created a **gvpr** program that would post process an enhanced dot program, adding **row,**  **column** , and **cellAdjust** (the last tweaks the position within the cell).  
I use **dot** to establish all the standard attributes, then my **gvpr** program to reposition all the nodes, based on the new attributes, then **neato -n** to route edges and produce the output.  
 ![Dot](https://global.discourse-cdn.com/graphviz/original/1X/6e1bd72df75f400c1548f62dbeda45e1e7717c50.png) ![rowcol1](https://global.discourse-cdn.com/graphviz/original/1X/a71e4b85b461d5db9f01818297f12a8f4399a556.png)

 ![rowcol2](https://global.discourse-cdn.com/graphviz/original/1X/bbff49f18d0e8edeb5c600b6e003d9ed7d2bb924.png) ![rowcol4](https://global.discourse-cdn.com/graphviz/original/1X/463b7750f949672680a003eca5dad586cd157b35.png)

```
digraph rc {
  graph[nodesep=.5]

  node [style=filled fillcolor=white]
  {
    node [row=1]
    a1 [col=1]
    a2 [col=2]
    a3 [col=3]
    a5 [col=5 fillcolor=orange]
    a6 [col=6 fillcolor=red]
  }
  {
    node [row=2]
    b1 [col=1]
    b4 [col=4]
    b5 [col=5]   
  }
  {
    node [row=3]
    c1 [col=1]
    c2 [col=2]
  }
  {
    node [row=4]
    d4 [col=4 fillcolor=yellow]
    d5 [col=5]   
  }
}

digraph circles {
  graph[nodesep=.5]

  {
    node [row=2 shape=circle style=filled]
    // sequence matters
    large [col=2 label="" width=1.5 fillcolor=red]
    medium [col=2 label="" width=1 fillcolor=green]
    small [col=2 label="ok" width=.5 fillcolor=blue fontcolor=white]

    x1 [row=4 col=4 fillcolor=orange]
    x2 [row=4 col=7 fillcolor=lightblue]
    x3 [row=3 col=1 fillcolor=purple]
  } 

large->x1
medium->x2
small->x3
}

digraph circles {
  graph[nodesep=.5]

    node [row=3 shape=circle style=filled]
    // sequence matters
    large [col=3 label="" width=1.5 fillcolor=red]
    medium [col=3 label="" width=1 fillcolor=green]
    small [col=3 label="" width=.5 fillcolor=blue]
    t1 [col=3 label="" width=.3 fillcolor=orange cellAdjust=n]
    t2 [col=3 label="" width=.3 fillcolor=purple cellAdjust=e]
    t3 [col=3 label="" width=.3 fillcolor=pink cellAdjust=sw]
    t4 [col=3 label="" width=.3 fillcolor=yellow cellAdjust=se]

    node [row=3 shape=square style=filled]
    // sequence matters
    large2 [col=5 label="" width=1.5 fillcolor=red]
    node [row=3 shape=star style=filled]
    medium2 [col=5 label="" width=1 fillcolor=green]
    node [row=3 shape=circle style=filled]
    small2 [col=5 label="" width=.5 fillcolor=blue]
    t12 [col=5 label="" width=.3 fillcolor=orange cellAdjust=n]
    t22 [col=5 label="" width=.3 fillcolor=purple cellAdjust=e]
    t32 [col=5 label="" width=.3 fillcolor=pink cellAdjust=sw]
    t42 [col=5 label="" width=.3 fillcolor=yellow cellAdjust=se]

    node [row=3 shape=square style=filled]
    // sequence matters
    large3 [col=7 label="" width=1.5 fillcolor=red]
    node [row=3 shape=star style=filled]
    medium3 [col=7 label="" width=1 fillcolor=green]
    node [row=3 shape=circle style=filled]
    small3 [col=7 label="" width=.5 fillcolor=blue]
    t13 [col=7 label="" width=.3 fillcolor=orange cellAdjust=n]
    node [row=3 shape=circle style=filled]
    t23 [col=7 label="" width=.3 fillcolor=purple cellAdjust=e]
    node [row=3 shape=triangle style=filled]
    t33 [col=7 label="" width=.3 fillcolor=pink cellAdjust=sw]
    node [row=3 shape=octagon style=filled]
    t43 [col=7 label="" width=.3 fillcolor=yellow cellAdjust=se]
}
```

---

<div class="post-metadata">

### Author: ![magjac](https://sea2.discourse-cdn.com/graphviz/user_avatar/forum.graphviz.org/magjac/32/16_2.png) [@magjac](https://forum.graphviz.org/u/magjac)
#### Post date: [April 11, 2020, 10:13am UTC](https://forum.graphviz.org/t/stupid-dot-tricks/31/2 "2020-04-11T10:13:02Z")

</div>

Thanks for the contribution @steveroush and welcome to the forum 😃.

I haven’t used **gvpr** myself. What does the **gvpr** program that creates this look like?

---

<div class="post-metadata">

### Author: ![steveroush](https://avatars.discourse-cdn.com/v4/letter/s/a9adbd/32.png) [@steveroush](https://forum.graphviz.org/u/steveroush)
#### Post date: [April 14, 2020, 6:54pm UTC](https://forum.graphviz.org/t/stupid-dot-tricks/31/4 "2020-04-14T18:54:25Z")

</div>

That program is a work-in-progress (currently broken) (feature creep).  
If you are interested in gvpr programs in general, you can find them here (maybe) in a Linux install: **/usr/share/graphviz/gvpr/** or here if you built your own from git: **…/cmd/gvpr/lib/**  
Here is a little program that counts nodes, edges and the number of characters in the node and edge labels:

```
BEGIN {
  int nodeCnt=0, edgeCnt=0, nodeLabelCharCnt=0, edgeLabelCharCnt=0;
}
N {
  nodeCnt++;
  nodeLabelCharCnt+=length($.label);
}
E {
  edgeCnt++;
  edgeLabelCharCnt+=length($.label);
}
//////////////////////////////////////////////////////////
END_G{
   print ("Total nodes: ", nodeCnt);
   print ("Total edges: ", edgeCnt);
   print ("Total node label character count: ", nodeLabelCharCnt);
   print ("Total edge label character count: ", edgeLabelCharCnt);
}
```
