def test_betweeness_centrality_16(self): """ params = [depth、sample、top、source_sample、degree、direction] :return: """ body = { "depth": 5, "degree": 50, "sample": -1, "top": 10, "source_sample": -1, "direction": "IN" } code, res = Algorithm().post_betweeness_centrality(body, auth=auth) id = res["task_id"] if id > 0: result = get_task_res(id, 120, auth=auth) print(result) assert result == { '1:vadas': 4.0, '1:peter': 4.0, '2:ripple': 2.0, '2:lop': 2.0, '1:marko': 0.0, '1:josh': 0.0 } else: assert 0
def test_closeness_centrality_17(self): """ param=[depth, degree, sample, top, source_sample, direction] :return: """ body = { "depth": 5, "degree": 50, "sample": -1, "top": 10, "source_sample": -1, "direction": "OUT" } code, res = Algorithm().post_closeness_centrality(body, auth=auth) id = res["task_id"] if id > 0: result = get_task_res(id, 120, auth=auth) print(result) assert result == { '1:marko': 3.5, '1:peter': 2.0, '2:lop': 1.0, '2:ripple': 0.0, '1:josh': 0.0, '1:vadas': 0.0 } else: assert 0
def test_eigenvector_centrality_19(self): """ param = [depth, sample, top, degree, source_sample, direction, label] :return: """ body = { "depth": 5, "degree": 50, "sample": -1, "top": 10, "source_sample": 10, "direction": "BOTH", "label": "created" } code, res = Algorithm().post_eigenvector_centrality(body, auth=auth) id = res["task_id"] if id > 0: result = get_task_res(id, 120, auth=auth) print(result) assert result == { '2:ripple': 3, '1:marko': 3, '1:peter': 3, '1:josh': 1, '1:vadas': 1, '2:lop': 1 } else: assert 0
def test_stressCentrality_01(self): """ :return: """ body = {"depth": 10} code, res = Algorithm().post_stress_centrality(body, auth=auth) id = res["task_id"] if id > 0: result = get_task_res(id, 120, auth=auth) print(result) assert result == { '1:marko': 8, '1:josh': 8, '1:o': 8, '1:peter': 0, '2:p': 8, '1:r': 0, '1:s': 0, '1:wang': 0, '1:qian': 0, '2:ripple': 0, '1:li': 0, '1:vadas': 0, '2:zhao': 0, '2:lop': 8, '2:e': 0, '1:h': 8 } else: assert 0
def test_kcore_04(self): """ :return: """ body = {"direction": "IN", "k": 2} code, res = Algorithm().post_kcore(body, auth=auth) id = res["task_id"] if id > 0: result = get_task_res(id, 300, auth=auth) print(result) assert result == {'kcores': []} else: assert 0
def test_lpa_05(self): """ :return: """ body = {"direction": "IN", "workers": 0} code, res = Algorithm().post_lpa(body, auth=auth) id = res["task_id"] if id > 0: result = get_task_res(id, 120, auth=auth) print(result) assert result else: assert 0
def test_lpa_01(self): """ :return: """ body = {} code, res = Algorithm().post_lpa(body, auth=auth) id = res["task_id"] if id > 0: result = get_task_res(id, 120, auth=auth) print(result) assert result else: assert 0
def test_rings_detect_03(self): """ :return: """ body = {"depth": 5, "limit": 3} code, res = Algorithm().post_rings_detect(body, auth=auth) id = res["task_id"] if id > 0: result = get_task_res(id, 120, auth=auth) print(result) assert len(result['rings']) == 3 else: assert 0
def test_lpa_11(self): """ :return: """ body = {"source_label": "person", "workers": 0} code, res = Algorithm().post_lpa(body, auth=auth) id = res["task_id"] if id > 0: result = get_task_res(id, 120, auth=auth) print(result) assert result else: assert 0
def test_rings_detect_20(self): """ param = [depth, count_only, workers] :return: """ body = {"depth": 5, "count_only": True, "workers": 10} code, res = Algorithm().post_rings_detect(body, auth=auth) id = res["task_id"] if id > 0: result = get_task_res(id, 120, auth=auth) print(result) assert result['rings_count'] == 18 else: assert 0
def test_rings_detect_17(self): """ param = [depth, direction, degree, workers] :return: """ body = {"direction": "BOTH", "depth": 5, "degree": 50, "workers": 0} code, res = Algorithm().post_rings_detect(body, auth=auth) id = res["task_id"] if id > 0: result = get_task_res(id, 120, auth=auth) print(result) assert len(result['rings']) == 18 else: assert 0
def test_rings_detect_08(self): """ param = [depth, capacity] :return: """ body = {"depth": 5, "capacity": 50} code, res = Algorithm().post_rings_detect(body, auth=auth) id = res["task_id"] if id > 0: result = get_task_res(id, 120, auth=auth) print(result) assert len(result['rings']) == 18 else: assert 0
def test_count_edge(self): """ 统计边信息接口 :return: """ body = {} code, res = Algorithm().post_count_edge(body, auth=auth) id = res["task_id"] if id > 0: result = get_task_res(id, 120, auth=auth) print(result) assert result == {'created': 8, '*': 13, 'knows': 5} else: assert 0
def test_kcore_01(self): """ 无参数 :return: """ body = {} code, res = Algorithm().post_kcore(body, auth=auth) id = res["task_id"] if id > 0: result = get_task_res(id, 300, auth=auth) print(result) assert result == {'kcores': []} else: assert 0
def test_degree_centrality_02(self): """ param = [label] :return: """ body = {"label": "created"} code, res = Algorithm().post_degree_centrality(body, auth=auth) id = res["task_id"] if id > 0: result = get_task_res(id, 120, auth=auth) print(result) assert result == {'1:marko': 1, '1:peter': 1, '2:ripple': 2} else: assert 0
def test_degree_centrality_06(self): """ param = [direction] :return: """ body = {"direction": "IN"} code, res = Algorithm().post_degree_centrality(body, auth=auth) id = res["task_id"] if id > 0: result = get_task_res(id, 120, auth=auth) print(result) assert result == {'1:josh': 1, '1:peter': 1, '1:vadas': 1, '2:ripple': 3} else: assert 0
def test_triangle_count_04(self): """ param = [direction, degree] :return: """ body = {"direction": "OUT"} code, res = Algorithm().post_triangle_count(body, auth=auth) id = res["task_id"] if id > 0: result = get_task_res(id, 120, auth=auth) print(result) assert result == {'edges_out': 13, 'vertices_out': 7, 'triangles': 2} else: assert 0
def test_degree_centrality_08(self): """ param = [top] :return: """ body = {"top": 5} code, res = Algorithm().post_degree_centrality(body, auth=auth) id = res["task_id"] if id > 0: result = get_task_res(id, 120, auth=auth) print(result) assert result == {'2:ripple': 3, '1:marko': 3, '1:peter': 3, '1:josh': 1, '1:vadas': 1} else: assert 0
def test_degree_centrality_03(self): """ param = [label] :return: """ body = {"label": "knows"} code, res = Algorithm().post_degree_centrality(body, auth=auth) id = res["task_id"] if id > 0: result = get_task_res(id, 120, auth=auth) print(result) assert result == {'1:josh': 1, '1:marko': 2, '1:peter': 2, '1:vadas': 1} else: assert 0
def test_rings_detect_02(self): """ param = [depth, source_label] :return: """ body = {"depth": 5, "source_label": "男人"} code, res = Algorithm().post_rings_detect(body, auth=auth) id = res["task_id"] if id > 0: result = get_task_res(id, 120, auth=auth) print(result) assert len(result['rings']) == 8 else: assert 0
def test_degree_centrality_05(self): """ param = [direction] :return: """ body = {"direction": "OUT"} code, res = Algorithm().post_degree_centrality(body, auth=auth) id = res["task_id"] if id > 0: result = get_task_res(id, 120, auth=auth) print(result) assert result == {'2:lop': 1, '1:marko': 3, '1:peter': 2} else: assert 0
def test_rings_detect_04(self): """ param = [depth, direction] :return: """ body = {"depth": 5, "direction": "IN"} code, res = Algorithm().post_rings_detect(body, auth=auth) id = res["task_id"] if id > 0: result = get_task_res(id, 120, auth=auth) print(result) assert len(result['rings']) == 0 else: assert 0
def test_degree_centrality_12(self): """ param = [top、direction、label] :return: """ body = {"direction": "OUT", "top": 5, "label": "created"} code, res = Algorithm().post_degree_centrality(body, auth=auth) id = res["task_id"] if id > 0: result = get_task_res(id, 120, auth=auth) print(result) assert result == {'1:marko': 1, '1:peter': 1} else: assert 0
def test_count_vertex(self): """ 统计顶点信息接口 :return: """ body = {} code, res = Algorithm().post_count_vertex(body, auth=auth) id = res["task_id"] if id > 0: result = get_task_res(id, 120, auth=auth) print(result) assert result == {'software': 5, 'person': 11, '*': 16} else: assert 0
def test_betweeness_centrality_12(self): """ params = [depth、sample、top] :return: """ body = {"depth": 5, "sample": -1, "top": 3} code, res = Algorithm().post_betweeness_centrality(body, auth=auth) id = res["task_id"] if id > 0: result = get_task_res(id, 120, auth=auth) print(result) assert result == {'1:vadas': 9.0, '1:peter': 9.0, '2:ripple': 4.0} else: assert 0
def test_eigenvector_centrality_03(self): """ param = [depth, source_sample] :return: """ body = {"depth": 5, "source_sample": 2} code, res = Algorithm().post_eigenvector_centrality(body, auth=auth) id = res["task_id"] if id > 0: result = get_task_res(id, 120, auth=auth) print(result) assert 1 # assert result == {'2:ripple': 2, '1:peter': 1, '2:lop': 1} else: assert 0
def test_eigenvector_centrality_01(self): """ param = [depth] :return: """ body = {"depth": 5} code, res = Algorithm().post_eigenvector_centrality(body, auth=auth) id = res["task_id"] if id > 0: result = get_task_res(id, 120, auth=auth) print(result) assert 1 # assert result == {'2:ripple': 3, '1:marko': 4, '1:josh': 2, '1:vadas': 3, '1:peter': 4, '2:lop': 3} else: assert 0
def test_kcore_13(self): """ :return: """ body = {"merged": True, "k": 2} code, res = Algorithm().post_kcore(body, auth=auth) id = res["task_id"] if id > 0: result = get_task_res(id, 300, auth=auth) print(result) assert result == { 'kcores': [['2:ripple', '1:marko', '1:josh', '1:vadas', '2:lop']] } else: assert 0
def test_pageRank_01(self): """ :return: """ body = {} code, res = Algorithm().post_page_rank(body, auth=auth) id = res["task_id"] if id > 0: result = get_task_res(id, 120, auth=auth) print(result) rank_code, rank_res = Gremlin().gremlin_post("g.V('1:marko')") print(rank_code, rank_res) assert result['last_changed_rank'] == 0.00015807441539228417 and \ rank_res['result']['data'][0]['properties']['r_rank'] == 0.05084635172453192 else: assert 0
def test_weakConnectedComponent_01(self): """ :return: """ body = {} code, res = Algorithm().post_weak_connected_component(body, auth=auth) id = res["task_id"] if id > 0: result = get_task_res(id, 120, auth=auth) print(result) assert result == { 'components': 5, 'iteration_times': 1, 'times': 20 } else: assert 0