Find All Connected Components
BFS find all connected components
Complicate the problem: find all components in a graph.
Some hints for you:
- When you’re done with the first component, save it, and start traversing again with some nodes that haven’t been visited yet.
- To split your components, you can use an upgraded
visitedlist: put0if vertex is not visited yet, or putkif vertex is inkth component. - Return tuple of lists of vertex numbers, one list for each component. Create it by using an upgraded
visitedlist.
Opgave
Swipe to start coding
Implement getComponents() function.
Var alt klart?
Tak for dine kommentarer!
Sektion 2. Kapitel 5
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
Awesome!
Completion rate improved to 7.69
Find All Connected Components
Stryg for at vise menuen
BFS find all connected components
Complicate the problem: find all components in a graph.
Some hints for you:
- When you’re done with the first component, save it, and start traversing again with some nodes that haven’t been visited yet.
- To split your components, you can use an upgraded
visitedlist: put0if vertex is not visited yet, or putkif vertex is inkth component. - Return tuple of lists of vertex numbers, one list for each component. Create it by using an upgraded
visitedlist.
Opgave
Swipe to start coding
Implement getComponents() function.
Var alt klart?
Tak for dine kommentarer!
Sektion 2. Kapitel 5
single