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

Method AddEdge

graph/coloring/graph.go:34–42  ·  view source on GitHub ↗

AddEdge will add a new edge between the provided vertices in the graph

(one, two int)

Source from the content-addressed store, hash-verified

32
33// AddEdge will add a new edge between the provided vertices in the graph
34func (g *Graph) AddEdge(one, two int) {
35 // Add vertices: one and two to the graph if they are not present
36 g.AddVertex(one)
37 g.AddVertex(two)
38
39 // and finally add the edges: one->two and two->one for undirected graph
40 g.edges[one][two] = struct{}{}
41 g.edges[two][one] = struct{}{}
42}
43
44func (g *Graph) ValidateColorsOfVertex(colors map[int]Color) error {
45 if g.vertices != len(colors) {

Callers 2

BipartiteCheckFunction · 0.95
getTestGraphsFunction · 0.45

Calls 1

AddVertexMethod · 0.95

Tested by 1

getTestGraphsFunction · 0.36