示例#1
0
def page_rank(
        graph: Matrix, 
        page_rank: Vector,
        damping_factor=0.85,
        threshold=1.e-5,
        max_iters=None):

    if max_iters is None:

        c.algorithm(
                algorithm       = "page_rank",
                graph           = graph,
                page_rank       = page_rank,
                damping_factor  = damping_factor,
                threshold       = threshold,
        )

    else:

        c.algorithm(
                algorithm       = "page_rank",
                graph           = graph,
                page_rank       = page_rank,
                damping_factor  = damping_factor,
                threshold       = threshold,
                max_iters       = max_iters
        )

    return page_rank
示例#2
0
def bfs_level_masked_v2(graph, wavefront, levels):
    c.algorithm(
            algorithm   = "bfs_level_masked_v2",
            graph       = graph,
            wavefront   = wavefront,
            levels      = levels
    )

    return levels
示例#3
0
def mst(graph: Matrix, parents: Vector):

    return c.algorithm(
            algorithm   = "mst",
            graph       = graph,
            parents     = parents
    )
示例#4
0
def vertex_out_degree(graph: Matrix, vid: int):
    return c.algorithm(
            algorithm   = "vertex_out_degree", 
            graph       = graph
    )(      
            vid         = vid
    )
示例#5
0
def triangle_count_newGBTL(l_matrix: Matrix, u_matrix: Matrix):

    return c.algorithm(
            algorithm   = "triangle_count_newGBTL",
            l_matrix    = l_matrix,
            u_matix     = u_matrix
    )
示例#6
0
def sssp(graph: Matrix, path: Vector):

    return c.algorithm(
            algorithm   = "sssp", 
            graph       = graph, 
            path        = path
    )
示例#7
0
def vertex_eccentricity(graph: Matrix, vid: int):

    return c.algorithm(
            algorithm   = "vertex_eccentricity",
            graph       = graph
    )(
            vid         = vid
    )
示例#8
0
def bfs(graph: Matrix, wavefront: Vector, parent_list=None):
    if not isinstance(wavefront, Vector):
        print("creating wavefront")
        w = [0] * graph.shape[1]
        w[wavefront] = 1
        wavefront = Vector(w)

    if parent_list is None:
        print("creating parent_list")
        parent_list = Vector([0] * graph.shape[1])

    c.algorithm(
            algorithm   = "bfs",
            graph       = graph,
            wavefront   = wavefront,
            parent_list = parent_list
    )
示例#9
0
def closeness_centrality(graph: Matrix, vid: int):

    return c.algorithm(
            algorithm   = "closeness_centrality",
            graph       = graph
    )(
            vid         = vid
    )
示例#10
0
def bfs_batch(graph: Matrix, wavefronts: Matrix, parent_list=None):
    # TODO
    #if not isinstance(wavefront, Matrix):
    #    w = [0] * graph.shape[1]
    #    w[wavefront] = 1
    #    wavefront = Vector(w)

    if parent_list is None:
        parent_list = Matrix(shape=graph.shape, dtype=graph.dtype)

    c.algorithm(
            algorithm   = "bfs_batch",
            graph       = graph,
            wavefronts  = wavefronts,
            parent_list = parent_list
    )

    return parent_list
示例#11
0
def mis(graph: Matrix, independent_set: Vector, seed: int = 0):

    return c.algorithm(
            algorithm       = "mis",
            graph           = graph,
            independent_set = independent_set
    )(
            seed            = seed        
    )
示例#12
0
def maxflow(capacity: Matrix, source: int, sink: int):

    return c.algorithm(
            algorithm   = "maxflow",
            capacity    = capacity
    )(
            source      = source,
            sink        = sink
    )
示例#13
0
def graph_distance_matrix(graph: Matrix, result: Matrix = None):

    if result is None:
        result = Matrix(shape=graph.shape, dtype=graph.dtype)

    return c.algorithm(
            algorithm   = "graph_distance", 
            graph       = graph,
            result      = result,
    )
示例#14
0
def graph_distance(graph: Matrix, sid: int, result: Vector=None):

    if result is None:
        result = Vector(shape=graph.shape[0], dtype=graph.dtype)

    return c.algorithm(
            algorithm   = "graph_distance", 
            graph       = graph,
            result      = result,
    )(
            sid         = sid
    )
示例#15
0
def graph_radius(graph: Matrix):

    return c.algorithm(
            algorithm   = "graph_radius",
            graph       = graph
    )
示例#16
0
def graph_diameter(graph: Matrix):

    return c.algorithm(
            algorithm   = "graph_diameter",
            graph       = graph
    )
示例#17
0
def get_vertex_IDs(independent_set: Matrix):

    return c.algorithm(
            algorithm       = "get_vertex_IDs",
            independent_set = independent_set
    )
示例#18
0
def triangle_count(graph: Matrix):
    return c.algorithm(
            algorithm   = "triangle_count",
            graph       = graph
    )
示例#19
0
def triangle_count_masked(graph: Matrix):
    return c.algorithm(
            algorithm   = "triangle_count_masked",
            graph       = graph
    )