Running Built-in Algorithms Using the Analyst API

The Analyst API provides convenience ways to apply built-in graph analyses. Especially, the API provides a single wrapper method for the analyses that is composed of multiple sub-steps.

Obtaining an Analyst instance

In order to obtain an Analyst instance, simply invoke createAnalyst() on your Session object:

1analyst = session.create_analyst()

Running Algorithms and Browsing Results

The Analyst API provides methods for each built-in graph analysis. If the graph analysis requires certain preprocessing steps, all of those preprocessing steps are encapsulated in the Analyst API method.

For instance, the Analyst API provides the following method to count the numbers of triangles in a graph:

1analyst.count_triangles(graph, sort_vertices_by_degree)

The above method is actually composed of the following sub-steps.

  1. Create an undirected copy of the given graph (the count triangles algorithm is only defined on undirected graphs)

  2. Optionally sort the vertices of the undirected copy by degree. This is a speed versus memory consumption trade-off which can be controlled by passing the sort_vertices_by_degree parameter

  1. Invoke the built-in count triangles algorithm on the graph copy

  2. Return the result

  3. Drop the undirected copy of the graph

For detailed information, refer to the Analyst class in the API section.

Optional arguments

The Analyst class has overloaded convenience methods which use default values for optional parameters. For example,

1analyst.pagerank(
2    graph,
3    tol=0.001,
4    damping=0.85,
5    max_iter=100,
6    norm=False,
7    rank="pagerank"
8)

will use a max error of 0.001, a damping factor of 0.85 and a maximum of 100 iterations. For detailed information, refer to the Analyst class in the API section.

Reuse existing data structures

By default, the Analyst creates a new in-memory data structure to hold the result of an algorithm invocation. That data structure gets disposed once the Analyst object gets disposed. However, you can also pass in existing mutable data structures the algorithm writes its result into. Examples:

1rank = analyst.pagerank(G)
2analyst.pagerank(G, rank=rank)

Disposing an Analyst Instance

Once the graph analysis is finished, the user can invoke the destroy() method to deallocate all of the resources used by the Analyst. If there are multiple Analyst objects, a destroy() invocation of one Analyst instance does not affect the other instances.