Exemplo n.º 1
0
def test_traverse_from_collect_if():
    graphA = CoachingGraph()
    graphA.init_semi_random_connected(100)

    actualA = len(graphA.users)
    network = graphTraverser.get_connected_network(graphA.users[0])
    sizeA = len(network)

    assert sizeA == actualA
Exemplo n.º 2
0
def test_get_subgraphs_connected():
    graph = CoachingGraph()
    graph.init_semi_random_connected(100)
    subgraphs = graphTraverser.get_subgraphs(graph.users)
    combined = []
    for subgraph in subgraphs:
        combined.extend(subgraph)

    assert set(combined) == set(graph.users)
Exemplo n.º 3
0
def test_traverse_from_collect_if():
	graphA = CoachingGraph()
	graphA.init_semi_random_connected(100)

	actualA = len(graphA.users)
	network = graphTraverser.get_connected_network(graphA.users[0])
	sizeA = len(network)

	assert sizeA == actualA
Exemplo n.º 4
0
def test_get_subgraphs_connected():
	graph = CoachingGraph()
	graph.init_semi_random_connected(100)
	subgraphs = graphTraverser.get_subgraphs(graph.users)
	combined = []
	for subgraph in subgraphs:
		combined.extend(subgraph)

	assert set(combined) == set(graph.users)
Exemplo n.º 5
0
def test_infect_limited_infects_correct_number_connected():
	graph = CoachingGraph()
	graph.init_semi_random_connected(200)
	numToInfect = 70
	users = graph.users
	infecter = Infecter()

	infecter.infect_limited(users, numToInfect, 0, False)
	numInfected = infecter.get_num_infected(users)

	assert numInfected == numToInfect
Exemplo n.º 6
0
def test_infect_limited_from():
	graph = CoachingGraph()
	graph.init_semi_random_connected(200)
	numToInfect = 70
	users = graph.users
	user = random.choice(users)
	infecter = Infecter()

	infecter.infect_limited_from(user, numToInfect)
	numInfected = infecter.get_num_infected(users)

	assert numInfected == numToInfect
Exemplo n.º 7
0
def generate_test_graphs_connected(dirName, numGraphs, maxSize):
    logger.info("generating test graphs in directory: {}".format(dirName))
    folderPath = refresh_testData_folder(dirName)

    for i in range(numGraphs):
        graph = CoachingGraph()

        fileNumber = i + 1
        fileName = '{}_'.format(fileNumber) + TEST_GRAPH_SUFFIX

        randomSize = random.randint(40, maxSize)
        graph.init_semi_random_connected(randomSize)

        filePath = os.path.join(folderPath, fileName)
        graph.save_as(filePath)
Exemplo n.º 8
0
def generate_test_graphs_connected(dirName, numGraphs, maxSize):
	logger.info("generating test graphs in directory: {}".format(dirName))
	folderPath = refresh_testData_folder(dirName)

	for i in range(numGraphs):
		graph = CoachingGraph()

		fileNumber = i + 1
		fileName = '{}_'.format(fileNumber) + TEST_GRAPH_SUFFIX

		randomSize = random.randint(40, maxSize)
		graph.init_semi_random_connected(randomSize)

		filePath = os.path.join(folderPath, fileName)
		graph.save_as(filePath)
Exemplo n.º 9
0
def test_init_semi_random_connected():
    graph = CoachingGraph()
    graph.init_semi_random_connected(200)
    numSubgraphs = len(graphTraverser.get_subgraphs(graph.users))

    assert numSubgraphs == 1
Exemplo n.º 10
0
def test_init_semi_random_connected():
	graph = CoachingGraph()
	graph.init_semi_random_connected(200)
	numSubgraphs = len(graphTraverser.get_subgraphs(graph.users))

	assert numSubgraphs == 1