2011-07-19 64 views
6

我首次使用dot + GraphViz來幫助規劃出圖形DB架構。圖形DB架構的最佳點/ GraphViz佈局

當我添加更多節點時,輸出看起來不太理想。特別是語言和國家看起來相當混亂。

我試過一些基本的排名,但一直無法影響它。

我如何獲得更清晰的輸出?

代碼:

digraph ReferenceGraph { 
    nodesep = 2; 
    edge [color=gray50, fontname=Calibri, fontsize=11] 
    node [shape=record, fontname=Calibri, fontsize=11] 

    root [label="Reference Node", color=darkgreen, fontcolor=darkgreen, fontname=Calibri, fontsize=11] 

    sue [label="{{User}|{GivenName=Sue}|{FamilyName=Williams}|{Username=swilliams}|{[email protected]}|{BusinessPhone=02 1234 5678}|{MobilePhone=0414 123 456}|{PasswordSalt=fcd376dc}|{PasswordHash=a8635cfd2930ebc0cc78}|{PreviousPasswordSalt=gggf6dc}|{PreviousPasswordHash=wer435cfd2930ebc0cc78}|{RequirePasswordChangeOnNextLogin=true}|FailedLoginAttempts=0|LastLoginAttemptUtc=21 Jun 2011 16:43:01 UTC|{DateCreatedUtc=20 Jun 2011 15:43:07 UTC}}", color=blue, fontcolor=blue] 
    sue -> root [label="ADMINISTERS"] 

    clint [label="{{Client}|{UniqueId=100}|{GivenName=Clint}|{MiddleNames=ian bill}|{FamilyName=Wood}|{PreferredName=Woods}|{Gender=Male Female Unknown}|{PlaceOfBirthTown}|{PlaceOfBirthState}|{PlaceOfBirthCountry}|{[email protected]}|{LanguageComments}|{InterpreterRequired=true false}|{InterpreterComments}|{Religion=Buddhist}|{LegalOrders=order1}|{DateOfBirth=21 June 1979}|{DateOfBirthCertainty=Confirmed Unconfirmed Estimated}}", color=blue, fontcolor=blue] 
    clint -> acme [label="CLIENT_BELONGS_TO"] 
    clint -> english [label ="SPEAKS"] 

    cat [label="Cat (Client)"] 
    cat -> acme [label="CLIENT_BELONGS_TO"] 
    cat -> english [label ="SPEAKS"] 
    cat -> mandarin [label ="SPEAKS"] 

    acme [label="{{Agency}|{UniqueId=100}|{Key=acme}|{Name=Acme Australia}}", color=blue, fontcolor=blue] 
    root -> acme [label="HOSTS"] 

    john [label="John (User)"] 
    john -> acme [label="USER_BELONGS_TO"] 

    jack [label="Jack (User)"] 
    jack -> acme [label="USER_BELONGS_TO"] 

    centreA [label="{{Centre}|{Name=CentreA}|{BusinessPhone=02 1234 5678}|{Fax=0414 123 456}|{[email protected]}|{Status=Active}}", color=blue, fontcolor=blue] 
    centreA -> acme [label="CENTRE_BELONGS_TO"] 

    centreAStreetAddress [label="{{PhysicalAddress}|{Line 1=Level 1}|{Line 2=11 Sydney Road}|{TownSuburb=Sydney}|{State=NSW}|{Postcode=2000}|{Country=Australia}}", color=blue, fontcolor=blue] 
    centreA -> centreAStreetAddress [label="HAS_STREET_ADDRESS"] 

    centreAPostalAddress [label="PO Box 123 (PhysicalAddress)"] 
    centreA -> centreAPostalAddress [label="HAS_POSTAL_ADDRESS"] 

    clintCurrentAddress [label="{{CurrentAddress}|{Line 1=Level 1}|{Line 2=11 Sydney Road}|{TownSuburb=Sydney}|{State=NSW}|{Postcode=2000}|{Country=Australia}}", color=blue, fontcolor=blue] 
    clint -> clintCurrentAddress [label="HAS_STREET_ADDRESS"] 

    referenceData [label="Reference Data"] 
    root -> referenceData [label="HAS_REFERENCE_DATA"] 

    languagesReferenceData [label="Languages"] 
    referenceData -> languagesReferenceData [label="HAS_LANGUAGES"] 

    english [label="{{Language}|{Name=English}}", color=blue, fontcolor=blue] 
    languagesReferenceData -> english [label="HAS_LANGUAGE"] 

    mandarin [label="Mandarin (Language)"] 
    languagesReferenceData -> mandarin [label="HAS_LANGUAGE"] 

    japanese [label="Japanese (Language)"] 
    languagesReferenceData -> japanese [label="HAS_LANGUAGE"] 

    countriesReferenceData [label="Countries"] 
    referenceData -> countriesReferenceData [label="HAS_COUNTRIES"] 

    australia [label="{{Country}|{Name=Australia}}", color=blue, fontcolor=blue] 
    countriesReferenceData -> australia [label="HAS_COUNTRY"] 

    china [label="China (Country)"] 
    countriesReferenceData -> china[label="HAS_COUNTRY"] 
} 

回答

7

您可以嘗試添加的

splines=true; 
overlap=prism; 

代替nodesep=2;和渲染圖形與替代NEATO。這將導致更緊湊的佈局儘管標籤與某些節點重疊,並且基於記錄的節點彼此非常接近。

請注意,儘管您可能永遠無法通過graphviz獲得完美的數據庫模式 - 但幾乎總會有一些交叉邊緣可以更好地佈局。手動佈局的數據庫模式將擊敗graphviz輸出。

+5

最後我用 splines = true; overlap = portho; model = subset; 這讓我走上了正軌。謝謝! –

+0

非常好,這確實是更好! – marapet