import math
import random


def prepare_data_for_graph_classification(datalist, train_ratio=0.6, rnd_labeled_graphs=True):
    """Split the graphs in training and testing based in train_ratio.
    rnd_labeled_graphs=True means that the graphs in the batch that are used for training are choosen at random
    (at each epoch, for the same batch, different graphs are used for training)."""
    num_train_examples = math.floor(len(datalist)*train_ratio)
    if rnd_labeled_graphs:
        random.shuffle(datalist)
    train_list = datalist[:num_train_examples]
    test_list = datalist[num_train_examples:]
    return train_list, test_list