Beispiel #1
0
def main():
    import argparse

    import katana.local
    from katana.galois import set_active_threads

    katana.local.initialize()

    parser = argparse.ArgumentParser()
    parser.add_argument("--startNode", type=int, default=0)
    parser.add_argument("--propertyName", type=str, default="NewProperty")
    parser.add_argument("--reportNode", type=int, default=1)
    parser.add_argument("--noverify", action="store_true", default=False)
    parser.add_argument("--threads", "-t", type=int, default=1)
    parser.add_argument("input", type=str)

    args = parser.parse_args()

    print("Using threads:", set_active_threads(args.threads))

    graph = PropertyGraph(args.input)

    bfs_sync_pg(graph, args.startNode, args.propertyName)

    print("Node {}: {}".format(
        args.reportNode,
        graph.get_node_property(args.propertyName)[args.reportNode]))

    if not args.noverify:
        numNodeProperties = len(graph.node_schema())
        newPropertyId = numNodeProperties - 1
        verify_bfs(graph, args.startNode, newPropertyId)
Beispiel #2
0
def main():
    import argparse

    parser = argparse.ArgumentParser()
    parser.add_argument("--startNode", type=int, default=0)
    parser.add_argument("--propertyName", type=str, default="NewProperty")
    parser.add_argument("--edgeWeightProperty", type=str, required=True)
    parser.add_argument("--shift", type=int, default=6)
    parser.add_argument("--reportNode", type=int, default=1)
    parser.add_argument("--noverify", action="store_true", default=False)
    parser.add_argument("--threads", "-t", type=int, default=1)
    parser.add_argument("input", type=str)
    args = parser.parse_args()

    print("Using threads:", setActiveThreads(args.threads))

    graph = PropertyGraph(args.input)

    sssp(graph, args.startNode, args.edgeWeightProperty, args.shift,
         args.propertyName)

    print("Node {}: {}".format(
        args.reportNode,
        graph.get_node_property(args.propertyName)[args.reportNode]))

    if not args.noverify:
        numNodeProperties = len(graph.node_schema())
        newPropertyId = numNodeProperties - 1
        verify_sssp(graph, args.startNode, newPropertyId)
Beispiel #3
0
def main():
    import argparse

    parser = argparse.ArgumentParser()
    parser.add_argument("--algoType", type=str, default="push")
    parser.add_argument("--propertyName", type=str, default="NewProperty")
    parser.add_argument("--reportNode", type=int, default=1)
    parser.add_argument("--noverify", action="store_true", default=False)
    parser.add_argument("--threads", "-t", type=int, default=1)
    parser.add_argument("input", type=str)
    args = parser.parse_args()

    print("Using threads:", setActiveThreads(args.threads))

    graph = PropertyGraph(args.input)

    if args.algoType == "push":
        cc_push_topo(graph, args.propertyName)
    else:
        cc_pull_topo(graph, args.propertyName)

    print("Node {}: {}".format(
        args.reportNode,
        graph.get_node_property(args.propertyName)[args.reportNode]))

    if not args.noverify:
        numNodeProperties = len(graph.node_schema())
        newPropertyId = numNodeProperties - 1
        verify_cc(graph, newPropertyId)
Beispiel #4
0
def test_commit(property_graph):
    # TODO(amp): mark_all_properties_persistent shouldn't be required. Why is it?
    property_graph.mark_all_properties_persistent()
    with TemporaryDirectory() as tmpdir:
        property_graph.path = tmpdir
        property_graph.write()
        del property_graph
        property_graph = PropertyGraph(tmpdir)
    assert property_graph.num_nodes() == 29092
    assert property_graph.num_edges() == 39283
    assert len(property_graph.node_schema()) == 31
    assert len(property_graph.edge_schema()) == 19
Beispiel #5
0
def test_bfs(property_graph: PropertyGraph):
    start_node = 0
    property_name = "NewProp"

    bfs_sync_pg(property_graph, start_node, property_name)

    num_node_properties = len(property_graph.node_schema())
    new_property_id = num_node_properties - 1
    verify_bfs(property_graph, start_node, new_property_id)

    stats = BfsStatistics(property_graph, property_name)
    assert stats.n_reached_nodes == 752
Beispiel #6
0
def test_betweenness_centrality_level(property_graph: PropertyGraph):
    property_name = "NewProp"

    betweenness_centrality(property_graph, property_name, 16, BetweennessCentralityPlan.level())

    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

    stats = BetweennessCentralityStatistics(property_graph, property_name)

    assert stats.min_centrality == 0
    assert stats.max_centrality == approx(8210.38)
    assert stats.average_centrality == approx(1.3645)
Beispiel #7
0
def test_bfs(property_graph: PropertyGraph):
    start_node = 0
    property_name = "NewProp"

    bfs_sync_pg(property_graph, start_node, property_name)

    num_node_properties = len(property_graph.node_schema())
    new_property_id = num_node_properties - 1
    verify_bfs(property_graph, start_node, new_property_id)

    stats = BfsStatistics(property_graph, property_name)

    assert stats.source_node == start_node
    assert stats.max_distance == 7

    bfs_assert_valid(property_graph, property_name)
Beispiel #8
0
def test_pagerank(property_graph: PropertyGraph):
    property_name = "NewProp"

    pagerank(property_graph, 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

    pagerank_assert_valid(property_graph, property_name)

    stats = PagerankStatistics(property_graph, property_name)

    assert stats.min_rank == approx(0.1499999761581421)
    assert stats.max_rank == approx(1328.6629638671875, abs=0.06)
    assert stats.average_rank == approx(0.5205338001251221, abs=0.001)
Beispiel #9
0
def test_bfs(property_graph: PropertyGraph):
    property_name = "NewProp"
    start_node = 0

    bfs(property_graph, start_node, 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

    bfs_assert_valid(property_graph, property_name)

    stats = BfsStatistics(property_graph, property_name)

    assert stats.source_node == start_node
    assert stats.max_distance == 7

    # Verify with numba implementation of verifier as well
    verify_bfs(property_graph, start_node, new_property_id)
Beispiel #10
0
def test_busy_wait(property_graph: PropertyGraph):
    set_busy_wait()
    property_name = "NewProp"
    start_node = 0

    bfs(property_graph, start_node, 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

    bfs_assert_valid(property_graph, start_node, property_name)

    BfsStatistics(property_graph, property_name)

    # Verify with numba implementation of verifier as well
    verify_bfs(property_graph, start_node, new_property_id)
    set_busy_wait(0)
Beispiel #11
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)
Beispiel #12
0
def test_jaccard(property_graph: PropertyGraph):
    property_name = "NewProp"
    compare_node = 0

    jaccard(property_graph, compare_node, 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

    jaccard_assert_valid(property_graph, compare_node, property_name)

    stats = JaccardStatistics(property_graph, compare_node, property_name)

    assert stats.max_similarity == approx(1)
    assert stats.min_similarity == approx(0)
    assert stats.average_similarity == approx(0.000637853)

    similarities: np.ndarray = property_graph.get_node_property(property_name).to_numpy()
    assert similarities[compare_node] == 1
    assert similarities[1917] == approx(0.28571428)
    assert similarities[2812] == approx(0.01428571)
Beispiel #13
0
def check_schema(property_graph: PropertyGraph, 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