Skip to content

Commit

Permalink
fix: amend docstring
Browse files Browse the repository at this point in the history
  • Loading branch information
askorupka committed Oct 11, 2024
1 parent 3dadbeb commit 7db4adc
Showing 1 changed file with 44 additions and 7 deletions.
51 changes: 44 additions & 7 deletions GNNGraphs/src/sampling.jl
Original file line number Diff line number Diff line change
Expand Up @@ -118,18 +118,55 @@ function sample_neighbors(g::GNNGraph{<:COO_T}, nodes, K = -1;
end

"""
induced_subgraph(graph::GNNGraph, nodes::Vector{Int}) -> GNNGraph
induced_subgraph(graph::GNNGraph, nodes::Vector{Int})
Generates a subgraph from the original graph using the provided `nodes`.
The function includes the nodes' neighbors and creates edges between nodes that are connected in the original graph.
If a node has no neighbors, an isolated node will be added to the subgraph.
If a node has no neighbors, an isolated node will be added to the subgraph.
Returns A new `GNNGraph` containing the subgraph with the specified nodes and their features.
# Arguments:
- `graph::GNNGraph`: The original graph containing nodes, edges, and node features.
- `nodes::Vector{Int}`: A vector of node indices to include in the subgraph.
# Arguments
- `graph::GNNGraph`. The original graph containing nodes, edges, and node features.
- `nodes::Vector{Int}. A vector of node indices to include in the subgraph.
# Examples
# Returns:
A new `GNNGraph` containing the subgraph with the specified nodes and their features.
```jldoctest
julia> s = [1, 2]
2-element Vector{Int64}:
1
2
julia> t = [2, 3]
2-element Vector{Int64}:
2
3
julia> graph = GNNGraph((s, t), ndata = (; x=rand(Float32, 32, 3), y=rand(Float32, 3)), edata = rand(Float32, 2))
GNNGraph:
num_nodes: 3
num_edges: 2
ndata:
y = 3-element Vector{Float32}
x = 32×3 Matrix{Float32}
edata:
e = 2-element Vector{Float32}
julia> nodes = [1, 2]
2-element Vector{Int64}:
1
2
julia> subgraph = Graphs.induced_subgraph(graph, nodes)
GNNGraph:
num_nodes: 2
num_edges: 1
ndata:
y = 2-element Vector{Float32}
x = 32×2 Matrix{Float32}
edata:
e = 1-element Vector{Float32}
"""
function Graphs.induced_subgraph(graph::GNNGraph, nodes::Vector{Int})
if isempty(nodes)
Expand Down

0 comments on commit 7db4adc

Please sign in to comment.