Triangle Counting

Description, inputs and outputs of the Triangle counting algorithm

URI

<http://cray.com/graphAlgorithm.triangle_counting>

Description

Triangle Counting is used to count the total number of triangles in a graph.

Inputs and Default Values

  • Vector inputs - None.
  • Scalar inputs - This algorithm accepts a single integer scalar argument. The value of this integer ranges from 0 to 4 and specifies which types of triangles are to be included in the count.
    • 0: Return a count of all the triangles in the graph, both cyclic (including rotations) and non-cyclic triangles
    • 1: Return a count of all the unique triangles in the graph, both cyclic and non-cyclic triangles
    • 2: Return a count of only the non-cyclic triangles
    • 3: Return a count of only the cyclic triangles (including rotations)
    • 4: Return a count of only the unique cyclic triangles

Outputs

This algorithm returns a single integer containing the number of triangles.

Example: Triangle Counting

PREFIX cray: <http://cray.com/>

  SELECT ?total_num_triangles
  WHERE {
    CONSTRUCT{
      ?sub ?pred ?obj .
    }
    WHERE{
      ?sub ?pred ?obj .
    }
    INVOKE cray:graphAlgorithm.triangle_counting(1) 
    PRODUCING ?total_num_triangles