# Change Nickname

Current Nickname:

Certifications

Certificate Issued at Valid until Serial No. File
Serial No. Valid until

Not having one? Apply now! >>>

Invoice

ProductName CreateTime ID Price File
ProductName CreateTime ID Price File

# Induced Subgraph

✓ File Writeback ✕ Property Writeback ✓ Direct Return ✓ Stream Return ✕ Stats

## Overview

Induced Subgraph algorithm is used to compute the induced subgraph of a given set of nodes in a graph. It provides a way to focus on the immediate connections and gain insights into the local structure and interactions within the selected subset of nodes.

## Concepts

### Induced Subgraph

An induced subgraph includes only the nodes from the given set and the edges that connect those nodes.

As this example shows, when specifying node set S = {A, B, I, K, L, M, N}, the induced subgraph is the graph whose node set is S and whose edge set contains all edges that have both endpoints in S.

Ultipa's Induced Subgraph algorithm returns all the 1-step paths in the induced subgraph.

## Considerations

• Induced Subgraph algorithm ignores the direction of edges but calculates them as undirected edges.

## Syntax

• Command: `algo(subgraph)`
• Parameters:
Name
Type
Spec
Default
Optional
Description
ids / uuids []`_id` / []`_uuid` / / No ID/UUID of the nodes to calculate
limit int ≥-1 `-1` Yes Number of results to return, `-1` to return all results

## Examples

The example graph is as follows:

### File Writeback

Spec
Content
Description
filename `_id--[_uuid]--_id` 1-step path in the induced subgraph, presented in the form of startNode--edge--endNode
``````algo(subgraph).params({
ids: ['A','C','D','G']
}).write({
file:{
filename: 'paths'
}
})
``````

Results: File paths

``````C--[102]--A
C--[105]--D
D--[107]--A
D--[106]--A
G--[109]--G
``````

### Direct Return

Alias Ordinal
Type
Description
0 []`path` 1-step path in the induced subgraph, presented in the form of startNode -- edge -- endNode
``````algo(subgraph).params({
ids: ['A','C','D','G']
}) as subgraph
return subgraph
``````

Results: subgraph

 3--[102]--1 3--[105]--4 4--[107]--1 4--[106]--1 7--[109]--7

### Stream Return

Alias Ordinal
Type
Description
0 []`path` 1-step path in the induced subgraph, presented in the form of startNode -- edge -- endNode
``````algo(subgraph).params({
uuids: [6,7]
}).stream() as p
with pedges(p) as e
find().edges(e) as edges
return max(edges.score)
``````

Results: 5