作为 RAPIDS cuGraph 的一部分,属性图可以将 cuGraph 的所有优点应用于存储在图结构中的属性丰富数据集。属性图实际上是一种数据模型,而不是一种图类型。在 cuGraph 生态系统中,属性图是一种元图,可以封装和实例化所有其他图类型。这种观点源于属性图最初是为数据库系统创建的。从概念上讲,属性图可以被视为一种属性丰富的结构,可以投影到任何图类型上。Dataversity 提供了一个很好的属性图定义,其中包含来自多个资源的定义。

属性图支持

Sample Property Graph

多种边和节点类型,如属性图 API 中所示

  • 基于属性和/或边和节点类型的子图提取,如下所示。

  • 将属性存储在 GPU 上的图结构中,或使用基于 GNN 的存储扩展存储在主机存储中。

  • 在属性图中添加额外的属性、节点和边,以存储分析结果等派生数据。

  • 由远程服务器管理的客户端访问,允许使用 CuGraph 服务进行共享访问和远程操作。

  • 这是在两阶段分析中使用 cuGraph 属性图的示例。

下一页

知识存储

import cudf
import cugraph
from cugraph.experimental import PropertyGraph

# Import a built-in dataset
from cugraph.datasets import karate

# Read edgelist data into a DataFrame, load into PropertyGraph as edge data.
# Create a graph using the imported Dataset object
graph = cugraph.Graph(directed=False)
G = karate.get_graph(create_using=graph,fetch=True)

df = G.edgelist.edgelist_df
pG = PropertyGraph()
pG. add_edge_data(df, vertex_col_names=("src", "dst"))

# Run Louvain to get the partition number for each vertex.
# Set resolution accordingly to identify two primary partitions.
(partition_info, _) = cugraph.louvain(pG.extract_subgraph(create_using=graph), resolution=0.6)

# Add the partition numbers back to the Property Graph as vertex properties
pG.add_vertex_data(partition_info, vertex_col_name="vertex")

# Use the partition properties to extract a Graph for each partition.
G0 = pG.extract_subgraph(selection=pG.select_vertices("partition == 0"))
G1 = pG.extract_subgraph(selection=pG. select_vertices("partition == 1"))
# Run pagerank on each graph, print results.
pageranks0 = cugraph.pagerank(G0)
pageranks1 = cugraph.pagerank(G1)
print(pageranks0.sort_values (by="pagerank", ascending=False).head(3))
print(pageranks1.sort_values (by="pagerank", ascending=False).head(3))
本页