日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Katana的高性能图形分析库

發布時間:2023/12/18 编程问答 35 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Katana的高性能图形分析库 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

目錄

庫中的圖形分析算法

獲取Katana圖形庫

使用Katana圖形庫

鄰接矩陣的輸入

來自邊緣列表的輸入

來自Pandas DataFrame的輸入

來自GraphML的輸入

執行圖分析算法

Metagraph支持

Katana圖形庫有多快?

我在哪里可以了解更多信息?

參考


根據?Gartner, Inc.的數據,圖形處理是2021年十大數據分析趨勢之一。它是一個新興的應用領域,也是數據科學家處理關聯數據集(例如社交、電信和金融)的必要工具網絡;網絡流量;和生化途徑)。實際應用中的圖往往很大,而且越來越大。例如,當今的社交網絡可以擁有數十億個節點和邊緣,因此高性能并行計算至關重要。

為此,Katana Graph與英特爾合作,設計了一個高性能、易于使用的圖形分析Python庫,具有(a)高度優化的重要圖形分析算法的并行實現;(b)一個高級Python接口,用于在底層C++圖形引擎之上編寫自定義并行算法;(c)pandasscikit-learnApache Arrow以及?英特爾AI?軟件堆棧中的工具和庫的互操作性;(d)全面支持各種格式的提取、轉換和加載(ETL)(e)?Metagraph?插件。

本文將介紹庫中的內容、如何訪問庫、使用示例和基準數據以突出性能。

庫中的圖形分析算法

圖形處理管道中常用的關鍵算法預先打包在Katana庫中。目前可用的算法如下:

  • 廣度優先搜索:?返回從源節點開始的廣度優先搜索構造的定向樹
  • 單源最短路徑:?計算從源節點開始到所有節點的最短路徑
  • 連接的組件:?查找圖的內部連接但未連接到其他組件的組件(即節點組)
  • 網頁級別:?根據傳入鏈接的結構計算圖中節點的排名
  • 中介中心性:?根據通過每個節點的最短路徑數計算圖中節點的中心性
  • 三角形計數:?計算圖形中三角形的數量
  • 魯汶社區檢測:?使用魯汶啟發式計算最大化模塊化的圖社區
  • 子圖提取:?提取圖的誘導子圖
  • Jaccard相似度:?計算給定節點與圖中每個其他節點的Jaccard系數
  • 使用標簽傳播的社區檢測:?使用標簽傳播算法計算圖中的社區
  • 局部聚類系數函數:?衡量圖中節點傾向于聚集在一起的程度
  • K-Truss?找到包含至少三個頂點的圖的最大誘導子圖,其中每條邊都與至少K-2個三角形相關
  • K-Core?查找包含度數為K或以上的節點的最大子圖

更多算法被添加到庫中,用戶可以輕松添加自己的算法,我們將在下面演示。

獲取Katana圖形庫

Katana Graph的分析庫是開源的,在?3-Clause BSD許可下免費提供。它可以在?GitHub?上找到,也可以從Anaconda.org輕松安裝:

$ conda install -c katanagraph/label/dev -c conda-forge katana-python

使用Katana圖形庫

KatanaPython庫支持各種格式的ETL,例如鄰接矩陣、pandas DataFramesNumPy數組、邊列表、GraphMLNetworkX等。下面顯示了幾個示例:

import numpy as np import pandas from katana.local import Graph from katana.local.import_data import (from_adjacency_matrix,from_edge_list_arrays,from_edge_list_dataframe,from_edge_list_matrix,from_graphml)

鄰接矩陣的輸入

katana_graph = from_adjacency_matrix(np.array([[0, 1, 0], [0, 0, 2], [3, 0, 0]]))

來自邊緣列表的輸入

katana_graph = from_edge_list_arrays(np.array([0, 1, 10]), np.array([1, 2, 0]),prop = np.array([1, 2, 3]))

來自Pandas DataFrame的輸入

katana_graph = from_edge_list_dataframe(pandas.DataFrame(dict(source=[0, 1, 10],destination=[1, 2, 0],prop = [1, 2, 3])))

來自GraphML的輸入

katana_graph = from_graphml(input_file)

執行圖分析算法

以下示例計算輸入圖的介數中心性:

import katana.local from katana.example_utils import get_input from katana.property_graph import PropertyGraph from katana.analytics import betweenness_centrality,BetweennessCentralityPlan,BetweennessCentralityStatistics katana.local.initialize()property_name = "betweenness_centrality" betweenness_centrality(katana_graph, property_name, 16,BetweennessCentralityPlan.outer()) stats = BetweennessCentralityStatistics(g, property_name)print("Min Centrality:", stats.min_centrality) print("Max Centrality:", stats.max_centrality) print("Average Centrality:", stats.average_centrality)

KatanaPython庫可與pandasscikit-learnApache Arrow互操作。

除了前面列出的預打包例程外,數據科學家還可以使用簡單的Python接口編寫自己的圖形算法,該接口公開了Katana Graph的優化C++引擎及其并發數據結構和并行循環結構。Katana Graph庫已經包含廣度優先搜索實現,但以下示例說明了使用API實現此類算法是多么容易:

def bfs(graph: Graph, source):"""Compute the BFS distance to all nodes from source.The algorithm in bulk-synchronous level by level.:param graph: The input graph.:param source: The source node for the traversal.:return: An array of distances, indexed by node ID."""next_level_number = 0# The work lists for the current and next levels using a # Katana concurrent data structure.curr_level_worklist = InsertBag[np.uint32]()next_level_worklist = InsertBag[np.uint32]()# Create and initialize the distance array.# source is 0, everywhere else is INFINITYdistance = np.empty((len(graph),), dtype=np.uint32)distance[:] = INFINITYdistance[source] = 0# Start processing with just the source node.next_level_worklist.push(source)# Execute until the worklist is empty.while not next_level_worklist.empty():# Swap the current and next work listscurr_level_worklist, next_level_worklist = next_level_worklist,curr_level_worklist# Clear the worklist for the next level.next_level_worklist.clear()next_level_number += 1# Process the current worklist in parallel by applying# bfs_operator for each element of the worklist.do_all(curr_level_worklist,# The call here binds the initial arguments of bfs_operator.bfs_operator(graph, next_level_worklist,next_level_number, distance))return distance# This function is marked as a Katana operator, meaning that it will # be compiled to native code and prepared for use with Katana do_all. @do_all_operator() def bfs_operator(graph: Graph, next_level_worklist,next_level_number, distance, node_id):"""The operator called for each node in the work list.The initial four arguments are provided by bfs above.node_id is taken from the worklist and passed to thisfunction by do_all.:param next_level_worklist: The work list to add next nodes to.:param next_level_number: The level to assign to nodes we find.:param distance: The distance array to fill with data.:param node_id: The node we are processing.:return:"""# Iterate over the out edges of our nodefor edge_id in graph.edges(node_id):# Get the destination of the edgedst = graph.get_edge_dest(edge_id)# If the destination has not yet been reached, set its level# and add it to the work list so its out edges can be processed# in the next level.if distance[dst] == INFINITY:distance[dst] = next_level_numbernext_level_worklist.push(dst)# There is a race here, but it's safe. If multiple calls to# operator add the same destination, they will all set the# same level. It will create more work because the node will# be processed more than once in the next level, but it avoids# atomic operations so it can still be a win in low-degree graphs.

Metagraph支持

Katana GraphPython分析庫將通過?Metagraph?插件提供。Metagraph為圖形分析提供了一致的Python入口點。可以使用標準API編寫圖形工作流,然后將其分發到可插入Metagraph的兼容圖形庫。現在,開源圖形社區將能夠直接使用Katana Graph的高性能應用程序。Metagraph插件包含在Anaconda包中,可以按如下方式安裝和調用:

$ conda create -n metagraph-test -c conda-forge \-c katanagraph/label/dev \-c metagraph metagraph-katanaimport metagraph as mg bfs = mg.algos.traversal.bfs_iter(katana_graph, <start node>)

Katana圖形庫有多快?

Katana庫已針對其他圖形分析框架進行了廣泛的基準測試,并且始終顯示出與?GAP Benchmark Suite?相當或更好的性能。?1?顯示了Katana Graph相對于來自不同領域的各種圖的GAP參考實現的性能。

1. 使用GAP Benchmark Suite測量Katana Graph性能。該數據取自Azad等人。(2020)2。系統:雙路 2.0 GHz Intel? Xeon? Platinum 8153 處理器(64個邏輯內核)和 384 GB DDR4 內存。有關性能和基準測試結果的更完整信息,請訪問?www.intel.com/benchmarks

Katana Graph庫在最近的字節可尋址內存技術上也被證明在超大圖上表現良好,例如Clueweb12WDC12(分別有421280億條邊,這些是一些最大的公開可用圖)例如英特爾? 傲騰? DC持久內存( 1)。

1. Katana Graph BFS在超大圖上的性能。它將單個基于英特爾傲騰內存的節點的性能與具有多個節點的集群進行了比較。每個TACC Stampede Skylake集群節點都有兩個2.1 GHz Intel Xeon Platinum 8160處理器和192 GB DDR4內存。Cascade Lake服務器具有兩個2.2 GHz第二代Intel Xeon可擴展處理器,配備6 TB Intel Optane PMM384 GB DDR4 DRAMIce Lake服務器有兩個2.2 GHz Intel Xeon Platinum 8352Y處理器,8 TB Intel Optane PMM1 TB DDR4 DRAM。有關性能和基準測試結果的更完整信息,請訪問?www.intel.com/benchmarks

我在哪里可以了解更多信息?

我希望您確信Katana Graph庫是用于圖形分析的多功能、高性能選項。您可以在GitHub 站點上了解有關該庫的更多信息、提出問題、發布功能請求等?

參考

  • Nguyen, D.Lenharth, A.Pingali, K. (2013)?用于圖形分析的輕量級基礎架構。第24ACM操作系統原理研討會論文集 (SOSP '13)
  • 阿扎德,A. 等人。(2020年)。?使用GAP基準套件、IEEE工作負載表征國際研討會(IISWC)評估圖形分析框架。
  • ClueWeb12數據集
  • Web Data Commons – 超鏈接圖
  • Gill, G.Dathathri, R.Hoang, L.Peri, R.Pingali, K. (2020)?使用英特爾傲騰DC持久內存對海量數據集進行單機圖分析?VLDB捐贈基金會議記錄,13(8), 1304–1318
  • Dathathri, R. 等人。(2019)。?Gluon-Async:用于分布式和?異構圖形分析的批量異步系統。第28屆并行架構和編譯技術國際會議論文集(PACT)
  • https://www.codeproject.com/Articles/5317383/Katana-s-High-Performance-Graph-Analytics-Library

    總結

    以上是生活随笔為你收集整理的Katana的高性能图形分析库的全部內容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。