14.6.2.2 Adding Edges
You can also add edges to a graph using GraphChangeSet
.
opg4j> var changeSet2 = updatedGraph.<Integer>createChangeSet()
opg4j> changeSet2.addEdge(333, 42).setProperty("cost", 42.3)
opg4j> changeSet2.addEdge(42, 99)
opg4j> var updatedGraph2 = changeSet2.build()
import oracle.pgx.api.*;
GraphChangeSet<Integer> changeSet2 = graph.createChangeSet();
changeSet2.addEdge(333, 42).setProperty("cost", 42.42);
changeSet2.addEdge(42, 99);
PgxGraph updatedGraph2 = changeSet2.build();
from pypgx.api import *
change_set_2 = graph.create_change_set()
changeSet2.add_edge(333, 42).set_property("cost", 42.42)
changeSet2.add_edge(42, 99)
updated_graph_2 = change_set_2.build()
Note that by calling changeSet2.build()
, you created a
brand new graph with a unique name assigned by the graph server (PGX). If need be,
you can specify a name argument to the build()
method.
Additionally, you can create a new snapshot on top of the current graph
with the buildNewSnapshot()
method. See Creating a Snapshot via ChangeSet for more information.
Parent topic: Modifying Loaded Graphs Using ChangeSet