def voterank(graph, num_of_nodes=0): """Evalute VoteRank on a graph. Args: graph (:class:`graphscope.Graph`): A simple graph. num_of_nodes (unsigned long int, optional): Number of ranked nodes to extract. Default all nodes. Returns: :voterank : list Ordered list of computed seeds. Only nodes with positive number of votes are returned. Examples: .. code:: python >>> import graphscope >>> from graphscope.dataset import load_p2p_network >>> sess = graphscope.session(cluster_type="hosts", mode="eager") >>> g = load_p2p_network(sess) >>> # project to a simple graph (if needed) >>> pg = g.project(vertices={"host": ["id"]}, edges={"connect": ["dist"]}) >>> c = graphscope.voterank(pg, num_of_nodes=10) >>> sess.close() """ num_of_nodes = int(num_of_nodes) c = AppAssets(algo="voterank", context="vertex_data")(graph, num_of_nodes) r = c.to_dataframe({"id": "v.id", "result": "r"}) r = r[r["result"] != 0].sort_values(by=["result"]) return r["id"].tolist()
def single_source_dijkstra_path_length(G, source, weight=None): if weight is None: weight = "weight" pg = G.project_to_simple(e_prop=weight) ctx = AppAssets(algo="sssp_projected")(pg, source) return ctx.to_dataframe({"node": "v.id", "result": "r"})