# Subgraph Rank Alignment (Edited)

**URL:** <https://forum.graphviz.org/t/subgraph-rank-alignment-edited/1604>\
**Category:** Uncategorized\
**Created:** [May 5, 2023, 2:17pm UTC](https://forum.graphviz.org/t/subgraph-rank-alignment-edited/1604 "2023-05-05T14:17:01Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Calvin](https://avatars.discourse-cdn.com/v4/letter/c/f475e1/32.png) [@Calvin](https://forum.graphviz.org/u/Calvin)\
**Post date:** [May 5, 2023, 2:17pm UTC](https://forum.graphviz.org/t/subgraph-rank-alignment-edited/1604/1 "2023-05-05T14:17:01Z")

</div>

I am trying to align subgraph cluster\_A A2 with B3 but when I use

```auto
{rank=same; A2 B3 }

```

The box around the subgraph stops working as I expected. Does anyone know how to solve this?

```auto
digraph {
    graph [compound=true]
    node [shape=rect];
    
    subgraph cluster_A {
        A2 [shape=plaintext]
        A3 [shape=plaintext]
        A2->A3 [style=invis]
        
    }
    A1 -> A2
    
    A3->A4 [ltail=cluster_A]
  
    B1 -> B2
    B2 -> B3
    B3 -> B4
    B4 -> B5
   B5 -> B6
   {rank=same; A1 B1 }
   
   { rank=same; A4 B6 }
}

```

---

<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:** [May 5, 2023, 2:51pm UTC](https://forum.graphviz.org/t/subgraph-rank-alignment-edited/1604/2 "2023-05-05T14:51:42Z")

</div>

setting **rank** across clusters doesn’t work as desired unless you set **newrank=true** ([newrank | Graphviz](https://graphviz.org/docs/attrs/newrank/))

```auto
digraph {
    graph [compound=true newrank=true] // added newrank
    node [shape=rect];
    
    subgraph cluster_A {
        A2 [shape=plaintext]
        A3 [shape=plaintext]
        A2->A3 [style=invis]
    }
    A1 -> A2 // you might add lhead
    
    A3->A4 [ltail=cluster_A]
  
    B1 -> B2
    B2 -> B3
    B3 -> B4
    B4 -> B5
    B5 -> B6
   {rank=same; A1 B1 }
   {rank=same; A4 B6 }
   {rank=same A2 B3}
   {rank=same A3 B4} // optional, keep A3 close to A2
}

```

Giving:

 ![subgraphRank1](https://global.discourse-cdn.com/graphviz/original/2X/4/4bf27305971fca7e5f1e821515d1f3291f4b9440.png)
