Check if is One Component
BFS: check if graph is one-component
In the previous method, we considered that the graph is one-component. That’s because if you start traversing at some node, you’ll visit only nodes from the same component.
If there are some other components, you should start from vertices of another component.
Swipe to start coding
Think about Implementation of method hasOneComponent()
. which returns True if it is only one component in graph.
Modify your g
graph by adding nodes in that way, so there are miltiple components, and check how function works.
Løsning
Tak for dine kommentarer!
single
Spørg AI
Spørg AI
Spørg om hvad som helst eller prøv et af de foreslåede spørgsmål for at starte vores chat
Opsummér dette kapitel
Explain code
Explain why doesn't solve task
Awesome!
Completion rate improved to 7.69
Check if is One Component
Stryg for at vise menuen
BFS: check if graph is one-component
In the previous method, we considered that the graph is one-component. That’s because if you start traversing at some node, you’ll visit only nodes from the same component.
If there are some other components, you should start from vertices of another component.
Swipe to start coding
Think about Implementation of method hasOneComponent()
. which returns True if it is only one component in graph.
Modify your g
graph by adding nodes in that way, so there are miltiple components, and check how function works.
Løsning
Tak for dine kommentarer!
Awesome!
Completion rate improved to 7.69single