コード例 #1
0
def multiple_memory_random_wd(node_list=[10, 20, 50, 100, 200, 500],
                              weights="random",
                              positive_cycle_check=None,
                              verbose=False,
                              plot=True):
    """
    Compute and plots memory benchmarks for algorithm wd with a list of graphs
    :param node_list: list of nodes of the graphs on which the benchmark will be run
    :param weights: random | positive
    :param positive_cycle_check: True or False, to enable or skip the check for null cycle weight
    :param verbose: True  [False] to enable [disable] verbosity
    :param plot: True to plot on a graph the memory usages as the number of nodes grows
    :return: dictionary {n_nodes: memory_usage} with memory usages for each different run and n_nodes as key
    """
    memory_usage_dictionary = {}
    for n in node_list:
        memory_usage_dictionary[n] = memory_random_wd(
            n_nodes=n,
            weights=weights,
            positive_cycle_check=positive_cycle_check,
            verbose=verbose)

    if plot:
        plot_dictionary(memory_usage_dictionary)

    if verbose:
        print(memory_usage_dictionary)
    return memory_usage_dictionary
コード例 #2
0
def multiple_memory_random_graph_instantiation(
        node_list=[10, 20, 50, 100, 200, 500],
        p=0.5,
        weights="random",
        positive_cycle_check=True,
        verbose=False,
        plot=True):
    """
    Compute and plots time benchmarks for algorithm opt1 with a list of graphs
    :param node_list: list of nodes of the graphs on which the benchmark will be run
    :param plot: True to plot on a graph the delta values as the number of nodes grows
    :param p: edge probability
    :param weights: random | positive
    :param positive_cycle_check: True or False, to enable or skip the check for null cycle weight
    :param verbose: True  [False] to enable [disable] verbosity
    :return: dictionary {n_nodes: memory_usage} with memory usages for each different run and n_nodes as key
    """
    assert weights == "random" or weights == "positive"
    memory_usage_dictionary = {}
    for n in node_list:
        memory_usage_dictionary[n] = random_graph_instantiation_memory(
            n_nodes=n,
            p=p,
            weights=weights,
            positive_cycle_check=positive_cycle_check,
            verbose=verbose)

    if plot:
        plot_dictionary(memory_usage_dictionary)

    if verbose:
        print(memory_usage_dictionary)
    return memory_usage_dictionary
コード例 #3
0
def multiple_time_random_wd(node_list=[10, 20, 50, 100, 200, 500],
                            weights="random",
                            positive_cycle_check=None,
                            verbose=False,
                            plot=True):
    """
    Compute and plots time benchmarks for algorithm wd with a list of graphs
    :param node_list: list of nodes of the graphs on which the benchmark will be run
    :param weights: random | positive
    :param positive_cycle_check: True or False, to enable or skip the check for null cycle weight
    :param verbose: True  [False] to enable [disable] verbosity
    :param plot: True to plot on a graph the memory usages as the number of nodes grows
    :return:
    """
    delta_times = {}
    for n in node_list:
        delta_times[n] = time_random_wd(
            n_nodes=n,
            weights=weights,
            positive_cycle_check=positive_cycle_check,
            verbose=verbose)

    if plot:
        plot_dictionary(delta_times)

    return delta_times