import os from utils import make_ready_for_one_file_simulation source_location = os.path.dirname(os.path.abspath(__file__)) + "/../context" sys.path.insert(0, source_location) source_location = os.path.dirname(os.path.abspath(__file__)) + "/.." sys.path.insert(0, source_location) from aggregation_simulator.utils_configuration import get_test_files_directory, get_configuration from aggregation_simulator.network import Network from aggregation_async_simulator import run_simulation from context_aggregator.utils_same import same test_name1 = "test_network0" d = os.path.join(get_test_files_directory(), test_name1) network_file_path1 = os.path.join(d, test_name1 + ".txt") simulation_root_dir = get_configuration("config.cfg", "TestDirectory", "simple_test_root_dir") network = Network() network.read(network_file_path1) dot_file_path = os.path.join(d, network_file_path1 + ".dot") # # Code duplication from utils.py # def get_test_network(condition, network_name): d = get_test_files_directory() network_file = os.path.join(d, "%s/%s/%s.txt" % (condition, network_name, network_name)) network = Network() network.read(network_file)
def get_test_network(condition, network_name): d = get_test_files_directory() network_file = os.path.join(d, "%s/%s/%s.txt" % (condition, network_name, network_name)) network = Network() network.read(network_file) return network
new_neighbors = new_neighbors[0:goal] diff = set(neighbors) - set(new_neighbors) for d in diff: if len(new_network[d]) == 1: # if this is the only link, don't do anything new_neighbors.append(d) else: print "remove key(%d) from n(%s)" % (key, new_network[d]) new_network[d].remove(key) print "removed key(%d) from n(%s)" % (key, new_network[d]) new_network[key] = new_neighbors print new_network #new_network = Network.make_symmetric_network(self, new_network) n2 = Network(new_network) n2.write(new_network_path) n2.dot_gen(new_network_path + ".dot") def generate_dot(network_file_path): network = Network(network_file_path) dot_file_path = network_file_path + ".dot" network.dot_gen(dot_file_path) if __name__ == "__main__": network_name = "pseudo_realworld_49" network = get_test_files_directory() + os.sep + network_name + os.sep + network_name + ".txt" network_name = "pseudo_realworld_49_2d" new_network = get_test_files_directory() + os.sep + network_name + os.sep + network_name + ".txt" print get_average_network_link(network) generate_dot(new_network) #reduce_average_network_link(network, new_network,3) #print get_average_network_link(new_network)