def run_tc(property_graph: PropertyGraph, _input_args): analytics.sort_all_edges_by_dest(property_graph) tc_plan = analytics.TriangleCountPlan.ordered_count(edges_sorted=True) with time_block("triangle counting"): n = analytics.triangle_count(property_graph, tc_plan) print(f"STATS:\nNumber of Triangles: {n}")
def test_triangle_count_presorted(): property_graph = PropertyGraph( get_input("propertygraphs/rmat15_cleaned_symmetric")) sort_nodes_by_degree(property_graph) sort_all_edges_by_dest(property_graph) n = triangle_count( property_graph, TriangleCountPlan.node_iteration(relabeling=False, edges_sorted=True)) assert n == 282617
def test_triangle_count(): property_graph = PropertyGraph( get_input("propertygraphs/rmat15_cleaned_symmetric")) original_first_edge_list = [ property_graph.get_edge_dest(e) for e in property_graph.edges(0) ] n = triangle_count(property_graph) assert n == 282617 n = triangle_count(property_graph, TriangleCountPlan.node_iteration()) assert n == 282617 n = triangle_count(property_graph, TriangleCountPlan.edge_iteration()) assert n == 282617 assert [property_graph.get_edge_dest(e) for e in property_graph.edges(0)] == original_first_edge_list sort_all_edges_by_dest(property_graph) n = triangle_count(property_graph, TriangleCountPlan.ordered_count(edges_sorted=True)) assert n == 282617