2016-08-05 16 views
14

Tworzę kilka diagramów aktywności UML za pomocą dot-graphviz, a krawędzie/strzałki (2+) zbiegają się w tym samym punkcie, gdy docelowy kształt jest zwężonym prostokątem (H = 0,5, W = 0,05). Ten problem nie występuje, jeśli docelowy kształt jest kwadratem (H = 0,5, W = 0,5).Zwiększenie separacji krawędzi w graphviz

Tutaj jest zmniejszona przykład plamek:

digraph G { 
graph [ ranksep = 0.5, rankdir = LR ] 
A4 [ shape = "record", height = 0.5, fontsize = 10, margin = "0.20,0.05", label = "Output\ to\rPreviewer", style = "rounded" ] 
A5 [ shape = "rectangle", height = 0.5, width = 0.05, margin = "0,0", style = "filled", label = "" ] 
A4 -> A5 [ shape = "edge", dir = "both", style = "solid", arrowtail = "none", arrowhead = "vee", labeldistance = 1, fontsize = 10 ] 
A6 [ shape = "diamond", height = 0.5, width = 0.5, margin = "0,0", label = "" ] 
A6 -> A5 [ shape = "edge", dir = "both", style = "solid", arrowtail = "none", arrowhead = "vee", labeldistance = 1, fontsize = 10, label = "[generate: false]" ] 
A7 [ shape = "record", height = 0.5, fontsize = 10, margin = "0.20,0.05", label = "Output\ to\rFile", style = "rounded" ] 
A6 -> A7 [ shape = "edge", dir = "both", style = "solid", arrowtail = "none", arrowhead = "vee", labeldistance = 1, fontsize = 10, label = "[generate: true]" ] 
A8 [ shape = "doublecircle", height = 0.3, width = 0.3, margin = "0,0", label = "" ] 
A7 -> A5 [ shape = "edge", dir = "both", style = "solid", arrowtail = "none", arrowhead = "vee", labeldistance = 1, fontsize = 10 ] 
A5 -> A8 [ shape = "edge", dir = "both", style = "solid", arrowtail = "none", arrowhead = "vee", labeldistance = 1, fontsize = 10 ] 
} 

Powyższy tekst generuje następujący wykres w http://webgraphviz.com

Current output

Pożądana moc jest następujący

Desired output

+1

można spróbować 'A6 -> A5: nw' i 'A7 -> A5: sw'. Nie daje dokładnie pożądanego wyniku, ale przynajmniej oddziela krawędzie. – vaettchen

+0

@vaettchen, to nie brzmi jak uniwersalne rozwiązanie i bardzo specyficzne dla podanego przykładu. To nie pomogłoby, gdyby były 4 krawędzie. – Jaime

+0

Poprawnie - próbowałem rozwiązania dla tego konkretnego pytania. Może edytujesz swój post, mówiąc, że szukasz ogólnego rozwiązania dla większej liczby krawędzi/strzał. – vaettchen

Odpowiedz

2

znalazłem wariację, która produkuje ładne wyjście, ale wymaga dużo przetwarzania i krawędź-count i kierunek świadomości:

digraph G { 
graph [ ranksep = 0.5, rankdir = LR ] 
A4 [ shape = "record", height = 0.5, fontsize = 10, margin = "0.20,0.05", label = "Output\ to\rPreviewer", style = "rounded" ] 
A5 [ shape = "record", height = 0.5, width = 0.05, margin = "0,0", style = "filled", label = "<f0>|<f1>|<f2>", fillcolor="black" ] 
A4 -> A5:f0:w [ shape = "edge", dir = "both", style = "solid", arrowtail = "none", arrowhead = "vee", labeldistance = 1, fontsize = 10 ] 
A6 [ shape = "diamond", height = 0.5, width = 0.5, margin = "0,0", label = "" ] 
A6 -> A5:f1:w [ shape = "edge", dir = "both", style = "solid", arrowtail = "none", arrowhead = "vee", labeldistance = 1, fontsize = 10, label = "[generate: false]" ] 
A7 [ shape = "record", height = 0.5, fontsize = 10, margin = "0.20,0.05", label = "Output\ to\rFile", style = "rounded" ] 
A6 -> A7 [ shape = "edge", dir = "both", style = "solid", arrowtail = "none", arrowhead = "vee", labeldistance = 1, fontsize = 10, label = "[generate: true]" ] 
A8 [ shape = "doublecircle", height = 0.3, width = 0.3, margin = "0,0", label = "" ] 
A7 -> A5:f2:w [ shape = "edge", dir = "both", style = "solid", arrowtail = "none", arrowhead = "vee", labeldistance = 1, fontsize = 10 ] 
A5 -> A8 [ shape = "edge", dir = "both", style = "solid", arrowtail = "none", arrowhead = "vee", labeldistance = 1, fontsize = 10 ] 
} 

To jest wyjście:

enter image description here

Chciałbym jeszcze Chciałbym wiedzieć, czy istnieje prostsze rozwiązanie.

+0

Przyjmuję własną odpowiedź, ponieważ zapewnia ona najlepszy wynik i może być rozszerzona na dowolną liczbę krawędzi. – Jaime

1

można określić port wyjściowy wszystkich krawędziach do east i dostać preaty piękny rezultat (przynajmniej w tym przypadku):

digraph G { 
     graph [ ranksep = 0.5, rankdir = LR ] 
     edge [tailport=e]     # <----- added this line 
     A4 [ shape = "record", height = 0.5, fontsize = 10, margin = "0.20,0.05", label = "Output\ to\rPreviewer", style = "rounded" ] 
     A5 [ shape = "rectangle", height = 0.5, width = 0.05, margin = "0,0", style = "filled", label = "" ] 
     A4 -> A5 [ shape = "edge", dir = "both", style = "solid", arrowtail = "none", arrowhead = "vee", labeldistance = 1, fontsize = 10 ] 
     A6 [ shape = "diamond", height = 0.5, width = 0.5, margin = "0,0", label = "" ] 
     A6 -> A5 [ shape = "edge", dir = "both", style = "solid", arrowtail = "none", arrowhead = "vee", labeldistance = 1, fontsize = 10, label  = "[generate: false]" ] 
     A7 [ shape = "record", height = 0.5, fontsize = 10, margin = "0.20,0.05", label = "Output\ to\rFile", style = "rounded" ] 
     A6 -> A7 [ shape = "edge", dir = "both", style = "solid", arrowtail = "none", arrowhead = "vee", labeldistance = 1, fontsize = 10, label  = "[generate: true]" ] 
     A8 [ shape = "doublecircle", height = 0.3, width = 0.3, margin = "0,0", label = "" ] 
     A7 -> A5 [ shape = "edge", dir = "both", style = "solid", arrowtail = "none", arrowhead = "vee", labeldistance = 1, fontsize = 10 ] 
     A5 -> A8 [ shape = "edge", dir = "both", style = "solid", arrowtail = "none", arrowhead = "vee", labeldistance = 1, fontsize = 10 ] 
} 

produce:

results

+0

Cześć Ohad, to wyglądało na dobrą alternatywę i pierwszy rzut oka, ale to tylko zbieg okoliczności dla podanego przykładu. Spróbuj skomentować linię 'A7 -> A5', a oryginalny efekt pojawi się ponownie. – Jaime

+0

Chociaż nie jest to przypadek, masz rację, to nie jest rozwiązanie dla wszystkich przypadków –