UltipaDocs
Products
Solutions
Resources
Company
Start Free Trial
UltipaDocs
Start Free Trial
  • Introduction
  • Running Algorithms
    • Degree Centrality
    • Closeness Centrality
    • Harmonic Centrality
    • Eccentricity Centrality
    • Betweenness Centrality
    • Bridges
    • Articulation Points
    • Eigenvector Centrality
    • Katz Centrality
    • CELF
    • PageRank
    • ArticleRank
    • TextRank
    • HITS
    • SybilRank
    • Jaccard Similarity
    • Overlap Similarity
    • Cosine Similarity
    • Pearson Correlation Coefficient
    • Euclidean Distance
    • KNN
    • Vector Similarity
    • Bipartite Graph
    • HyperANF
    • Weakly Connected Components (WCC)
    • Strongly Connected Components (SCC)
    • k-Edge Connected Components
    • Local Clustering Coefficient
    • Triangle Count
    • Clique Count
    • k-Core
    • k-Truss
    • p-Cohesion
    • Induced Subgraph
    • Topological Sort
    • Breadth-First Search (BFS)
    • Depth-First Search (DFS)
    • Dijkstra's Shortest Path
    • A* Shortest Path
    • Yen's K-Shortest Paths
    • Shortest Path (BFS)
    • Delta-Stepping SSSP
    • Shortest Path Faster Algorithm (SPFA)
    • All-Pairs Shortest Path (APSP)
    • Minimum Spanning Tree (MST)
    • K-Spanning Tree
    • Steiner Tree
    • Prize-Collecting Steiner Tree (PCST)
    • Minimum Cost Flow
    • Maximum Flow
    • K-Hop Fast
    • Longest Path (DAG)
    • Random Walk
    • Adamic-Adar Index
    • Common Neighbors
    • Preferential Attachment
    • Resource Allocation
    • Total Neighbors
    • Same Community
    • Louvain
    • Leiden
    • Modularity Optimization
    • Label Propagation
    • HANP
    • SLPA
    • k-Means
    • HDBSCAN
    • K-1 Coloring
    • Modularity
    • Conductance
    • Max k-Cut
      • Node2Vec
      • Struc2Vec
      • LINE
      • Fast Random Projection
      • Summary of Graph Embedding
      • Gradient Descent
      • Backpropagation
      • Skip-gram
      • Skip-gram Optimization
  1. Docs
  2. /
  3. Graph Algorithms
  4. /
  5. Graph Structure

Induced Subgraph

Overview

The Induced Subgraph algorithm extracts the subgraph formed by a given set of nodes and all edges between them. This enables focused analysis on a subset of the graph, revealing local structure and connectivity patterns among selected nodes.

Concepts

Induced Subgraph

An induced subgraph includes only the nodes from the given set and all edges that have both endpoints in that set.

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.

Considerations

  • The algorithm respects edge direction.
  • Multi-edges between the same pair of nodes are preserved.
  • Self-loops are included if the node is in the specified set.

Example Graph

GQL
INSERT (A:default {_id: "A"}), (B:default {_id: "B"}),
       (C:default {_id: "C"}), (D:default {_id: "D"}),
       (E:default {_id: "E"}), (F:default {_id: "F"}),
       (G:default {_id: "G"}), (H:default {_id: "H"}),
       (I:default {_id: "I"}),
       (A)-[:default]->(B), (C)-[:default]->(A),
       (E)-[:default]->(C), (E)-[:default]->(A),
       (C)-[:default]->(D), (D)-[:default]->(A),
       (D)-[:default]->(A), (F)-[:default]->(G),
       (G)-[:default]->(G), (F)-[:default]->(I),
       (H)-[:default]->(G)

Parameters

NameTypeDefaultDescription
nodesSTRING/Required. Comma-separated node _id values specifying the node set for the induced subgraph.

Run Mode

Returns:

ColumnTypeDescription
sourceIdSTRINGSource node identifier (_id)
targetIdSTRINGTarget node identifier (_id)
edgeExistsINTEdge existence indicator (always 1)
GQL
CALL algo.inducedsubgraph({
  nodes: ["A,C,D,G"]
}) YIELD sourceId, targetId, edgeExists

Result:

sourceIdtargetIdedgeExists
CD1
CA1
DA1
DA1
GG1

Stream Mode

Returns the same columns as run mode, streamed for memory efficiency.

GQL
CALL algo.inducedsubgraph.stream({
  nodes: "A,C,D,G"
}) YIELD sourceId, targetId
RETURN sourceId, targetId

Result:

sourceIdtargetId
CD
CA
DA
DA
GG

Stats Mode

Returns:

ColumnTypeDescription
nodeCountINTNumber of nodes in the induced subgraph
edgeCountINTNumber of edges in the induced subgraph
densityFLOATGraph density: edgeCount / (nodeCount * (nodeCount - 1)) for directed graphs
GQL
CALL algo.inducedsubgraph.stats({
  nodes: "A,C,D,G"
}) YIELD nodeCount, edgeCount, density

Result:

nodeCountedgeCountdensity
450.4166666666666667