PGX offers the following methods for setting and getting property values in the Property
class:
PgxFuture<V> getAsync(ID id) PgxFuture<V> getAsync(K key)
Blocking variants:
V get(ID id) V get(K key)
prop[key]
You can either pass in a PgxVertex
/PgxEdge
object or directly assign the vertex/edge identifier values
and a boxed Java object with the appropriate type that contains the requested value is returned.
Another way to get vertex/edge property values is to pass vertex/edge
property name to PgxVertex#getProperty
/PgxEdge#getProperty
methods.
Examples:
PgxGraph G = ... VertexProperty<Integer, Boolean> vip = G.getVertexProperty("vip"); EdgeProperty<Float> cost = G.getEdgeProperty("cost"); PgxVertex<Integer> vertex = G.getVertex(801); PgxEdge edge = G.getEdge(5692L); boolean isVip = vip.get(vertex); float costValue = cost.get(edge); // shortcuts boolean isVip = vip.get(801); float costValue = cost.get(5692L); // from PgxVertex and PgxEdge boolean isVip = vertex.get("vip") float costValue = edge.getProperty("cost")
vip = G.get_vertex_property("vip") cost = G.get_edge_property("cost") vertex = G.get_vetex(801) edge = G.get_edge(5692) is_vip = vip.get(vertex) cost_value = cost.get(edge) isVip = vip.get(801) costValue = cost.get(5692) is_vip = vertex.get_property("vip") cost_value = edge.get_property("cost")
Similarly, the client can set the value of properties by applying one of the following methods in Property
:
PgxFuture<Void> setAsync(K key, V value) PgxFuture<Void> setValuesAsync(Map<K, V> values) PgxFuture<Void> setValuesAsync(Map<K, V> values, V defaultValue)
Blocking variants are
void set(K key, V value) void setValues(Map<K, V> values) void setValues(Map<K, V> values, V defaultValue)
set(self, key, value)
Property values may be set in a number of ways. A single property value can be set directly (first method), or the property values for several
vertices and edges can be set all at once. values
are the key-value pairs (i.e. a Map
), for which the key is the PgxVertex
(or PgxEdge
) and the value is the property value that should be set for this vertex (or edge).
If a defaultValue
is given, it will be assigned to all the vertices (or edges) which are not specified
in the given values
map. This is conceptually
equivalent to first using the fill()
method with the
given defaultValue
and then applying the setValues(values)
method.
Using the following fill()
method, the client can set the same value for a property in every vertex
or edge of the graph:
PgxFuture<Void> fillAsync(V value) void fill(V value) // blocking equivalent
fill(self, value)
You can set a single property value through the following method of PgxVertex
and PgxEdge
<V> PgxFuture<Void> setPropertyAsync(String, V)
and its blocking variants
<V> void setProperty(String, V)
get_property(self, property_name)
To iterate the values of a property, the client can invoke the following methods in the Property
class:
PgxFuture<Iterable<Map.Entry<K, V>>> getValuesAsync() PgxFuture<Iterable<Map.Entry<K, V>>> getTopKValuesAsync(int k) PgxFuture<Iterable<Map.Entry<K, V>>> getBottomKValuesAsync(int k)
Blocking equivalents:
Iterable<Map.Entry<K, V>> getValues() Iterable<Map.Entry<K, V>> getTopKValues(int k) Iterable<Map.Entry<K, V>> getBottomKValues(int k)
get_values(self) get_bottom_k_values(self, k) get_top_k_values(self, k)
The method getValuesAsync
(or getValues
) returns an iterator of key-value pairs; the key is the unique PgxVertex
and
the value is the value of this property for that vertex or edge. The iteration does not necessarily follow a specific order.
The next two methods (getTopKValue
and getBottomKValues
) return similar iterators. However,
these iterators are ordered by the value of this property, in descending or ascending order up to K elements.
PGX provides VertexLabels
and EdgeLabel
for multiple labels on a
vertex and a single label on an edge. The property graph model that
PGX support defines such label concepts.
Similar to the property access, to access vertex labels, PGX offers the
following methods of VertexLabels
:
PgxFuture<Set<String>> getAsync(ID id) PgxFuture<Set<String>> getAsync(K key)
Blocking variants:
V get(ID id) V get(K key)
get(self, key)
To access an edge label, PGX offers the following methods of EdgeLabel
:
PgxFuture<String> getAsync(ID id) PgxFuture<String> getAsync(K key)
Blocking variants:
String get(ID id) String get(K key)
get(self, key)
You can either pass in a PgxVertex
/PgxEdge
object or directly assign the vertex/edge identifier values
and a boxed Java object with the appropriate type that contains the requested value is returned.
Another way to get vertex/edge labels is to directly call PgxVertex#getLabels
/PgxEdge#getLabel
methods.
Examples:
PgxGraph G = ... VertexLabels<Integer> vertexLabels = G.getVertexLabels(); EdgeLabel edgeLabel = G.getEdgeLabel(); PgxVertex<Integer> vertex = G.getVertex(801); PgxEdge edge = G.getEdge(5692L); Set<String> vLabels = vertexLabels.get(vertex); String eLabel = edgeLabel.get(edge); // shortcuts Set<String> vLabels = vertexLabels.get(801); String eLabel = edgeLabel.get(5692L); // from PgxVertex and PgxEdge Set<String> vLabels = vertex.getLabels() String eLabel = edge.getLabel()
G = ... vertex_labels = G.get_vertex_labels() edge_label = G.get_edge_label() vertex = G.get_vertex(801) edge = G.get_edge(5692L) v_labels = vertex_labels.get(vertex); e_label = edge_label.get(edge); # shortcuts v_labels = vertex_labels.get(801); e_label = edge_label.get(5692L); # from PgxVertex and PgxEdge v_labels = vertex.get_labels() e_label = edge.get_label()
For more information on how to load graphs with labels see the following pages: