Connect vertex 'from' to 'to' by a new edge if not exist
(from, to Vertex)
| 114 | |
| 115 | // Connect vertex 'from' to 'to' by a new edge if not exist |
| 116 | func (d *DAG) Connect(from, to Vertex) bool { |
| 117 | if from == nil || to == nil { |
| 118 | return false |
| 119 | } |
| 120 | for k := range d.edges { |
| 121 | if k.From() == from && k.To() == to { |
| 122 | return true |
| 123 | } |
| 124 | } |
| 125 | edge := RealEdge(from, to) |
| 126 | d.edges[edge] = edge |
| 127 | return true |
| 128 | } |
| 129 | |
| 130 | // AddConnect add 'to' to the DAG 'd' and connect 'from' to 'to' |
| 131 | func (d *DAG) AddConnect(from, to Vertex) bool { |