Graph Theory37 sections · 1633 units
Open in Course

Pattern - Hub Nodes

Reducing Edges

If you have a set of items that are all connected to each other (a clique), adding edges between every pair is O(k2)O(k^2) for kk items. Too slow for large cliques.

Instead, create a virtual "hub" node. Connect every item to the hub. Now you have kk edges instead of k2k^2. Items in the same clique share the hub as their leader.

This pattern appears when problems have large groups that must be unified.

Space complexity is O(n)O(n) for the data structures used.