用法:
cugraph.linear_assignment.hungarian(G, workers, epsilon=None)
針對對稱的加權二分圖執行匈牙利算法。
作為二分圖,圖的頂點集可以劃分為兩個不相交的集合,使得所有邊都將一個集合的頂點連接到另一個集合的頂點。工人變量標識一組頂點,另一組是不在工人集中的所有頂點(V - 工人)。
邊權重反映了將特定工作分配給工人的成本。
匈牙利算法識別出最低成本的頂點匹配,這樣所有可以分配工作的工人都被準確地分配到工作中。
- G:cugraph.Graph
cuGraph 圖說明符,應包含連接信息作為邊列表。邊權重是必需的。如果未提供邊列表,則將對其進行計算。
- workers:cudf.Series 或 cudf.DataFrame
一個序列或列,用於標識工作集中頂點的頂點 ID。如果是multi-column 頂點,它應該是一個 cudf.DataFrame。 G 中所有不在工作集中的頂點都被隱式分配給工作集。
- epsilon:float/double(匹配圖中的權重),可選(默認=無)
用於確定值何時足夠接近零以考慮 0。在 C++ 代碼中默認(如果未指定)為 1e-6。不用於整數權重類型。
- cost:匹配 cost.dtype
整體任務的成本
- df:cudf.DataFrame
df[‘vertex’][i] 給出第 i 個頂點的頂點 ID。此列中僅定義工作人員列表中的頂點。
df[‘assignment’][i] 給出分配給相應頂點的“job” 的頂點id。
參數:
返回:
例子:
>>> # Download dataset from https://github.com/rapidsai/cugraph/datasets/.. >>> # M = cudf.read_csv(datasets_path / 'bipartite.csv', delimiter=' ', >>> # dtype=['int32', 'int32', 'float32'], header=None) >>> # G = cugraph.Graph() >>> # G.from_cudf_edgelist(M, source='0', destination='1', edge_attr='2') >>> # cost, df = cugraph.hungarian(G, workers)
相關用法
- Python cugraph.link_prediction.jaccard.jaccard用法及代碼示例
- Python cugraph.link_prediction.wjaccard.jaccard_w用法及代碼示例
- Python cugraph.link_analysis.pagerank.pagerank用法及代碼示例
- Python cugraph.link_prediction.woverlap.overlap_w用法及代碼示例
- Python cugraph.link_prediction.overlap.overlap用法及代碼示例
- Python cugraph.link_prediction.jaccard.jaccard_coefficient用法及代碼示例
- Python cugraph.link_analysis.hits.hits用法及代碼示例
- Python cugraph.community.spectral_clustering.spectralBalancedCutClustering用法及代碼示例
- Python cugraph.community.ecg.ecg用法及代碼示例
- Python cugraph.Graph.from_cudf_adjlist用法及代碼示例
- Python cugraph.community.louvain.louvain用法及代碼示例
- Python cugraph.tree.minimum_spanning_tree.maximum_spanning_tree用法及代碼示例
- Python cugraph.centrality.betweenness_centrality.betweenness_centrality用法及代碼示例
- Python cugraph.dask.community.louvain.louvain用法及代碼示例
- Python cugraph.traversal.bfs.bfs用法及代碼示例
- Python cugraph.community.egonet.batched_ego_graphs用法及代碼示例
- Python cugraph.tree.minimum_spanning_tree.minimum_spanning_tree用法及代碼示例
- Python cugraph.Graph.from_cudf_edgelist用法及代碼示例
- Python cugraph.centrality.betweenness_centrality.edge_betweenness_centrality用法及代碼示例
- Python cugraph.components.connectivity.strongly_connected_components用法及代碼示例
注:本文由純淨天空篩選整理自rapids.ai大神的英文原創作品 cugraph.linear_assignment.hungarian。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。