1 year ago

#382652

test-img

cavog15507

Get Connected Components in an undirected graph - Python

I want to get all connected subgraph of the graph
graph = {1: [3, 4], 2: [5, 8], 3: [4, 1], 4: [1, 3], 5: [2, 8], 6: [7, 9], 7: [6, 10, 9], 8: [2, 5], 9: [7, 6, 10], 10: [7, 9]}
for example I have this graph dictionary, the function should return the connected subgraph. I want a recursion function of the depth-first traversal. which initialize status dictionary with 0, whose keys are the vertices and change to 1 when a vertex has been marked, and to 2 when it has edged it.

python

graph

undirected-graph

0 Answers

Your Answer

Accepted video resources