1

EDIT: Answer found as I was about to submit. This post discusses invisible edges: Graphviz top to bottom AND left to right

I'm currently using the python package "diagrams" to build out a process diagram for my project. Unfortunately, it causes some ugly display due to being all direction Left-to-Right or Top-to-Bottom (with no ability to mix the two, to my knowledge).

Here is a snippet of my diagram's code:

from diagrams import Diagram, Cluster

from diagrams.generic.database import SQL
from diagrams.generic.place import Datacenter
from diagrams.generic.compute import Rack
from diagrams.generic.network import Subnet

from diagrams.aws.general import User


with Diagram('Sample', show=False, outformat='png', direction='LR'):
    database_1 = SQL('Database 1')

    database_2 = SQL('Database 2')

    database_3 = SQL('Database 3')

    server = Datacenter('Datacenter')

    human = User('Human Reviewer')

    with Cluster('Additional items to group separately', direction='TB'):
        process = Subnet('Connection')
        compute = Rack('Compute')
        compute_other = Rack('Compute Other')

    with Cluster('Files to group together'):
        database_4 = SQL('Database 4')
        database_5 = SQL('Database 5')
        database_6 = SQL('Database 6')
    [database_4, database_5, database_6] >> compute

    database_1 >> server
    database_2 >> server
    database_3 >> server

    server >> process >> compute >> compute_other >> human

It returns image_current

But the desired image would be one in which the cluster 'Files to group together' would be spread horizontally to make the diagram more compact. See this figure for the desired output. enter image description here

Is there a way to align the cluster 'Files to group together' horizontally while still having the rest of the diagram flow left-to-right? I was thinking that I would just have to create invisible edges between the items in the cluster, but I can't seem to find an option in graphviz to set an edge to invisible (and it doesn't seem like there are unique options to diagrams that aren't in graphviz).

NOTE: I tried Edge(color=None), but you can still see an arrow, and there is no flow from db4 to db5 to db6 so the Edge was merely an attempt at forcing an alignment

Is there a better package to use for building these diagrams?

Thanks!

kjsfld
  • 141
  • 1
  • 2
  • 9

1 Answers1

0

Couldn't find a similar post when searching, but the AI gods read my post and pointed to this post as the top suggestion: Graphviz top to bottom AND left to right

In that post, the users mention a graphviz option of Edge(style='invis'). I implemented that instead of my attempt at Edge(color=None) and that worked as intended.

kjsfld
  • 141
  • 1
  • 2
  • 9