Input: (adjacency matrix, Y is edge source, X is edge destination)
{0,1,0,0,0,0,0,0},
{0,0,1,1,0,0,0,0},
{1,0,0,1,0,0,0,0},
{0,0,0,0,1,1,0,0},
{0,0,0,0,0,0,1,0},
{0,0,0,0,1,0,0,1},
{0,0,0,0,1,0,0,0},
{0,0,0,0,0,1,0,0},
Output:
{nodes=[(0,3),(0,3),(0,3),(3,2),(4,0),(5,1),(4,0),(5,1)],components=[{nodes=[6,4],next=[0],next_contains=[1]},{nodes=[7,5],next=[1,0],next_contains=[1,1]},{nodes=[3],next=[0,1],next_contains=[1,1,0]},{nodes=[2,1,0],next=[3,2,0,1],next_contains=[1,1,1,1]}]}
Input:
// a b c d e f g h i j
/* a */{0,1,0,0,0,1,0,1,0,0},
/* b */{1,0,1,0,0,0,0,0,0,0},
/* c */{0,1,0,1,0,0,0,0,0,0},
/* d */{0,0,0,0,1,0,0,0,0,0},
/* e */{0,0,0,1,0,0,0,0,0,0},
/* f */{0,0,0,0,0,0,1,0,0,0},
/* g */{0,0,0,1,0,1,0,0,0,0},
/* h */{0,0,0,0,0,0,0,0,1,0},
/* i */{0,0,1,0,1,0,0,1,0,1},
/* j */{0,0,0,0,0,0,0,0,0,0},
Output:
{nodes=[(0,3),(0,3),(0,3),(3,0),(3,0),(5,1),(5,1),(0,3),(0,3),(9,2)],components=[{nodes=[4,3],next=[0],next_contains=[1]},{nodes=[6,5],next=[1,0],next_contains=[1,1]},{nodes=[9],next=[],next_contains=[0,0,0]},{nodes=[8,7,2,1,0],next=[3,2,0,1],next_contains=[1,1,1,1]}]}