我可以更改 GraphX 中边的 srcId 和 dstId 的值吗?

Can I change the value of srcId and dstId of an edge in GraphX?

有什么方法可以更改边缘的 srcId 和 dstId 的值,因为当我这样做时:

val newGraph = graph.mapEdges(
      e =>
        if(//a condition here) {
          e.srcId*0 + //a value
          e.dstId*0 + //another value
          e.attr*1.0 //so that the attribute will remain the same
        }
    else {
          //another piece of code here
        }
    )

newGraph的srcId和dstId与graph的值相同。请注意,if 语句中的条件 100% 有效(已测试),并且图中确实存在 id 的新值,这意味着新 id 不会指向不存在的顶点。此外,edge 属性的更改适用于该段代码,只有 id 不会更改。

不,mapEdges,与 GraphImplmapTripletsmapVertices)上的其他转换相同,仅用于映射属性。引用 official documentation

Transforms each edge attribute using the map function, passing it a whole partition at a time. (...) and it should return a new iterator over the new values of each edge. The new iterator's elements must correspond one-to-one with the old iterator's elements.

据我所知,目前无法在不重新创建整个图表的情况下修改源或目标。