# Setup a positionning layout for the subgraphs

**URL:** https://forum.graphviz.org/t/setup-a-positionning-layout-for-the-subgraphs/613
**Category:** Help
**Created:** [April 15, 2021, 2:57pm UTC](https://forum.graphviz.org/t/setup-a-positionning-layout-for-the-subgraphs/613 "2021-04-15T14:57:34Z")
**Posts on this page:** 15
**Page:** 1

<div class="post-metadata">

### Author: ![eiro](https://avatars.discourse-cdn.com/v4/letter/e/67e7ee/32.png) [@eiro](https://forum.graphviz.org/u/eiro)
#### Post date: [April 15, 2021, 2:57pm UTC](https://forum.graphviz.org/t/setup-a-positionning-layout-for-the-subgraphs/613/1 "2021-04-15T14:57:34Z")

</div>

helllo people,

I have this graph with clusters this simplified  
like this (because I wanted to figure out what was wrong):

digraph {  
subgraph cluster\_0 { A1 → A2 → A3 }  
subgraph cluster\_1 { B1 → B2 → B3 }  
subgraph cluster\_2 { C1 → C2 → C3 }  
subgraph cluster\_3 { D1 → D2 → D3 }  
subgraph cluster\_4 { E1 → E2 → E3 }  
{ A1 B1 } → C1 → { D1 E1 }  
}

the generated layout looks like this

AA BB  
AA BB  
AA CC BB  
AA CC DD EE BB  
CC DD EE  
CC DD EE  
DD EE

I’m generally happy about that but this time, I need  
to publish it so I need to rearange things that way:

AA CC DD  
AA CC DD  
CC  
BB CC EE  
BB CC EE

I usually use tikz for those kind of things but I really  
would like to level up my dot skills so I can keep using  
graphviz. It turns out I find it hard because I don’t understand how  
things comes all together. I wrote things and try to guess what should  
be drawn but I fail.

for exemple: I wrote this

digraph {  
rankdir=LR  
rank=same  
subgraph cluster\_0 { A1 → A2 → A3 }  
subgraph cluster\_1 { B1 → B2 → B3 }  
subgraph cluster\_2 { C1 → C2 → C3 }  
subgraph cluster\_3 { D1 → D2 → D3 }  
subgraph cluster\_4 { E1 → E2 → E3 }  
{ A1 B1 } → C1 → { D1 E1 }  
}

And now some nodes are out of their subgraphs. This  
really confuse me as I always saw subgraphs as “scopes”  
but maybe they are not.

I started to push graphs in subgraphs to change rankdirs  
but it didn’t work. also because I think subgraphs as  
scopes with a local context.

I probably missed the good example or tutorial to achieve  
this. Any link or help is welcome.

thanks for reading,  
marc

---

<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 15, 2021, 3:57pm UTC](https://forum.graphviz.org/t/setup-a-positionning-layout-for-the-subgraphs/613/2 "2021-04-15T15:57:47Z")

</div>

[your code includes non-ascii characters (look at the arrows). if you use the “preformatted text” option to include code, you will prevent that]

- Here is a good tutorial for **dot** [https://www.graphviz.org/pdf/dotguide.pdf](https://www.graphviz.org/pdf/dotguide.pdf)
- The **rank=same** is causing the nodes to leave their clusters. You are misusing the attribute, but it shouldn’t do wacky things. **rank=same** applies to individual subgraphs, like this `{rank=same A1 -> A2 -> A3}`
- _To me_ subgraphs and clusters are very different things
  - Clusters are more like mini-graphs unto themselves
  - Subgraphs are more like sets of nodes with common attributes that may (or may not) be positioned together

- FYI, positioning nodes where you want (as opposed to where **dot** wants) can be challenging, but often you can do it. Positioning clusters where you want is often ~ impossible. I usually use the **gvpr** program to post-process a **dot** output to position clusters.

I find your _AA, BB, …_ pseudo-sketches confusing. Could you provide a pencil sketch of you want to achieve?

---

<div class="post-metadata">

### Author: ![eiro](https://avatars.discourse-cdn.com/v4/letter/e/67e7ee/32.png) [@eiro](https://forum.graphviz.org/u/eiro)
#### Post date: [April 16, 2021, 9:28am UTC](https://forum.graphviz.org/t/setup-a-positionning-layout-for-the-subgraphs/613/3 "2021-04-16T09:28:42Z")

</div>

> - Here is a good tutorial for **dot** [https://www.graphviz.org/pdf/dotguide.pdf](https://www.graphviz.org/pdf/dotguide.pdf)

I knew it and read it long time ago but as far as i remember, it doesn’t  
help when it comes to positionning. i’ll give it a try again. thanks for  
the reminder.

> - The **rank=same** is causing the nodes to leave their clusters. You  
> are misusing the attribute, but it shouldn’t do wacky things.  
> **rank=same** applies to individual subgraphs, like this `{rank=same A1 -> A2 -> A3}`

indeed. i made some progress thanks to your informations.

> - _To me_ subgraphs and clusters are very different things
> - Clusters are more like mini-graphs unto themselves
> - Subgraphs are more like sets of nodes with common attributes that may (or may not) be positioned together

you don’t need a subgraph for common attributes : just a block.

```
{ // dummies
    node [width=0,height=0,label=""]
    level1
    level1
    level1
}

```

> - FYI, positioning nodes where you want (as opposed to where **dot**  
> wants) can be challenging, but often you can do it. Positioning  
> clusters where you want is often ~ impossible. I usually use the  
> **gvpr** program to post-process a **dot** output to position  
> clusters.

i don’t even know this tool. i have to see that.

> I find your _AA, BB, …_ pseudo-sketches confusing.

that’s because the web page ruined my indentation! this is very sad the  
mailing list don’t exist anymore :(.

> Could you provide a pencil sketch of you want to achieve?

Using an image for such a simple thing is anoying to me. let’s  
see if this weird tool know markdown first:

```auto
    AA CC DD
    AA CC DD
       CC
    BB CC EE
    BB CC EE

```

thanks for your help  
regards  
marc

---

<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 16, 2021, 4:22pm UTC](https://forum.graphviz.org/t/setup-a-positionning-layout-for-the-subgraphs/613/4 "2021-04-16T16:22:41Z")

</div>

Or, you can do the node layout yourself & let Graphviz (neato) do the edges, like so:

```
digraph z {
  // build by hand
  // use "neato -n -T..." see http://www.graphviz.org/faq/#FaqDotWithNodeCoords
  // remember, all coordinates are in points (72/inch)
  a [pos="100,100"]
  b [pos="200,100"]
  c [pos="200,200"]
  subgraph clusterX {
    graph [bb="50,350,480,580"]
    d [pos="100,500"]
    e [pos="400,400"]
  }
  f [pos="100,200"]
  a->c
  b->f
  d->f
}
```

---

<div class="post-metadata">

### Author: ![smattr](https://sea2.discourse-cdn.com/graphviz/user_avatar/forum.graphviz.org/smattr/32/85_2.png) [@smattr](https://forum.graphviz.org/u/smattr)
#### Post date: [April 19, 2021, 4:03am UTC](https://forum.graphviz.org/t/setup-a-positionning-layout-for-the-subgraphs/613/5 "2021-04-19T04:03:57Z")

</div>

> [@eiro](#):
>
> that’s because the web page ruined my indentation! this is very sad the  
> mailing list don’t exist anymore :(.
> 
> …
> 
> Using an image for such a simple thing is anoying to me. let’s  
> see if this weird tool know markdown first:

“This weird tool” being the forum? The forum is actually pretty clever and understands Markdown, complete with Graphviz syntax highlighting, inline image rendering, and niceties like turning the quotes in my prior sentence into smart quotes. Improvement suggestions are welcome, but IMHO it is already vastly superior to a mailing list.

---

<div class="post-metadata">

### Author: ![eiro](https://avatars.discourse-cdn.com/v4/letter/e/67e7ee/32.png) [@eiro](https://forum.graphviz.org/u/eiro)
#### Post date: [April 19, 2021, 7:58am UTC](https://forum.graphviz.org/t/setup-a-positionning-layout-for-the-subgraphs/613/6 "2021-04-19T07:58:51Z")

</div>

hello Steve,

> ```
> digraph z {
> // build by hand
> // use "neato -n -T..." see http://www.graphviz.org/faq/#FaqDotWithNodeCoords
> // remember, all coordinates are in points (72/inch)
> 
> ```

At this point, Tikz will be more convenient so I’ll fall back to it for  
this time. However, I explored every options you proposed and learned a  
lot. thank you!

regards  
marc

---

<div class="post-metadata">

### Author: ![eiro](https://avatars.discourse-cdn.com/v4/letter/e/67e7ee/32.png) [@eiro](https://forum.graphviz.org/u/eiro)
#### Post date: [April 19, 2021, 1:19pm UTC](https://forum.graphviz.org/t/setup-a-positionning-layout-for-the-subgraphs/613/7 "2021-04-19T13:19:49Z")

</div>

hello Matthew,

> “This weird tool” being the forum?

If you see discourse as a web forum: this is probably a good tool (i  
don’t know: i don’t use web fora). the thing is they claim to have a  
“mailing list mode” which is probably written by people who don’t have  
that much experience of mailing lists.

weird wasn’t the good term to describe what i feel but i’m sad they took  
email users as second class citizen because it would be really nice to  
finally have a tool to respect user choices in a fair way.

> The forum is actually pretty clever and understands Markdown

that’s the point i missed in first place. indent with more spaces should  
have done the job.

> complete with Graphviz syntax highlighting,  
> inline image rendering

with no concent or possible configuration from the user. those are  
both bad idea because of visual impairment and ecological low tech  
users but completely normal in the web world. your vision of “superior”  
is biased by your digital culture.

> and niceties like turning the quotes in my prior sentence into smart quotes.

Nothing new since mailing lists but using a web app will force me  
to renounce to all the power and freedom i have using my local tools:  
mailing lists send emails which are just emails among others so i can  
use the same workflow and tools to choose how/when i send,  
recieve, annote, archive (with possible multiple taxinomies and mixed  
with other contents), index, delete … i have the same interface for  
everything and it’s tuned the way i want it to be (and it’s so  
convenient i didn’t change that much since the last millenium. i just  
added mu ([GitHub - djcb/mu: maildir indexer/searcher + emacs mail client + guile bindings](https://github.com/djcb/mu/)) and a menu made with fzf  
([GitHub - junegunn/fzf: 🌸 A command-line fuzzy finder](https://github.com/junegunn/fzf/)) some years ago.

also: i use vim for 25 years now so i’m really demanding on what an  
editor can do for me so you can imagine how painful it is to use the  
the one provided by the web interface.

> Improvement suggestions are welcome,  
> but IMHO it is already vastly superior to a mailing list.

I really appreciate your offer! thank you very much. But do you realize  
it probably means to hack the code of discourse itself to make it email  
friendly? if so and if you’re ready for that: it would be awesome and i  
can probably share a lot of ideas with you.

regards.  
marc

---

<div class="post-metadata">

### Author: ![smattr](https://sea2.discourse-cdn.com/graphviz/user_avatar/forum.graphviz.org/smattr/32/85_2.png) [@smattr](https://forum.graphviz.org/u/smattr)
#### Post date: [April 19, 2021, 3:08pm UTC](https://forum.graphviz.org/t/setup-a-positionning-layout-for-the-subgraphs/613/8 "2021-04-19T15:08:19Z")

</div>

> [@eiro](#):
>
> the thing is they claim to have a  
> “mailing list mode” which is probably written by people who don’t have  
> that much experience of mailing lists.

Fair enough. FWIW we’re also happy for you to file issues on Gitlab which you can then interact with via email. Though obviously this is suboptimal too.

> [@eiro](#):
>
> with no concent or possible configuration from the user. those are  
> both bad idea because of visual impairment and ecological low tech  
> users but completely normal in the web world. your vision of “superior”  
> is biased by your digital culture.

By “user” I guess you mean the reader of a post here. The _writer_ of a post has full control over their content. I may be incorrect about this, but I’m not sure how the forum degrades accessibility. Graphviz is inherently a program for producing images, so users will want to post images. On a mailing list they would attach them, on the forum they post them inline. Whether they choose accessible colors, add alt text, etc, is entirely within their control. The forum is machine readable (it’s relatively clean HTML after all), so I would assume tools like screen readers can handle it. If there’s an improvement you think could be made, please let us know.

> [@eiro](#):
>
> using a web app will force me to renounce to all the power and freedom i have using my local tools

I don’t really disagree with you. I’m a Vim user myself and was used to driving everything via my mail client. Some of my machines don’t have a GUI installed. But it seems an interactive forum is what users expect these days. I haven’t tried the mailing list mode, so it’s possible this regains the experience you’re after.

> [@eiro](#):
>
> But do you realize  
> it probably means to hack the code of discourse itself to make it email  
> friendly? if so and if you’re ready for that

Not so much. I’m happy to tweak config settings if it will help users, but not hacking on Discourse itself. If you look at the Graphviz issue tracker, you’ll note we’re already deep underwater trying to deal with the existing workload. If you want to propose improvements to Discourse itself, their developers may be receptive.

---

<div class="post-metadata">

### Author: ![eiro](https://avatars.discourse-cdn.com/v4/letter/e/67e7ee/32.png) [@eiro](https://forum.graphviz.org/u/eiro)
#### Post date: [April 20, 2021, 11:48am UTC](https://forum.graphviz.org/t/setup-a-positionning-layout-for-the-subgraphs/613/9 "2021-04-20T11:48:57Z")

</div>

hello Matthew,

I wrote (IMPROVE?) in the rest of the mail when there is a way to make  
discourse more “civilized” (from their own words).

> > [@eiro](#):
> >
> > But do you realize  
> > it probably means to hack the code of discourse itself to make it email  
> > friendly? if so and if you’re ready for that
> 
> Not so much. I’m happy to tweak config settings if it will help users,  
> but not hacking on Discourse itself.

that’s why i was not optimistic even if i really enjoy your reply but  
let’s take a look (maybe i underestimate the level of configuration of  
this tool).

(IMPROVE?) First: this should be a new topic (based on the title) refering to the  
old one (based on In-Reply-To). let’s see how discourse behave.

> > [@eiro](#):
> >
> > the thing is they claim to have a  
> > “mailing list mode” which is probably written by people who don’t have  
> > that much experience of mailing lists.
> 
> Fair enough. FWIW we’re also happy for you to file issues on Gitlab which you can then interact with via email. Though obviously this is suboptimal too.

(IMPROVE?) AFAIK, none of them (discoursemail and Gitlab) gives us the opportunity  
to start a thread from an MUA: you need to choose between web or api  
client.

> > [@eiro](#):
> >
> > with no concent or possible configuration from the user. those are  
> > both bad idea because of visual impairment and ecological low tech  
> > users but completely normal in the web world. your vision of “superior”  
> > is biased by your digital culture.
> 
> By “user” I guess you mean the reader of a post here.

correct 🙂

> The _writer_ of a post has full control over their content.

(IMPROVE?) well … what if i want to send plain text? it would be nice  
to check if the mime type of the body is text/plain or text/markdown or  
better: if a mime alternate is present.

The forum is machine readable (it’s relatively clean HTML after all), so  
I would assume tools like screen readers can handle it. If there’s an  
improvement you think could be made, please let us know.

as i said: i’m not reading the html part so i don’t know how it renders.

> > [@eiro](#):
> >
> > using a web app will force me to  
> > renounce to all the power and freedom i have using my local tools

> I don’t really disagree with you. I’m a Vim user myself and was used  
> to driving everything via my mail client. Some of my machines don’t  
> have a GUI installed. But it seems an interactive forum is what users  
> expect these days. I haven’t tried the mailing list mode, so it’s  
> possible this regains the experience you’re after.

I’m not against an fora at all but i know by experience it’s such a pain  
to use them that i lost contact at some point so it would be if  
discourse could become a bridge between the web people and the other  
ones (even if it requires some tuning/discipline from client side): i  
would be happy to provide any helpers for mutt or mblaze.

regards  
marc

---

<div class="post-metadata">

### Author: ![scnorth](https://sea2.discourse-cdn.com/graphviz/user_avatar/forum.graphviz.org/scnorth/32/89_2.png) [@scnorth](https://forum.graphviz.org/u/scnorth)
#### Post date: [April 20, 2021, 2:27pm UTC](https://forum.graphviz.org/t/setup-a-positionning-layout-for-the-subgraphs/613/10 "2021-04-20T14:27:08Z")

</div>

That there are, possibly, 100x more readers of ‘How to install on Windows’ than anything else here, speaks volumes.

---

<div class="post-metadata">

### Author: ![eiro](https://avatars.discourse-cdn.com/v4/letter/e/67e7ee/32.png) [@eiro](https://forum.graphviz.org/u/eiro)
#### Post date: [April 20, 2021, 2:55pm UTC](https://forum.graphviz.org/t/setup-a-positionning-layout-for-the-subgraphs/613/11 "2021-04-20T14:55:37Z")

</div>

> That there are, possibly, 100x more readers of ‘How to install on Windows’ than anything else here, speaks volumes.

so this isn’t worth improving discourse?

---

<div class="post-metadata">

### Author: ![smattr](https://sea2.discourse-cdn.com/graphviz/user_avatar/forum.graphviz.org/smattr/32/85_2.png) [@smattr](https://forum.graphviz.org/u/smattr)
#### Post date: [April 20, 2021, 3:05pm UTC](https://forum.graphviz.org/t/setup-a-positionning-layout-for-the-subgraphs/613/12 "2021-04-20T15:05:56Z")

</div>

I believe Stephen’s point was that, by the numbers, the forum has been hugely more helpful to users than the mailing list.

(I have opinions about why we keep fielding questions about how to install Graphviz, but that is a topic for another day…)

> [@eiro](#):
>
> this should be a new topic (based on the title) refering to the old one (based on In-Reply-To)

Well we discovered one concrete area where Discourse falls down. However, I suspect this choice is deliberate by the developers to deal with mail clients and/or environments that mangle email subjects and/or headers.

> [@eiro](#):
>
> none of them (discoursemail and Gitlab) gives us the opportunity to start a thread from an MUA

AFAIK you are correct.

> [@eiro](#):
>
> what if i want to send plain text?

I suspect such a thing is not possible. Same for opting to receive plain text mail.

> [@eiro](#):
>
> i know by experience it’s such a pain to use them that i lost contact at some point

Not sure what to say, other than sympathizing. I too have given up interacting with certain communities that required yet another username and password and yet another website for me to monitor.

---

<div class="post-metadata">

### Author: ![scnorth](https://sea2.discourse-cdn.com/graphviz/user_avatar/forum.graphviz.org/scnorth/32/89_2.png) [@scnorth](https://forum.graphviz.org/u/scnorth)
#### Post date: [April 20, 2021, 3:09pm UTC](https://forum.graphviz.org/t/setup-a-positionning-layout-for-the-subgraphs/613/13 "2021-04-20T15:09:06Z")

</div>

Though I can’t even improve myself, or my own software, I’m not consciously standing in the way of any improvements to Discourse.

---

<div class="post-metadata">

### Author: ![eiro](https://avatars.discourse-cdn.com/v4/letter/e/67e7ee/32.png) [@eiro](https://forum.graphviz.org/u/eiro)
#### Post date: [April 20, 2021, 3:35pm UTC](https://forum.graphviz.org/t/setup-a-positionning-layout-for-the-subgraphs/613/14 "2021-04-20T15:35:23Z")

</div>

> I believe Stephen’s point was that, by the numbers, the forum has been  
> hugely more helpful to users than the mailing list.

that’s what i said since my very first reply i wrote to you: as sad as  
it is (because of the lack of diversity and freedom i already mention),  
having a web forum completely makes sense nowadays.

> > [@eiro](#):
> >
> > this should be a new topic (based on the title) refering to the old one (based on In-Reply-To)

> Well we discovered one concrete area where Discourse falls down.  
> However, I suspect this choice is deliberate by the developers to deal  
> with mail clients and/or environments that mangle email subjects  
> and/or headers.

that’s what i said: they shouldn’t talk about a “mailing list mode”. it  
doesn’t mean this is bad: it means they focus on other goals.

> Not sure what to say, other than sympathizing. I too have given up  
> interacting with certain communities that required yet another  
> username and password and yet another website for me to monitor.

thanks for sympathizing. doesn’t help but feel less lonely 😉

regards  
marc

---

<div class="post-metadata">

### Author: ![eiro](https://avatars.discourse-cdn.com/v4/letter/e/67e7ee/32.png) [@eiro](https://forum.graphviz.org/u/eiro)
#### Post date: [April 20, 2021, 3:45pm UTC](https://forum.graphviz.org/t/setup-a-positionning-layout-for-the-subgraphs/613/15 "2021-04-20T15:45:33Z")

</div>

hello Stephen,

> Though I can’t even improve myself, or my own software, I’m not  
> consciously standing in the way of any improvements to Discourse.

I wouldn’t have asked anything without Matthew inviting me to do so and  
i’m completely aware of the situation you share with many free software  
developpers.

I can even offer to host a mailing list if you want?

regards  
marc
