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