44from typing import Union , Iterable , Any , Tuple
55
66from networkx import MultiDiGraph , compose , path_graph
7+ from tqdm import tqdm
78
89__all__ = ["labeled_two_cycles_graph" ]
910
@@ -13,6 +14,7 @@ def labeled_two_cycles_graph(
1314 m : Union [int , Iterable [Any ]],
1415 common : Union [int , Any ] = 0 ,
1516 edge_labels : Tuple [str , str ] = ("a" , "b" ),
17+ verbose : bool = True ,
1618) -> MultiDiGraph :
1719 """Returns a graph with two cycles connected by one node.
1820 With labeled edges.
@@ -35,12 +37,17 @@ def labeled_two_cycles_graph(
3537 edge_labels: Tuple[str, str]
3638 Labels that will be used to mark the edges of the graph.
3739
40+ verbose : bool
41+ If true, a progress bar will be displayed.
42+
3843 Examples
3944 --------
4045 >>> import cfpq_data
41- >>> g = cfpq_data.labeled_two_cycles_graph(42, 29)
42- >>> g.number_of_nodes(), g.number_of_edges()
43- (72, 73)
46+ >>> g = cfpq_data.labeled_two_cycles_graph(42, 29, verbose=False)
47+ >>> g.number_of_nodes()
48+ 72
49+ >>> g.number_of_edges()
50+ 73
4451
4552 Returns
4653 -------
@@ -67,10 +74,14 @@ def labeled_two_cycles_graph(
6774 tmp .add_edge (common , first_node )
6875 tmp .add_edge (last_node , common )
6976
70- for edge in g1 .edges :
77+ for edge in tqdm (
78+ g1 .edges , disable = not verbose , desc = "Generation of the first cycle..."
79+ ):
7180 g1 .edges [edge ]["label" ] = edge_labels [0 ]
7281
73- for edge in g2 .edges :
82+ for edge in tqdm (
83+ g2 .edges , disable = not verbose , desc = "Generation of the second cycle..."
84+ ):
7485 g2 .edges [edge ]["label" ] = edge_labels [1 ]
7586
7687 g = MultiDiGraph (compose (g1 , g2 ))
0 commit comments