Simple python solution using BFS traversal
\nclass Solution:\n    def minReorder(self, n: int, connections: List[List[int]]) -> int:\n        visited=[0]*n\n        indegree=[[] for _ in range(n)]\n     
```\nclass Solution:\n    def minReorder(self, n: int, connections: List[List[int]]) -> int:\n        visited=[0]*n\n        indegree=[[] for _ in range(n)]\n        outdegree=[[] for _ in range(n)]\n        for frm,to in connections:\n            indegree[to].append(frm)\n            outdegree[frm].append(to)\n        lst=[0]\n        visited[0]=1\n        ct=0\n        while lst:\n            x=lst.pop(0)\n            for i in indegree[x]:\n                if visited[i]==0:\n                    lst.append(i)\n                    visited[i]=1\n            for i in outdegree[x]:\n                if visited[i]==0:\n                    lst.append(i)\n                    visited[i]=1\n                    # here we have to change the direction of edge\n                    ct+=1\n        return ct\n```
['Breadth-First Search', 'Graph', 'Python', 'Python3']