Counting Components
This function checks for the number of components in an UNDIRECTED graph.
Usage
counting_components(graph: Graph)
Parameters:
graph : Graph
Graph Object
Returns:
int
Number of connected components
Example
from jellybeans.algos import counting_componentsfrom jellybeans.structures import Graphg = Graph()g.add_vertex(1)g.add_vertex(5)g.add_vertex(9)g.add_vertex(19)g.add_bidirected_edge(1, 5)g.add_bidirected_edge(5, 9)print(counting_components(g)) # 2