Hi all,
I’m trying to fit a “mirrored” graph side by side.
this works when the arrow direction is going to the same side like
the problem happens when the middle node shifts. the other half then goes to the side
i want the graph to keep LR ranking even though the arrow direction is reversed
Please provide your input.
oh sorry
1st
strict digraph {
rankdir="LR"
splines=spline
d -> f
l -> n
d -> e
p -> w
q -> w
b -> f
p -> v
q -> v
f -> l
c -> g
s -> v
l -> m
j -> m
a -> f
i -> m
r -> v
j -> n
r -> u
i -> n
s -> u
r -> w
t -> u
e -> i
c -> e
c -> f
k -> m
b -> g
o -> p
e -> j
o -> q
f -> j
o -> t
f -> h
e -> h
h -> n
e -> l
f -> k
t -> w
o -> r
m -> o
p -> u
o -> s
d -> g
n -> o
g -> h
g -> j
k -> n
s -> w
f -> i
t -> v
e -> k
a -> e
b -> e
h -> m
}
2nd
strict digraph {
rankdir="LR"
splines=spline
d -> f
r -> o
l -> n
u -> t
d -> e
b -> f
w -> t
f -> l
c -> g
l -> m
w -> r
j -> m
a -> f
v -> r
i -> m
v -> p
j -> n
w -> s
i -> n
w -> q
w -> p
e -> i
c -> e
c -> f
k -> m
b -> g
v -> s
e -> j
u -> r
p -> o
f -> j
f -> h
e -> h
h -> n
u -> s
q -> o
e -> l
o -> n
t -> o
f -> k
u -> p
d -> g
o -> m
g -> j
k -> n
g -> h
s -> o
f -> i
e -> k
v -> t
a -> e
b -> e
v -> q
h -> m
}
Unfortunately, you got caught by how ranks work. Your ranks flow left-to-right, so dot positioned your node accordingly. And only one rankdir per graph. (Yes, it would be nice apply rankdir at a cluster-level - [Dot] Allow different rankdir for subgraph cluster (#887) · Issues · graphviz / graphviz · GitLab).
So, a fix is to swap head & tail of the “mirrored” edges and then add dir=back attribute (dir | Graphviz) to those edges to make it appear as you want.
Here is the gawk script used to modify the input:
gawk '$1~/^[o-z]$/{t=$1;$1=$3;$3=t " [dir=back]"}{print}'
Here is the result:
strict digraph {
rankdir="LR"
splines=spline
d -> f
o -> r [dir=back]
l -> n
t -> u [dir=back]
d -> e
b -> f
t -> w [dir=back]
f -> l
c -> g
l -> m
r -> w [dir=back]
j -> m
a -> f
r -> v [dir=back]
i -> m
p -> v [dir=back]
j -> n
s -> w [dir=back]
i -> n
q -> w [dir=back]
p -> w [dir=back]
e -> i
c -> e
c -> f
k -> m
b -> g
s -> v [dir=back]
e -> j
r -> u [dir=back]
o -> p [dir=back]
f -> j
f -> h
e -> h
h -> n
s -> u [dir=back]
o -> q [dir=back]
e -> l
n -> o [dir=back]
o -> t [dir=back]
f -> k
p -> u [dir=back]
d -> g
m -> o [dir=back]
g -> j
k -> n
g -> h
o -> s [dir=back]
f -> i
e -> k
t -> v [dir=back]
a -> e
b -> e
q -> v [dir=back]
h -> m
}
Giving:
1 Like
omg!! that was awesome!!
thank you so much for your help!