8.4.7 Computing Similars for a Graphlet Batch
You can fetch the k
most similar graphlets for a batch of input graphlets as described in the following code:
opg4j> var graphlets = new ArrayList()
opg4j> graphlets.add(52)
opg4j> graphlets.add(41)
opg4j> var batchedSimilars = model.computeSimilars(graphlets, 10)
List graphlets = Arrays.asList(52,41);
PgxFrame batchedSimilars = model.computeSimilars(graphlets,10);
batched_similars = model.compute_similars([52,41],10)
Searching for similar vertices for graphlet with
ID = 52
and ID =
41
using the trained model and printing
it with batched_similars.print()
,
will result in the following
output:+------------------------------------------------+
| srcGraphlet | dstGraphlet | similarity |
+------------------------------------------------+
| 52 | 52 | 1.0 |
| 52 | 10 | 0.8748674392700195 |
| 52 | 23 | 0.8551455140113831 |
| 52 | 26 | 0.8493421673774719 |
| 52 | 47 | 0.8411962985992432 |
| 52 | 25 | 0.8281504511833191 |
| 52 | 43 | 0.8202780485153198 |
| 52 | 24 | 0.8179885745048523 |
| 52 | 8 | 0.796689510345459 |
| 52 | 9 | 0.7947834134101868 |
| 41 | 41 | 1.0 |
| 41 | 197 | 0.9653506875038147 |
| 41 | 84 | 0.9552277326583862 |
| 41 | 157 | 0.9465565085411072 |
| 41 | 65 | 0.9287481307983398 |
| 41 | 248 | 0.9177336096763611 |
| 41 | 315 | 0.9043129086494446 |
| 41 | 92 | 0.8998928070068359 |
| 41 | 297 | 0.8897411227226257 |
| 41 | 50 | 0.8810243010520935 |
+------------------------------------------------+
Parent topic: Using the Pg2vec Algorithm