0

How to display the progress of execution of a code with library functions?

import networkx as nx
graph=nx.erdos_renyi_graph(100000,.2)

visited = set() # Set to keep track of visited nodes of graph.

def dfs(visited, graph, node):  #function for dfs 
    if node not in visited:
        print (node)
        visited.add(node)
        for neighbour in graph[node]:
            dfs(visited, graph, neighbour)

print("Following is the Depth-First Search")
dfs(visited, graph, '5000')
coms=nx.connected_components(graph)
1
  • 1
    you can use tqdm Commented Nov 3, 2021 at 21:37

1 Answer 1

1

As mentioned in the comments, use tqdm:

from tqdm import tqdm
for i in tqdm(range(10)):
  print(i, end = '')

Output:

100%|██████████| 10/10 [00:00<00:00, 26181.67it/s] 0123456789
Sign up to request clarification or add additional context in comments.

2 Comments

Hi Keivan, this sort of question is often a duplicate, please search for possibles duplicates first and cite them in a comment on the question. Rather than answering them; duplicates typically get closed quickly so you don't get any rep for answering them.
where should i use this code?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.