def test_leiden_clustering(): graph = Graph(get_input("propertygraphs/rmat10_symmetric")) leiden_clustering(graph, "value", "output") leiden_clustering_assert_valid(graph, "value", "output") LeidenClusteringStatistics(graph, "value", "output")
def test_triangle_count_presorted(): graph = Graph(get_input("propertygraphs/rmat15_cleaned_symmetric")) sort_nodes_by_degree(graph) sort_all_edges_by_dest(graph) n = triangle_count( graph, TriangleCountPlan.node_iteration(relabeling=False, edges_sorted=True)) assert n == 282617
def test_k_truss_fail(): graph = Graph(get_input("propertygraphs/rmat10_symmetric")) with raises(GaloisError): k_truss(graph, 2, "output") with raises(GaloisError): k_truss(graph, 1, "output2")
def test_local_clustering_coefficient(): graph = Graph(get_input("propertygraphs/rmat15_cleaned_symmetric")) local_clustering_coefficient(graph, "output") graph: Graph out = graph.get_node_property("output") assert out[-1].as_py() == 0 assert not np.any(np.isnan(out))
def test_k_truss(): graph = Graph(get_input("propertygraphs/rmat10_symmetric")) k_truss(graph, 10, "output") stats = KTrussStatistics(graph, 10, "output") assert stats.number_of_edges_left == 13338 k_truss_assert_valid(graph, 10, "output")
def test_k_core(): graph = Graph(get_input("propertygraphs/rmat10_symmetric")) k_core(graph, 10, "output") stats = KCoreStatistics(graph, 10, "output") assert stats.number_of_nodes_in_kcore == 438 k_core_assert_valid(graph, 10, "output")
def test_connected_components(): graph = Graph(get_input("propertygraphs/rmat10_symmetric")) connected_components(graph, "output") stats = ConnectedComponentsStatistics(graph, "output") assert stats.total_components == 69 assert stats.total_non_trivial_components == 1 assert stats.largest_component_size == 956 assert stats.largest_component_ratio == approx(0.933594) connected_components_assert_valid(graph, "output")
def test_independent_set(): graph = Graph(get_input("propertygraphs/rmat10_symmetric")) independent_set(graph, "output") IndependentSetStatistics(graph, "output") independent_set_assert_valid(graph, "output") independent_set(graph, "output2", IndependentSetPlan.pull()) IndependentSetStatistics(graph, "output2") independent_set_assert_valid(graph, "output2")
def get_default_args(): arguments = { "json_output": "", "input_dir": get_input("propertygraphs/"), "graph": "rmat15", "app": "all", "source_nodes": "", "trails": 1, "num_sources": 4, "thread_spin": False, "threads": None, } return arguments
def test_subgraph_extraction(): graph = Graph(get_input("propertygraphs/rmat15_cleaned_symmetric")) sort_all_edges_by_dest(graph) nodes = [1, 3, 11, 120] expected_edges = [[ nodes.index(graph.get_edge_dest(e)) for e in graph.edge_ids(i) if graph.get_edge_dest(e) in nodes ] for i in nodes] pg = subgraph_extraction(graph, nodes) assert isinstance(pg, Graph) assert len(pg) == len(nodes) assert pg.num_edges() == 6 for i, _ in enumerate(expected_edges): assert len(pg.edge_ids(i)) == len(expected_edges[i]) assert [pg.get_edge_dest(e) for e in pg.edge_ids(i)] == expected_edges[i]
def test_triangle_count(): graph = Graph(get_input("propertygraphs/rmat15_cleaned_symmetric")) original_first_edge_list = [ graph.get_edge_dest(e) for e in graph.edge_ids(0) ] n = triangle_count(graph) assert n == 282617 n = triangle_count(graph, TriangleCountPlan.node_iteration()) assert n == 282617 n = triangle_count(graph, TriangleCountPlan.edge_iteration()) assert n == 282617 assert [graph.get_edge_dest(e) for e in graph.edge_ids(0)] == original_first_edge_list sort_all_edges_by_dest(graph) n = triangle_count(graph, TriangleCountPlan.ordered_count(edges_sorted=True)) assert n == 282617
def pg_rmat15_cleaned_symmetric(): katana.local.initialize() pg = Graph(get_input("propertygraphs/rmat15_cleaned_symmetric")) return pg
def graph(): g = Graph(get_input("propertygraphs/ldbc_003")) return g