@@ -265,7 +265,7 @@ def _run_one(graph: ProgramGraph) -> str:
265
265
def to_pyg (
266
266
graphs : Union [ProgramGraph , Iterable [ProgramGraph ]],
267
267
timeout : int = 300 ,
268
- vocabulary : Dict [str , int ] = None ,
268
+ vocabulary : Optional [ Dict [str , int ] ] = None ,
269
269
executor : Optional [ExecutorLike ] = None ,
270
270
chunksize : Optional [int ] = None ,
271
271
) -> Union [HeteroData , Iterable [HeteroData ]]:
@@ -281,6 +281,10 @@ def to_pyg(
281
281
graph conversion before raising an error. If multiple inputs are
282
282
provided, this timeout is per-input.
283
283
284
+ :param vocabulary: A dictionary containing ProGraML's vocabulary, where the
285
+ keys are the text attribute of the nodes and the values their respective
286
+ indexes.
287
+
284
288
:param executor: An executor object, with method :code:`submit(callable,
285
289
*args, **kwargs)` and returning a Future-like object with methods
286
290
:code:`done() -> bool` and :code:`result() -> float`. The executor role
@@ -299,16 +303,17 @@ def to_pyg(
299
303
"""
300
304
301
305
def _run_one (graph : ProgramGraph ) -> HeteroData :
302
- # 3 lists, one per edge type
303
- # (control, data and call edges)
306
+ # 4 lists, one per edge type
307
+ # (control, data, call and type edges)
304
308
adjacencies = [[], [], [], []]
305
309
edge_positions = [[], [], [], []]
306
310
307
- # Create the adjacency lists
311
+ # Create the adjacency lists and the positions
308
312
for edge in graph .edge :
309
313
adjacencies [edge .flow ].append ([edge .source , edge .target ])
310
314
edge_positions [edge .flow ].append (edge .position )
311
315
316
+ # Store the text attributes
312
317
node_text = [node .text for node in graph .node ]
313
318
314
319
vocab_ids = None
0 commit comments