S-T (Source – Target) Connectivity

Description, inputs and outputs of S-T Source Target connectivity algorithm

URI

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

Description

The S-T Connectivity function calculates the length of the path between two vertices, if one exists.

Inputs and Default Values

  • Vector inputs - None.
  • Scalar inputs - The input graph to the S-T Connectivity function is expected to contain triples of the form (vertex1, predicate, vertex2) where the value of predicate is ignored. The S-T Connectivity function requires two scalar input arguments, which are the IRIs of the two vertices under consideration, source and target, respectively. This is illustrated in the example below:
    INVOKE <http://cray.com/graphAlgorithm.st_connectivity> (<urn:mySourceVertex>, <urn:myTargetVertex>)
    In the above example, <urn:mySourceVertex> and <urn:myTargetVertex> are the IRIs of the source and target vertices, respectively.

Outputs

The following example culls needed edges from the default graph and calls S-T Connectivity on the resulting graph.

Example: S-T (Source Target) Connectivity

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

SELECT ?nHops
WHERE {
  CONSTRUCT {
    ?v1 ?p ?v2 .
  } WHERE {
    SELECT ?v1 ?v2 ?p
    WHERE {
      ?v1 <urn:hasLink> ?v2 .
      BIND(<urn:path> AS ?p)
    }
  }
    INVOKE cray:graphAlgorithm.st_connectivity(<http://ga.org/string#000/vertex#00000001>,
        <http://ga.org/string#000/vertex#00200000>)
    PRODUCING ?nHops
}