MCPcopy Index your code
hub / github.com/TheAlgorithms/Python / add_edge

Method add_edge

graphs/minimum_spanning_tree_boruvka.py:20–33  ·  view source on GitHub ↗

Adds an edge to the graph

(self, head, tail, weight)

Source from the content-addressed store, hash-verified

18 self.num_vertices += 1
19
20 def add_edge(self, head, tail, weight):
21 """
22 Adds an edge to the graph
23
24 """
25
26 self.add_vertex(head)
27 self.add_vertex(tail)
28
29 if head == tail:
30 return
31
32 self.adjacency[head][tail] = weight
33 self.adjacency[tail][head] = weight
34
35 def distinct_weight(self):
36 """

Callers 1

buildMethod · 0.95

Calls 1

add_vertexMethod · 0.95

Tested by

no test coverage detected