@@ -80,9 +80,61 @@ function Graphs.has_edge(g::GNNHeteroGraph, edge_t::EType, i::Integer, j::Intege
8080    return  any ((s .==  i) .&  (t .==  j))
8181end 
8282
83- graph_type_symbol (:: GNNGraph{<:COO_T} ) =  :coo 
84- graph_type_symbol (:: GNNGraph{<:SPARSE_T} ) =  :sparse 
85- graph_type_symbol (:: GNNGraph{<:ADJMAT_T} ) =  :dense 
83+ """ 
84+     get_graph_type(g::GNNGraph) 
85+ 
86+ Return the underlying representation for the graph `g` as a symbol. 
87+ 
88+ Possible values are: 
89+ - `:coo`: Coordinate list representation. The graph is stored as a tuple of vectors `(s, t, w)`, 
90+           where `s` and `t` are the source and target nodes of the edges, and `w` is the edge weights. 
91+ - `:sparse`: Sparse matrix representation. The graph is stored as a sparse matrix representing the weighted adjacency matrix. 
92+ - `:dense`: Dense matrix representation. The graph is stored as a dense matrix representing the weighted adjacency matrix. 
93+ 
94+ The default representation for graph constructors GNNGraphs.jl is `:coo`. 
95+ The underlying representation can be accessed through the `g.graph` field. 
96+ 
97+ See also [`GNNGraph`](@ref). 
98+ 
99+ # Examples 
100+ 
101+ The default representation for graph constructors GNNGraphs.jl is `:coo`. 
102+ ```jldoctest 
103+ julia> g = rand_graph(5, 10) 
104+ GNNGraph: 
105+   num_nodes: 5 
106+   num_edges: 10 
107+ 
108+ julia> get_graph_type(g) 
109+ :coo 
110+ ``` 
111+ The `GNNGraph` constructor can also be used to create graphs with different representations. 
112+ ```jldoctest 
113+ julia> g = GNNGraph([2,3,5], [1,2,4], graph_type=:sparse) 
114+ GNNGraph: 
115+   num_nodes: 5 
116+   num_edges: 3 
117+ 
118+ julia> g.graph 
119+ 5×5 SparseArrays.SparseMatrixCSC{Int64, Int64} with 3 stored entries: 
120+  ⋅  ⋅  ⋅  ⋅  ⋅ 
121+  1  ⋅  ⋅  ⋅  ⋅ 
122+  ⋅  1  ⋅  ⋅  ⋅ 
123+  ⋅  ⋅  ⋅  ⋅  ⋅ 
124+  ⋅  ⋅  ⋅  1  ⋅ 
125+ 
126+ julia> get_graph_type(g) 
127+ :sparse 
128+ 
129+ julia> gcoo = GNNGraph(g, graph_type=:coo); 
130+ 
131+ julia> gcoo.graph 
132+ ([2, 3, 5], [1, 2, 4], [1, 1, 1]) 
133+ ```  
134+ """ 
135+ get_graph_type (:: GNNGraph{<:COO_T} ) =  :coo 
136+ get_graph_type (:: GNNGraph{<:SPARSE_T} ) =  :sparse 
137+ get_graph_type (:: GNNGraph{<:ADJMAT_T} ) =  :dense 
86138
87139Graphs. nv (g:: GNNGraph ) =  g. num_nodes
88140Graphs. ne (g:: GNNGraph ) =  g. num_edges
0 commit comments