MCPcopy Create free account
hub / github.com/alibaba/GraphScope / triangles

Function triangles

python/graphscope/analytical/app/triangles.py:33–61  ·  view source on GitHub ↗

Evaluate triangle counting of the graph G. Args: graph (:class:`graphscope.Graph`): A simple graph. Returns: :class:`graphscope.framework.context.VertexDataContextDAGNode`: A context with each vertex assigned with the triangle counting result, evaluated in eager

(graph)

Source from the content-addressed store, hash-verified

31@project_to_simple
32@not_compatible_for("arrow_property", "dynamic_property")
33def triangles(graph):
34 """Evaluate triangle counting of the graph G.
35
36 Args:
37 graph (:class:`graphscope.Graph`): A simple graph.
38
39 Returns:
40 :class:`graphscope.framework.context.VertexDataContextDAGNode`:
41 A context with each vertex assigned with the triangle counting result, evaluated in eager mode.
42
43 Examples:
44
45 .. code:: python
46
47 >>> import graphscope
48 >>> from graphscope.dataset import load_p2p_network
49 >>> sess = graphscope.session(cluster_type="hosts", mode="eager")
50 >>> g = load_p2p_network(sess)
51 >>> # project to a simple graph (if needed)
52 >>> pg = g.project(vertices={"host": ["id"]}, edges={"connect": ["dist"]})
53 >>> c = graphscope.triangles(pg)
54 >>> sess.close()
55
56 """
57 if graph.is_directed():
58 logger.warning(
59 "Triangles may not be consistent when be queried upon directed graph."
60 )
61 return AppAssets(algo="triangles", context="vertex_data")(graph)

Callers

nothing calls this directly

Calls 2

AppAssetsClass · 0.90
is_directedMethod · 0.45

Tested by

no test coverage detected