MCPcopy Index your code
hub / github.com/TheAlgorithms/Go / AddVertex

Method AddVertex

graph/coloring/graph.go:21–31  ·  view source on GitHub ↗

AddVertex will add a new vertex in the graph, if the vertex already exist it will do nothing

(v int)

Source from the content-addressed store, hash-verified

19// AddVertex will add a new vertex in the graph, if the vertex already
20// exist it will do nothing
21func (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
34func (g *Graph) AddEdge(one, two int) {

Callers 3

BipartiteCheckFunction · 0.95
AddEdgeMethod · 0.95
getTestGraphsFunction · 0.45

Calls

no outgoing calls

Tested by 1

getTestGraphsFunction · 0.36