I know that in GraphX we can merge two graphs in order to update an existing network for example... However, as a usual operation for updating a network is to insert into it a single node. How could one do such an updating operation in GraphX ?! Thanks !
Asked
Active
Viewed 1,211 times
1 Answers
7
Graphs are immutable, so you can't add a single node to an existing graph, but you can create a new graph based on the previous with the additional node added. Say you had a graph like this:
var graph: Graph[Int,Int] = ...
You could add a new node like this:
graph = Graph(
graph.vertices.union(sc.parallelize(Array[(VertexId, Int)]((13L, 1)))),
graph.edges,
0
)

David Griffin
- 13,677
- 5
- 47
- 65