@@ -38,9 +38,10 @@ type graphNodeSpec struct {
3838}
3939
4040type textEdge struct {
41- parent textNode
42- child textNode
43- label string
41+ parent textNode
42+ child textNode
43+ label string
44+ isBidirectional bool
4445}
4546
4647type textSubgraph struct {
@@ -144,18 +145,22 @@ func parseStyleClass(matchedLine []string) styleClass {
144145 return styleClass {className , styleMap }
145146}
146147
147- func setArrowWithLabel (lhs , rhs []textNode , label string , gp * graphProperties ) []textNode {
148+ func setArrowWithLabel (lhs , rhs []textNode , label string , isBidirectional bool , gp * graphProperties ) []textNode {
148149 log .Debug ("Setting arrow from " , lhs , " to " , rhs , " with label " , label )
149150 for _ , l := range lhs {
150151 for _ , r := range rhs {
151- setData (l , textEdge {l , r , label }, gp .data , gp .nodeSpecs )
152+ setData (l , textEdge {l , r , label , isBidirectional }, gp .data , gp .nodeSpecs )
152153 }
153154 }
154155 return rhs
155156}
156157
157158func setArrow (lhs , rhs []textNode , gp * graphProperties ) []textNode {
158- return setArrowWithLabel (lhs , rhs , "" , gp )
159+ return setArrowWithLabel (lhs , rhs , "" , false , gp )
160+ }
161+
162+ func setBidirectionalArrow (lhs , rhs []textNode , gp * graphProperties ) []textNode {
163+ return setArrowWithLabel (lhs , rhs , "" , true , gp )
159164}
160165
161166func rememberNode (node textNode , nodeSpecs map [string ]graphNodeSpec ) {
@@ -213,6 +218,30 @@ func (gp *graphProperties) parseString(line string) ([]textNode, error) {
213218 return []textNode {}, nil
214219 },
215220 },
221+ {
222+ regex : regexp .MustCompile (`(?s)^(.+)\s*<-->\s*\|(.+)\|\s*(.+)$` ),
223+ handler : func (match []string ) ([]textNode , error ) {
224+ if lhs , err = gp .parseString (match [0 ]); err != nil {
225+ lhs = []textNode {parseNode (match [0 ])}
226+ }
227+ if rhs , err = gp .parseString (match [2 ]); err != nil {
228+ rhs = []textNode {parseNode (match [2 ])}
229+ }
230+ return setArrowWithLabel (lhs , rhs , match [1 ], true , gp ), nil
231+ },
232+ },
233+ {
234+ regex : regexp .MustCompile (`(?s)^(.+)\s*<-->\s*(.+)$` ),
235+ handler : func (match []string ) ([]textNode , error ) {
236+ if lhs , err = gp .parseString (match [0 ]); err != nil {
237+ lhs = []textNode {parseNode (match [0 ])}
238+ }
239+ if rhs , err = gp .parseString (match [1 ]); err != nil {
240+ rhs = []textNode {parseNode (match [1 ])}
241+ }
242+ return setBidirectionalArrow (lhs , rhs , gp ), nil
243+ },
244+ },
216245 {
217246 regex : regexp .MustCompile (`(?s)^(.+)\s*-->\s*\|(.+)\|\s*(.+)$` ),
218247 handler : func (match []string ) ([]textNode , error ) {
@@ -222,7 +251,7 @@ func (gp *graphProperties) parseString(line string) ([]textNode, error) {
222251 if rhs , err = gp .parseString (match [2 ]); err != nil {
223252 rhs = []textNode {parseNode (match [2 ])}
224253 }
225- return setArrowWithLabel (lhs , rhs , match [1 ], gp ), nil
254+ return setArrowWithLabel (lhs , rhs , match [1 ], false , gp ), nil
226255 },
227256 },
228257 {
0 commit comments