torch_geometric.transforms.LineGraph
- class LineGraph(force_directed: bool = False)[source]
Bases:
BaseTransform将图转换为其对应的线图 (函数名称:
line_graph).\[ \begin{align}\begin{aligned}L(\mathcal{G}) &= (\mathcal{V}^{\prime}, \mathcal{E}^{\prime})\\\mathcal{V}^{\prime} &= \mathcal{E}\\\mathcal{E}^{\prime} &= \{ (e_1, e_2) : e_1 \cap e_2 \neq \emptyset \}\end{aligned}\end{align} \]线图节点索引等于原始图中合并的
edge_index中的索引。 对于无向图,最大线图节点索引为(data.edge_index.size(1) // 2) - 1。新节点的特征由旧的边属性给出。 对于无向图,互逆边的属性
(row, col)和(col, row)会被加在一起。