AddVertex will add a new vertex in the graph, if the vertex already exist it will do nothing
(v int)
| 19 | // AddVertex will add a new vertex in the graph, if the vertex already |
| 20 | // exist it will do nothing |
| 21 | func (g *Graph) AddVertex(v int) { |
| 22 | if g.edges == nil { |
| 23 | g.edges = make(map[int]map[int]struct{}) |
| 24 | } |
| 25 | |
| 26 | // Check if vertex is present or not |
| 27 | if _, ok := g.edges[v]; !ok { |
| 28 | g.vertices++ |
| 29 | g.edges[v] = make(map[int]struct{}) |
| 30 | } |
| 31 | } |
| 32 | |
| 33 | // AddEdge will add a new edge between the provided vertices in the graph |
| 34 | func (g *Graph) AddEdge(one, two int) { |
no outgoing calls