The implemented Connected Component is based on Breadth-first Search graph traversal equipped with one First-In-First-Out queue. The pseudo-code is shown below:
procedure ConnectedComponent(graph_CSR)
grpah_CSC := csr2csc(graph_CSR)
for each vertex v in graph
result(v) := -1
result(0) := 1
push node 0 into Queue
while all vertexs have been labeled
while Queue is not empty
u := pop Queue
for each edge(u, v) in both graph_CSR and graph_CSC
if result(v) == -1 then
result(v) := u + 1
push v into Queue
end if
end for
end while
newRoot := findNewRoot(result)
push root node into Queue
end while
return result
Here, the connected component gets all indegree and outdegree of each u when the input graph is directed. As a result, one addition csr2csc operation is required at the beginning.