示例#1
0
def calc_random_walks(graph_file, directed=False, max_depth=None):
    """
    compute random walks for each nodes in 'start_vertices'

    parameters
    ----------
    G : cuGraph.Graph or networkx.Graph
        The graph can be either directed (DiGraph) or undirected (Graph).
        Weights in the graph are ignored.
        Use weight parameter if weights need to be considered
        (currently not supported)

    start_vertices : int or list or cudf.Series
        A single node or a list or a cudf.Series of nodes from which to run
        the random walks

    max_depth : int
        The maximum depth of the random walks


    Returns
    -------
    random_walks_edge_lists : cudf.DataFrame
        GPU data frame containing all random walks sources identifiers,
        destination identifiers, edge weights

    seeds_offsets: cudf.Series
        Series containing the starting offset in the returned edge list
        for each vertex in start_vertices.
    """
    G = utils.generate_cugraph_graph_from_file(graph_file,
                                               directed=directed,
                                               edgevals=True)
    assert G is not None

    k = random.randint(1, 10)
    start_vertices = random.sample(range(G.number_of_vertices()), k)
    df, offsets = cugraph.random_walks(G, start_vertices, max_depth)

    return df, offsets, start_vertices
示例#2
0
def test_enable_batch_view_then_context(graph_file, directed, mg_device_count):
    gc.collect()
    skip_if_not_enough_devices(mg_device_count)
    G = utils.generate_cugraph_graph_from_file(graph_file, directed)

    assert G.batch_adjlists is None
    G.view_adj_list()
    assert G.batch_adjlists is None

    assert G.batch_transposed_adjlists is None
    G.view_transposed_adj_list()
    assert G.batch_transposed_adjlists is None

    with MGContext(number_of_devices=mg_device_count, p2p=True):
        assert G.batch_enabled is False, "Internal property should be False"
        G.enable_batch()
        assert G.batch_enabled is True, "Internal property should be True"
        assert G.batch_edgelists is not None, ("The graph should have "
                                               "been created with an "
                                               "edgelist")
        assert G.batch_adjlists is not None
        assert G.batch_transposed_adjlists is not None
def test_enable_batch_no_context_view_adj(graph_file, directed,
                                          mg_device_count):
    skip_if_not_enough_devices(mg_device_count)
    G = utils.generate_cugraph_graph_from_file(graph_file, directed)
    assert G.batch_enabled is False, "Internal property should be False"
    G.view_adj_list()
def test_enable_batch_no_context(graph_file, directed, mg_device_count):
    skip_if_not_enough_devices(mg_device_count)
    G = utils.generate_cugraph_graph_from_file(graph_file, directed)
    assert G.batch_enabled is False, "Internal property should be False"
    with pytest.raises(Exception):
        G.enable_batch()
示例#5
0
def test_enable_batch_no_context_view_adj(graph_file, directed, dask_client):
    gc.collect()
    G = utils.generate_cugraph_graph_from_file(graph_file, directed)
    assert G.batch_enabled is False, "Internal property should be False"
    G.view_adj_list()
示例#6
0
def test_enable_batch_no_context(graph_file, directed):
    gc.collect()
    G = utils.generate_cugraph_graph_from_file(graph_file, directed)
    assert G.batch_enabled is False, "Internal property should be False"
    with pytest.raises(Exception):
        G.enable_batch()