Hi there,
I am attempting to graph the following:
digraph ERD {
graph [ rankdir = "LR" ];
ranksep=1;
"DEPARTMENT" [ label="<DEPARTMENT> DEPARTMENT|<PK_DEPARTMENT>deptcode \l | <F_DEPARTMENT> self* \ldeptcode \ldeptname \l " shape = "record", style = "rounded" ];
"COURSE" [ label="<COURSE> COURSE|<PK_COURSE>cnum \l | <F_COURSE> self* \lcnum \lcname \ldepartment* \l " shape = "record", style = "rounded" ];
"PROFESSOR" [ label="<PROFESSOR> PROFESSOR|<PK_PROFESSOR>pnum \l | <F_PROFESSOR> self* \lpnum \lpname \loffice \ldepartment \l " shape = "record", style = "rounded" ];
"CLASS" [ label="<CLASS> CLASS|<PK_CLASS>term \l | <F_CLASS> self* \lcourse* \lterm \lsection \lprofessor* \l " shape = "record", style = "rounded" ];
"ENROLLMENT" [ label="<ENROLLMENT> ENROLLMENT|<PK_ENROLLMENT> | <F_ENROLLMENT> self* \lstudent* \lclass* \l " shape = "record", style = "rounded" ];
"SCHEDULE" [ label="<SCHEDULE> SCHEDULE|<PK_SCHEDULE>time \l | <F_SCHEDULE> self* \lclass* \lday \ltime \lroom \l " shape = "record", style = "rounded" ];
"MARK" [ label="<MARK> MARK|<PK_MARK>grade \l | <F_MARK> self* \lenrollment* \lgrade \l " shape = "record", style = "rounded" ];
"STUDENT" [ label="<STUDENT> STUDENT|<PK_STUDENT>snum \l | <F_STUDENT> self* \lsnum \lsname \lyear \l " shape = "record", style = "rounded" ];
"COURSE":"F_COURSE"->"DEPARTMENT":"PK_DEPARTMENT" [arrowhead = normal] [label="generic label"];
"PROFESSOR":"F_PROFESSOR"->"DEPARTMENT":"PK_DEPARTMENT" [arrowhead = normal] [label="generic label"];
"CLASS":"F_CLASS"->"COURSE":"PK_COURSE" [arrowhead = normal] [label="generic label"];
"ENROLLMENT":"F_ENROLLMENT"->"CLASS":"PK_CLASS" [arrowhead = normal] [label="generic label"];
"SCHEDULE":"F_SCHEDULE"->"CLASS":"PK_CLASS" [arrowhead = normal] [label="generic label"];
"MARK":"F_MARK"->"ENROLLMENT":"PK_ENROLLMENT" [arrowhead = normal] [label="generic label"];
}
However, the dot engine places the nodes such that there is an excessive amount of whitespace in the graph. It ends up looking like this:
For example, the PROFESSOR table could have easily been placed above the COURSE table to save on space. A similar optimization could have been made with the SCHEDULE table. Additionally, the DEPARTMENT table could have been placed on the left of COURSE and PROFESSOR, rather than the right.
From reading about this on the internet, I came across possibly setting the rankdir. However, I need it to be LR because otherwise the nodes themselves are oriented sideways.
Is there any way to allow the arrows to go both directions (not just from left to right, or vice versa?) to save on space? Or some other attributes I could specify to minimize the amount of unnecessary whitespace my graph has? I don’t want to make the nodes, font, or arrow lengths smaller though.
Thank you!