16.5.2 Running the Triangle Counting Algorithm
For triangle counting, the sortByDegree
boolean parameter of countTriangles()
allows you to control whether the graph should first be sorted by degree (true
) or not (false
). If true
, more memory will be used, but the algorithm will run faster; however, if your graph is very large, you might want to turn this optimization off to avoid running out of memory.
opg4j> analyst.countTriangles(graph, true)
==> 1
import oracle.pgx.api.*; Analyst analyst = session.createAnalyst(); long triangles = analyst.countTriangles(graph, true);
The algorithm finds one triangle in the sample graph.
Tip:
When using the graph shell, you can increase the amount of log output during execution by changing the logging level. See information about the:loglevel
command with :h
:loglevel
.
Parent topic: Executing Built-in Algorithms