@@ -275,7 +275,7 @@ def compare_n_programs(dfs_dict: Dict[str, pd.DataFrame], programs: List[str], c
275
275
276
276
data = dfs_dict [program ][columns ]
277
277
df = pd .concat ([df , data ], axis = 1 , sort = False )
278
-
278
+
279
279
# sort by nodes and then by instances
280
280
df = df .sort_values (by = ['nodes' , 'filename' ])
281
281
@@ -319,7 +319,7 @@ def pretty_print_pandas(df: pd.DataFrame, tablefmt='pretty'):
319
319
320
320
def merge_dataframes_helper (dfs : List [pd .DataFrame ], use_meta = True ) -> pd .DataFrame :
321
321
"""
322
- Create a new in-memory DataFrame that, for each row of all the dataframes in dfs, keeps only the first row
322
+ Create a new in-memory DataFrame that, for each row of all the dataframes in dfs, keeps only the first row
323
323
values merging `program_time`, `discovery_time` and `full_contraction` by mean, `discovery_iteration` by median,
324
324
while other columns are taken arbitrarily from the first.
325
325
:param dfs: List of DataFrames for a single program
@@ -538,13 +538,13 @@ def plot_precision_comparison(names: List[str], dfs: Dict[str, pd.DataFrame], ti
538
538
539
539
def karger_full_contraction_chart (dfs ):
540
540
karger_df = dfs [KARGER ].copy ()
541
- # karger_df['full_contraction_asymptotic'] = 0.3 * np.square(karger_df['nodes']).astype(float)
541
+ karger_df ['full_contraction_asymptotic' ] = 0.3 * np .square (karger_df ['nodes' ]).astype (float )
542
542
title = 'Tempo di esecuzione di full contraction rispetto al numero di nodi'
543
543
544
544
g = sns .lineplot (karger_df ['nodes' ], karger_df ['full_contraction' ], label = 'Full Contraction' )
545
- # g = sns.lineplot(karger_df['nodes'], karger_df['full_contraction_asymptotic'], label='Full Contraction Asintotico: n^2')
545
+ g = sns .lineplot (karger_df ['nodes' ], karger_df ['full_contraction_asymptotic' ], label = 'Full Contraction Asintotico: n^2' )
546
546
g .set (xlabel = 'Nodi' , ylabel = 'Tempo (μs)' )
547
- # g.set_xlim(6, 200)
547
+ g .set_xlim (6 , 200 )
548
548
# g.set_yscale('log')
549
549
550
550
plt .title (title )
@@ -557,7 +557,7 @@ def karger_discovery_vs_program_time_chart(dfs):
557
557
558
558
karger_df ['program_time' ] = karger_df ['program_time' ] / 1000.0 # to seconds
559
559
karger_df ['discovery_time' ] = karger_df ['discovery_time' ] / 1000.0 # to seconds
560
-
560
+
561
561
g = sns .lineplot (karger_df ['nodes' ], karger_df ['discovery_time' ], label = f'{ KARGER } (Discovery Time)' )
562
562
g = sns .lineplot (karger_df ['nodes' ], karger_df ['program_time' ], label = f'{ KARGER } (Runtime)' )
563
563
g .set (xlabel = 'Nodi' , ylabel = 'Tempo (s)' )
@@ -570,10 +570,10 @@ def karger_discovery_vs_program_time_chart(dfs):
570
570
def karger_relative_error (dfs ):
571
571
karger_df = dfs [KARGER ].copy ()
572
572
title = f'Errore relativo dell\' output rispetto al numero di nodi'
573
-
573
+
574
574
g = sns .barplot (karger_df ['nodes' ], karger_df ['min_cut_error' ], label = f'${ KARGER } (Errore Relativo)' )
575
575
g .set (xlabel = 'Nodi' , ylabel = 'Errore (%)' )
576
-
576
+
577
577
plt .title (title )
578
578
show_or_save_plot (title )
579
579
@@ -582,7 +582,7 @@ def karger_def_vs_tout_running_time(dfs):
582
582
# create copy to avoid side effect
583
583
karger_def_df = dfs [KARGER ].copy ()
584
584
karger_tout_df = dfs [KARGER_TOUT ].copy ()
585
-
585
+
586
586
# add a column program that represents the program name
587
587
karger_def_df ["program" ] = KARGER
588
588
karger_tout_df ["program" ] = KARGER_TOUT
@@ -599,7 +599,7 @@ def karger_def_vs_tout_running_time(dfs):
599
599
# create the barplot with `hue='program'`
600
600
g = sns .barplot (x = 'nodes' , y = 'program_time' , hue = 'program' , data = df )
601
601
g .set (xlabel = 'Nodi' , ylabel = 'Tempo (min)' )
602
-
602
+
603
603
title = f'Confronto del running time rispetto al numero di nodi per\n { KARGER } e { KARGER_TOUT } '
604
604
605
605
plt .title (title )
@@ -610,7 +610,7 @@ def karger_def_vs_tout_relative_error(dfs):
610
610
# create copy to avoid side effect
611
611
karger_def_df = dfs [KARGER ].copy ()
612
612
karger_tout_df = dfs [KARGER_TOUT ].copy ()
613
-
613
+
614
614
# add a column program that represents the program name
615
615
karger_def_df ["program" ] = KARGER
616
616
karger_tout_df ["program" ] = KARGER_TOUT
@@ -622,7 +622,7 @@ def karger_def_vs_tout_relative_error(dfs):
622
622
# create the barplot with `hue='program'`
623
623
g = sns .barplot (x = 'nodes' , y = 'min_cut_error' , hue = 'program' , data = df )
624
624
g .set (xlabel = 'Nodi' , ylabel = 'Errore (%)' )
625
-
625
+
626
626
title = f'Confronto dell\' errore relativo rispetto al numero di nodi per\n { KARGER } e { KARGER_TOUT } '
627
627
628
628
plt .title (title )
@@ -663,7 +663,7 @@ def karger_runtime(dfs):
663
663
664
664
plt .title (title )
665
665
show_or_save_plot (title )
666
-
666
+
667
667
668
668
def karger_vs_stein_runtime (dfs ):
669
669
karger_df = dfs [KARGER ].copy ()
@@ -725,7 +725,7 @@ def karger_timeout_vs_stein_runtime(dfs):
725
725
# Appendix (runtime): Karger vs KargerTimeout running time (program vs discovery time)
726
726
print_comparison (dataframes_merge , [ KARGER ], ['discovery_time' , 'program_time' ])
727
727
print_comparison (dataframes_merge , [ KARGER_TOUT ], ['discovery_time' , 'program_time' ])
728
-
728
+
729
729
# Appendix (error): Karger vs KargerTimeout approx error
730
730
print_comparison (dataframes_merge , [ KARGER ], ['min_cut' , 'expected_min_cut' , 'min_cut_error' ])
731
731
print_comparison (dataframes_merge , [ KARGER_TOUT ], ['min_cut' , 'expected_min_cut' , 'min_cut_error' ])
@@ -749,7 +749,7 @@ def karger_timeout_vs_stein_runtime(dfs):
749
749
# Q3: For each dataset compare discovery time with algorithm runtime.
750
750
karger_discovery_vs_program_time_chart (dataframes_merge )
751
751
karger_discovery_iter_vs_estimated (dataframes_merge )
752
-
752
+
753
753
# Q4: Output, Expected, Relative Error
754
754
karger_relative_error (dataframes_merge ) # all zeros!
755
755
karger_def_vs_tout_running_time (dataframes_merge )
0 commit comments