MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / __init__

Method __init__

graphs/boruvka.py:34–47  ·  view source on GitHub ↗

Arguments: num_of_nodes - the number of nodes in the graph Attributes: m_num_of_nodes - the number of nodes in the graph. m_edges - the list of edges. m_component - the dictionary which stores the index of the component which

(self, num_of_nodes: int)

Source from the content-addressed store, hash-verified

32
33class Graph:
34 def __init__(self, num_of_nodes: int) -> None:
35 """
36 Arguments:
37 num_of_nodes - the number of nodes in the graph
38 Attributes:
39 m_num_of_nodes - the number of nodes in the graph.
40 m_edges - the list of edges.
41 m_component - the dictionary which stores the index of the component which
42 a node belongs to.
43 """
44
45 self.m_num_of_nodes = num_of_nodes
46 self.m_edges: list[list[int]] = []
47 self.m_component: dict[int, int] = {}
48
49 def add_edge(self, u_node: int, v_node: int, weight: int) -> None:
50 """Adds an edge in the format [first, second, edge weight] to graph."""

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected