예제 #1
0
def run_sssp(property_graph: PropertyGraph, input_args, source_node_file):
    property_name = "NewProp"
    start_node = input_args["source_node"]
    edge_prop_name = input_args["edge_wt"]

    sssp_plan = analytics.SsspPlan.delta_step(input_args["sssp_delta"])
    if "kron" in input_args["name"] or "urand" in input_args["name"]:
        sssp_plan = analytics.SsspPlan.delta_step_fusion(
            input_args["sssp_delta"])

    if not source_node_file == "":
        if not os.path.exists(source_node_file):
            print(f"Source node file doesn't exist: {source_node_file}")
        with open(source_node_file, "r") as fi:
            sources = [int(l) for l in fi.readlines()]

        for source in sources:
            with time_block(f"sssp on {source}"):
                analytics.sssp(property_graph, source, edge_prop_name,
                               property_name, sssp_plan)

            check_schema(property_graph, property_name)

            analytics.sssp_assert_valid(property_graph, source, edge_prop_name,
                                        property_name)

            stats = analytics.SsspStatistics(property_graph, property_name)
            print(f"STATS:\n{stats}")
            property_graph.remove_node_property(property_name)

    else:
        with time_block("sssp"):
            analytics.sssp(property_graph, start_node, edge_prop_name,
                           property_name, sssp_plan)

        check_schema(property_graph, property_name)

        analytics.sssp_assert_valid(property_graph, start_node, edge_prop_name,
                                    property_name)

        stats = analytics.SsspStatistics(property_graph, property_name)
        print(f"STATS:\n{stats}")
        property_graph.remove_node_property(property_name)
예제 #2
0
def test_sssp(property_graph: PropertyGraph):
    property_name = "NewProp"
    weight_name = "workFrom"
    start_node = 0

    sssp(property_graph, start_node, weight_name, property_name)

    node_schema: Schema = property_graph.node_schema()
    num_node_properties = len(node_schema)
    new_property_id = num_node_properties - 1
    assert node_schema.names[new_property_id] == property_name

    assert property_graph.get_node_property(
        property_name)[start_node].as_py() == 0

    sssp_assert_valid(property_graph, start_node, weight_name, property_name)

    stats = SsspStatistics(property_graph, property_name)

    print(stats)
    assert stats.max_distance == 2011.0

    # Verify with numba implementation of verifier
    verify_sssp(property_graph, start_node, new_property_id)