# Path: PW_explorer/helper.py
# def mkdir_p(path):
#     """Make a directory if it doesn't already exist"""
#     try:
#         os.makedirs(path)
#     except OSError as exc:  # Python >2.5
#         if exc.errno == errno.EEXIST and os.path.isdir(path):
#             pass
#         else:
#             raise


from sklearn.cluster import DBSCAN
from ..helper import mkdir_p
from collections import defaultdict
import matplotlib.pyplot as plt
import os

    db = DBSCAN(metric='precomputed', eps=0.5, min_samples=1)
    labels = db.fit_predict(dist_matrix)

    unique_indices = {}
    label_counts = {}
    for i, label in enumerate(labels):
        if label not in unique_indices:
            unique_indices[label] = i
            label_counts[label] = 1
        else:
            label_counts[label] += 1

    df = dfs['col_2']

    figs = []
    for label, idx in list(unique_indices.items()):
        fig, ax = plt.subplots()
        cols = get_colors_list(df, idx + 1)
        # print(cols)
        group_size = [1 for _ in cols]
        ax.pie(group_size, colors=cols)
        my_circle = plt.Circle((0, 0), 0.7, color='white')
        p = plt.gcf()
        p.gca().add_artist(my_circle)
        ax.annotate(str(label_counts[label]), xy=(0, 0), ha='center', va='center', fontsize=35)
        figs.append(fig)

    if save_to_folder is not None:
        output_folder = os.path.join(save_to_folder, 'four_colorability_visualization')

# Path: PW_explorer/helper.py
# def mkdir_p(path):
#     """Make a directory if it doesn't already exist"""
#     try:
#         os.makedirs(path)
#     except OSError as exc:  # Python >2.5
#         if exc.errno == errno.EEXIST and os.path.isdir(path):
#             pass
#         else:
#             raise


# Path: PW_explorer/Custom_Visualization_Functions/four_colorability_visualization.py
from sklearn.cluster import DBSCAN
from ..helper import mkdir_p
from collections import defaultdict
import matplotlib.pyplot as plt
import os


    db = DBSCAN(metric='precomputed', eps=0.5, min_samples=1)
    labels = db.fit_predict(dist_matrix)

    unique_indices = {}
    label_counts = {}
    for i, label in enumerate(labels):
        if label not in unique_indices:
            unique_indices[label] = i
            label_counts[label] = 1
        else:
            label_counts[label] += 1

    df = dfs['col_2']

    figs = []
    for label, idx in list(unique_indices.items()):
        fig, ax = plt.subplots()
        cols = get_colors_list(df, idx + 1)
        # print(cols)
        group_size = [1 for _ in cols]
        ax.pie(group_size, colors=cols)
        my_circle = plt.Circle((0, 0), 0.7, color='white')
        p = plt.gcf()
        p.gca().add_artist(my_circle)
        ax.annotate(str(label_counts[label]), xy=(0, 0), ha='center', va='center', fontsize=35)
        figs.append(fig)

    if save_to_folder is not None:
        output_folder = os.path.join(save_to_folder, 'four_colorability_visualization')

        mkdir_p(output_folder)