13. 応用例: Grpahviz等で家系図を# 13.1. 仮想敵な一族の家系図# 13.1.1. blockdaig# blockdiagでの仮想的な一族の家系図を作成してみます。グループと婚姻関係を表すコンポーネントを 導入しています。 図 13.1 blockdiag での家系図# 同じ一族の家系図をgraphvizで描画してみます。 graph FT { layout=dot { rank= same 父方祖父 父方祖母 F1 [label="", shape="circle", width=0, height=0]; 父方祖父 -- F1 -- 父方祖母 }; { edge [dir=forward, arrwohed=normal]; F1 -- 叔父 F1 -- 父 } { rank = same; 母方祖父; 母方祖母; F2 [label="", shape="circle", width=0, height=0]; 母方祖父 -- F2 -- 母方祖母 ; }; { edge [dir=forward, arrwohed=normal]; F2 -- 伯母; F2 -- 母; } { rank=same; 父; 母; F3 [label="", shape="circle", width=0, height=0]; 父 -- F3 -- 母; }; { rank=same; 母再婚相手; F4 [label="", shape="circle", width=0, height=0]; 母 -- F4 -- 母再婚相手 } { edge [dir=forward, arrwohed=normal]; F3 -- 姉; F3 -- 自分; F3 -- 弟; F4 -- 義妹 } } 図 13.2 graphviz例# digraph FT { layout=neato { rank = same; 母方祖母; 母方祖父; F2 [label="", shape="circle", width=0, height=0]; 母方祖父 -> F2; 母方祖母 -> F2; }; { edge [dir=forward, arrwohed=normal]; F2 -> 母; F2 -> 伯母; } { rank= same 父方祖母 父方祖父 F1 [label="", shape="circle", width=0, height=0]; 父方祖父 -> F1 ; 父方祖母 -> F1 ; }; { edge [dir=forward, arrwohed=normal]; F1 -> 父 F1 -> 叔父 } { rank=same; 父; 母; F3 [label="", shape="circle", width=0, height=0]; 母 -> F3; 父 -> F3; 母再婚相手; 母; F4 [label="", shape="circle", width=0, height=0]; 母 -> F4 ; 母再婚相手 -> F4; }; { edge [dir=forward, arrwohed=normal]; F3 -> 姉; F3 -> 自分; F3 -> 弟; F4 -> 義妹 } } 図 13.3 graphviz例(digraph and neato)# PlantUMLのコンポーネント図(あるいは配置図?)を使った作例です。 婚姻関係を表現するために、rectangle を導入しています。夫婦と婚姻関係を表現するために、 表示ラベルが空白(" ")のインタフェースコンポーネントを導入しています。 図 13.4 plantUMLによる作例# 13.2. Caroline Bouvier Kennedyの家系図# Graphviz ギャラリー:家系図 にある 家系図の一例。 婚姻関係に rank=same の条件を追加しました。 graph G { label="ancestor graph from Caroline Bouvier Kennedy" layout = dot fontname="Helvetica,Arial,sans-serif" node [fontname="Helvetica,Arial,sans-serif"] edge [fontname="Helvetica,Arial,sans-serif"] I5 [shape=ellipse,color=red,style=bold,label="Caroline Bouvier Kennedy\nb. 27.11.1957 New York",image="_static/165px-Caroline_Kennedy.png",labelloc=b]; I1 [shape=box,color=blue,style=bold,label="John Fitzgerald Kennedy\nb. 29.5.1917 Brookline\nd. 22.11.1963 Dallas",image="_static/kennedyface.png",labelloc=b]; I6 [shape=box,color=blue,style=bold,label="John Fitzgerald Kennedy Jr.\nb. 25.11.1960 Washington\nd. 16.7.1999 over the Atlantic Ocean, near Aquinnah, MA, USA",image="_static/180px-JFKJr2.png",labelloc=b]; I7 [shape=box,color=blue,style=bold,label="Patrick Bouvier Kennedy\nb. 7.8.1963\nd. 9.8.1963"]; I2 [shape=ellipse,color=red,style=bold,label="Jaqueline Lee Bouvier\nb. 28.7.1929 Southampton\nd. 19.5.1994 New York City",image="_static/jacqueline-kennedy-onassis.png",labelloc=b]; I8 [shape=box,color=blue,style=bold,label="Joseph Patrick Kennedy\nb. 6.9.1888 East Boston\nd. 16.11.1969 Hyannis Port",image="_static/1025901671.png",labelloc=b]; I10 [shape=box,color=blue,style=bold,label="Joseph Patrick Kennedy Jr\nb. 1915\nd. 1944"]; I11 [shape=ellipse,color=red,style=bold,label="Rosemary Kennedy\nb. 13.9.1918\nd. 7.1.2005",image="_static/rosemary.png",labelloc=b]; I12 [shape=ellipse,color=red,style=bold,label="Kathleen Kennedy\nb. 1920\nd. 1948"]; I13 [shape=ellipse,color=red,style=bold,label="Eunice Mary Kennedy\nb. 10.7.1921 Brookline"]; I9 [shape=ellipse,color=red,style=bold,label="Rose Elizabeth Fitzgerald\nb. 22.7.1890 Boston\nd. 22.1.1995 Hyannis Port",image="_static/Rose_kennedy.jpeg",labelloc=b]; I15 [shape=box,color=blue,style=bold,label="Aristotle Onassis"]; I3 [shape=box,color=blue,style=bold,label="John Vernou Bouvier III\nb. 1891\nd. 1957",image="_static/BE037819.png",labelloc=b]; I4 [shape=ellipse,color=red,style=bold,label="Janet Norton Lee\nb. 2.10.1877\nd. 3.1.1968",image="_static/n48862003257_1275276_1366.png",labelloc=b]; {rank=same I1 I2 I15} {rank=same I3 I4 } {rank=same I8 I9 } I1 -- I5 [style=bold,color=blue]; I1 -- I6 [style=bold,color=blue]; I2 -- I6 [style=bold,color=red]; I1 -- I7 [style=bold,color=blue]; I2 -- I7 [style=bold,color=red]; I1 -- I2 [style=bold,color=green]; I8 -- I1 [style=bold,color=blue ]; I9 -- I1 [style=bold,color=red]; I8 -- I10 [style=bold,color=blue]; I9 -- I10 [style=bold,color=red]; I8 -- I11 [style=bold,color=blue]; I9 -- I11 [style=bold,color=red]; I8 -- I12 [style=bold,color=blue]; I9 -- I12 [style=bold,color=red]; I8 -- I13 [style=bold,color=blue]; I9 -- I13 [style=bold,color=red]; I8 -- I9 [style=bold,color=green]; I2 -- I5 [style=bold,color=red]; I2 -- I15 [style=bold,color=violet]; I3 -- I2 [style=bold,color=blue]; I4 -- I2 [style=bold,color=red]; I3 -- I4 [style=bold,color=green]; } 図 13.5 Colors and forms symbolize following * Blue box - man * Red ellipse - woman * Blue line - Father/Child relation * Red line - Mother/Child relation * Green line - Spouse relation * Orange line - Ancestors (other) children * Violet line - (other) spouse# 13.2.1. neato# 同じグラフをレイアウトエンジンを neato として描いてみます。 graph G { label="ancestor graph from Caroline Bouvier Kennedy" layout = neato overlap=false splines=true sep = 0.05 center=true normalize=true mode="major" model="circuit" fontname="Helvetica,Arial,sans-serif" node [fontname="Helvetica,Arial,sans-serif",fontsize=10 ] edge [fontname="Helvetica,Arial,sans-serif",fontsize=10 , len=1.00] I5 [shape=ellipse,color=red,style=bold, label="Caroline Bouvier Kennedy\nb. 27.11.1957 New York",image="_static/165px-Caroline_Kennedy.png",labelloc=b]; I1 [shape=box,color=blue,style=bold,label="John Fitzgerald Kennedy\nb. 29.5.1917 Brookline\nd. 22.11.1963 Dallas",image="_static/kennedyface.png",labelloc=b]; I6 [shape=box,color=blue,style=bold,label="John Fitzgerald Kennedy Jr.\nb. 25.11.1960 Washington\nd. 16.7.1999 over the Atlantic Ocean, near Aquinnah, MA, USA",image="_static/180px-JFKJr2.png",labelloc=b]; I7 [shape=box,color=blue,style=bold,label="Patrick Bouvier Kennedy\nb. 7.8.1963\nd. 9.8.1963"]; I2 [shape=ellipse,color=red,style=bold,label="Jaqueline Lee Bouvier\nb. 28.7.1929 Southampton\nd. 19.5.1994 New York City",image="_static/jacqueline-kennedy-onassis.png",labelloc=b]; I8 [shape=box,color=blue,style=bold,label="Joseph Patrick Kennedy\nb. 6.9.1888 East Boston\nd. 16.11.1969 Hyannis Port",image="_static/1025901671.png",labelloc=b]; I10 [shape=box,color=blue,style=bold,label="Joseph Patrick Kennedy Jr\nb. 1915\nd. 1944"]; I11 [shape=ellipse,color=red,style=bold,label="Rosemary Kennedy\nb. 13.9.1918\nd. 7.1.2005",image="_static/rosemary.png",labelloc=b]; I12 [shape=ellipse,color=red,style=bold,label="Kathleen Kennedy\nb. 1920\nd. 1948"]; I13 [shape=ellipse,color=red,style=bold,label="Eunice Mary Kennedy\nb. 10.7.1921 Brookline"]; I9 [shape=ellipse,color=red,style=bold,label="Rose Elizabeth Fitzgerald\nb. 22.7.1890 Boston\nd. 22.1.1995 Hyannis Port",image="_static/Rose_kennedy.png",labelloc=b]; I15 [shape=box,color=blue,style=bold,label="Aristotle Onassis"]; I3 [shape=box,color=blue,style=bold,label="John Vernou Bouvier III\nb. 1891\nd. 1957",image="_static/BE037819.png",labelloc=b]; I4 [shape=ellipse,color=red,style=bold,label="Janet Norton Lee\nb. 2.10.1877\nd. 3.1.1968",image="_static/n48862003257_1275276_1366.png",labelloc=b]; {rank=same I2 I1 I15 } {rank=same I3 I4 } {rank=same I8 I9 } I1 -- I5 [style=bold,color=blue, len=6.00]; I1 -- I6 [style=bold,color=blue, len=6.00]; I2 -- I6 [style=bold,color=red, len=6.00]; I1 -- I7 [style=bold,color=blue, len=6.00]; I2 -- I7 [style=bold,color=red, len=6.00]; I1 -- I2 [style=bold,color=green, len=4.00]; I8 -- I1 [style=bold,color=blue , len=6.00]; I9 -- I1 [style=bold,color=red, len=6.00]; I8 -- I10 [style=bold,color=blue, len=6.00]; I9 -- I10 [style=bold,color=red, len=6.00]; I8 -- I11 [style=bold,color=blue, len=6.00]; I9 -- I11 [style=bold,color=red, len=6.00]; I8 -- I12 [style=bold,color=blue, len=6.00]; I9 -- I12 [style=bold,color=red, len=6.00]; I8 -- I13 [style=bold,color=blue, len=6.00]; I9 -- I13 [style=bold,color=red, len=6.00]; I8 -- I9 [style=bold,color=green, len=4.00]; I2 -- I5 [style=bold,color=red, len=6.00]; I2 -- I15 [style=bold,color=violet, len=4.00]; I3 -- I2 [style=bold,color=blue, len=6.00]; I4 -- I2 [style=bold,color=red, len=6.00]; I3 -- I4 [style=bold,color=green, len=4.00]; } 図 13.6 Colors and forms symbolize following# ケネディ家の家系図をPlantUML化してみます。 図 13.7 ケネディ家の家系図(using PlantUML)# 13.3. UNIX Family 'Tree'# 13.3.1. オリジナル(Graphviz)のUnix Family Tree# digraph unix { label="courtesy Ian Darwin and Geoff Collyer, Softquad Inc." fontname="Helvetica,Arial,sans-serif" node [fontname="Helvetica,Arial,sans-serif"] edge [fontname="Helvetica,Arial,sans-serif"] node [color=lightblue2, style=filled]; "5th Edition" -> "6th Edition"; "5th Edition" -> "PWB 1.0"; "6th Edition" -> "LSX"; "6th Edition" -> "1 BSD"; "6th Edition" -> "Mini Unix"; "6th Edition" -> "Wollongong"; "6th Edition" -> "Interdata"; "Interdata" -> "Unix/TS 3.0"; "Interdata" -> "PWB 2.0"; "Interdata" -> "7th Edition"; "7th Edition" -> "8th Edition"; "7th Edition" -> "32V"; "7th Edition" -> "V7M"; "7th Edition" -> "Ultrix-11"; "7th Edition" -> "Xenix"; "7th Edition" -> "UniPlus+"; "V7M" -> "Ultrix-11"; "8th Edition" -> "9th Edition"; "1 BSD" -> "2 BSD"; "2 BSD" -> "2.8 BSD"; "2.8 BSD" -> "Ultrix-11"; "2.8 BSD" -> "2.9 BSD"; "32V" -> "3 BSD"; "3 BSD" -> "4 BSD"; "4 BSD" -> "4.1 BSD"; "4.1 BSD" -> "4.2 BSD"; "4.1 BSD" -> "2.8 BSD"; "4.1 BSD" -> "8th Edition"; "4.2 BSD" -> "4.3 BSD"; "4.2 BSD" -> "Ultrix-32"; "PWB 1.0" -> "PWB 1.2"; "PWB 1.0" -> "USG 1.0"; "PWB 1.2" -> "PWB 2.0"; "USG 1.0" -> "CB Unix 1"; "USG 1.0" -> "USG 2.0"; "CB Unix 1" -> "CB Unix 2"; "CB Unix 2" -> "CB Unix 3"; "CB Unix 3" -> "Unix/TS++"; "CB Unix 3" -> "PDP-11 Sys V"; "USG 2.0" -> "USG 3.0"; "USG 3.0" -> "Unix/TS 3.0"; "PWB 2.0" -> "Unix/TS 3.0"; "Unix/TS 1.0" -> "Unix/TS 3.0"; "Unix/TS 3.0" -> "TS 4.0"; "Unix/TS++" -> "TS 4.0"; "CB Unix 3" -> "TS 4.0"; "TS 4.0" -> "System V.0"; "System V.0" -> "System V.2"; "System V.2" -> "System V.3"; } 13.3.2. PlantUMLでのUnix Tree 図# 図 13.8 "courtesy Ian Darwin and Geoff Collyer, Softquad Inc."# 13.4. Other Example# stack overflow: Family tree layout with Dot/GraphViz の回答からの例。 graphvizの処理系によって結果が異なる。 digraph simpsons { edge [dir=none]; subgraph Generation0 { rank = same Abraham [shape = box, color = blue] Mona [shape = box, color = pink] AbrahamAndMona [shape = point] Abraham -> AbrahamAndMona -> Mona [dir = none] Clancy [shape = box, color = blue] Jackeline [shape = box, color = pink] ClancyAndJackeline [shape = point] Clancy -> ClancyAndJackeline -> Jackeline [dir = none] } subgraph Generation0Sons { rank = same HerbSon [shape = point] AbrahamAndMonaSons [shape = point] HomerSon [shape = point] HerbSon -> AbrahamAndMonaSons [dir = none] HomerSon -> AbrahamAndMonaSons [dir = none] MargeSon [shape = point] PattySon [shape = point] SelmaSon [shape = point] MargeSon -> PattySon [dir = none] PattySon -> SelmaSon [dir = none] } AbrahamAndMona -> AbrahamAndMonaSons [dir = none] ClancyAndJackeline -> PattySon [dir = none] subgraph Generation1 { rank = same Herb [shape = box, color = blue] Homer [shape = box, color = blue] Marge [shape = box, color = pink] Patty [shape = box, color = pink] Selma [shape = box, color = pink] HomerAndMarge [shape = point] Homer -> HomerAndMarge [dir = none] Marge -> HomerAndMarge [dir = none] } HerbSon -> Herb [dir = none] HomerSon -> Homer [dir = none] MargeSon -> Marge [dir = none] PattySon -> Patty [dir = none] SelmaSon -> Selma [dir = none] subgraph Generation1Sons { rank = same BartSon [shape = point] LisaSon [shape = point] MaggieSon [shape = point] BartSon -> LisaSon [dir = none] LisaSon -> MaggieSon [dir = none] } HomerAndMarge -> LisaSon [dir = none] subgraph Generation2 { rank = same Bart [shape = box, color = blue] Lisa [shape = box, color = pink] Maggie [shape = box, color = pink] Ling [shape = box, color = blue] } Selma -> Ling [dir = none] BartSon -> Bart [dir = none] LisaSon -> Lisa [dir = none] MaggieSon -> Maggie [dir = none] } 図 13.9 original# これを少し書き換えてみた結果、Abraham-Monaの位置がうまくコントロールできません。 graph simpsons { Herb [shape = box, color = blue] Homer [shape = box, color = blue] Marge [shape = box, color = pink] Patty [shape = box, color = pink] Selma [shape = box, color = pink] Abraham [shape = box, color = blue] Mona [shape = box, color = pink] Clancy [shape = box, color = blue] Jackeline [shape = box, color = pink] Bart [shape = box, color = blue] Lisa [shape = box, color = pink] Maggie [shape = box, color = pink] Ling [shape = box, color = blue] HomerAndMarge [shape = point] SelmaChildren [shape = point] AbrahamAndMona [shape = point] ClancyAndJackeline [shape = point] HerbSon [shape = point] AbrahamAndMonaSons [shape = point] HomerSon [shape = point] MargeSon [shape = point] PattySon [shape = point] SelmaSon [shape = point] subgraph Generation00 { rank = same Abraham -- AbrahamAndMona [dir = none] AbrahamAndMona -- Mona [dir = none] Clancy -- ClancyAndJackeline [dir = none] ClancyAndJackeline -- Jackeline [dir = none] } subgraph Generation00Sons { rank = same HerbSon -- AbrahamAndMonaSons [dir = none] AbrahamAndMonaSons -- HomerSon [dir = none] } subgraph Generation01 { rank = same } subgraph Generation01Sons { rank = same MargeSon -- PattySon [dir = none] PattySon -- SelmaSon [dir = none] } AbrahamAndMona -- AbrahamAndMonaSons [dir = none] ClancyAndJackeline -- PattySon [dir = none] HerbSon -- Herb [dir = none] subgraph Generation10 { rank = same Homer -- HomerAndMarge [dir = none] HomerAndMarge -- Marge [dir = none] } HomerSon -- Homer [dir = none] {rank=same; Herb;Homer; Marge;Patty;Selma; } MargeSon -- Marge [dir = none] PattySon -- Patty [dir = none] SelmaSon -- Selma [dir = none] subgraph Generation1Sons { rank = same BartSon [shape = point] LisaSon [shape = point] MaggieSon [shape = point] BartSon -- LisaSon [dir = none] LisaSon -- MaggieSon [dir = none] } HomerAndMarge -- LisaSon [dir = none] subgraph Generation2 { rank = same Bart;Lisa;Maggie; } BartSon -- Bart [dir = none] LisaSon -- Lisa [dir = none] MaggieSon -- Maggie [dir = none] Selma -- SelmaChildren SelmaChildren -- Ling [dir = none] } 図 13.10 変更版# digraph G { edge [dir=none]; node [regular=1]; "Herb" [shape=box, color="blue"] ; "Homer" [shape=box, color="blue"] ; "Marge" [shape=circle, color="pink"] ; "Clancy" [shape=box, color="blue"] ; "Jackeline" [shape=circle, color="pink"] ; "Abraham" [shape=box, color="blue"] ; "Mona" [shape=circle, color="pink"] ; "Patty" [shape=circle, color="pink"] ; "Selma" [shape=circle, color="pink"] ; "Bart" [shape=box, color="blue"] ; "Lisa" [shape=circle, color="pink"] ; "Maggie" [shape=circle, color="pink"] ; "Ling" [shape=box, color="blue"] ; a1 [shape=circle,label="",height=0.01,width=0.01]; b1 [shape=circle,label="",height=0.01,width=0.01]; b2 [shape=circle,label="",height=0.01,width=0.01]; b3 [shape=circle,label="",height=0.01,width=0.01]; {rank=same; Abraham -> a1 -> Mona}; {rank=same; b1 -> b2 -> b3}; {rank=same; Herb; Homer}; a1 -> b2 b1 -> Herb b3 -> Homer p1 [shape=circle,label="",height=0.01,width=0.01]; q1 [shape=circle,label="",height=0.01,width=0.01]; q2 [shape=circle,label="",height=0.01,width=0.01]; q3 [shape=circle,label="",height=0.01,width=0.01]; {rank=same; Homer -> p1 -> Marge}; {rank=same; q1 -> q2 -> q3}; {rank=same; Bart; Lisa; Maggie}; p1 -> q2; q1 -> Bart; q2 -> Lisa; q3 -> Maggie; x1 [shape=circle,label="",height=0.01,width=0.01]; y1 [shape=circle,label="",height=0.01,width=0.01]; y2 [shape=circle,label="",height=0.01,width=0.01]; y3 [shape=circle,label="",height=0.01,width=0.01]; {rank=same; Clancy -> x1 -> Jackeline}; {rank=same; y1 -> y2 -> y3}; {rank=same; Marge; Patty; Selma}; {rank=same; Bart; Ling} x1 -> y2; y1 -> Marge; y2 -> Patty; y3 -> Selma; Selma -> Ling; } 図 13.11 ネットで提案された改善例# PlantUMLで書き換えてみた結果、 図 13.12 PlantUML版# 図 13.13 ネットで提案された改善例をPlantUMLで書き直す。# 13.5. KEKの組織図 in PlantUML# 家系図ではないですが、同様の使い方で組織図も描けるのではと試してみます。 KEKの組織図は、https://www.kek.jp/wp-content/uploads/2024/04/orgchart_ja_20240401.pdf に掲載されている。 PlantUMLのWBSのような上から下へのトップダウンとはなっておらず、経営協議会/教育研究評議会/研究所運営会議とかどう取り扱って いいかわからない。 日本的組織とはそういうもんかとも思います。 一方で、PlantUMLのWBSもWBSのように、上から下への流れが定義によってはっきりしているものはよいが、組織図や、家系図といったものを一般的に表すことはできない様に感じます。 結局PlantUMLではコンポーネント図/配置図をベースにして、調整することができました。組織図も家系図の例のように、色々な手段を弄してなるべく近いものにしてみます。 (現状の組織を論理的な図にしてみることで、現状の組織の問題点が浮かびでるということもあるかとおもいます。) KEKの組織図は組織としての役割と、所長会議の様な会議体が混じっているために、PlantUMLやgraphvizの様な表現に馴染まないような気もします。 とりあえずの試作版です。 図 13.14 PlantUMLのコンポーネント図を使い、KEKの組織図を書くことに挑戦#