@@ -234,7 +234,9 @@ def __repr__(self) -> str:
234
234
]
235
235
return f"{ self .__class__ .__name__ } ({ self ._graph_info (yields = yield_fields ).to_dict ()} )"
236
236
237
- def visualize (self , node_count : int = 100 , center_nodes : Optional [List [int ]] = None ) -> Any :
237
+ def visualize (
238
+ self , node_count : int = 100 , center_nodes : Optional [List [int ]] = None , include_node_properties : List [str ] = None
239
+ ) -> Any :
238
240
visual_graph = self ._name
239
241
if self .node_count () > node_count :
240
242
visual_graph = str (uuid4 ())
@@ -256,11 +258,15 @@ def visualize(self, node_count: int = 100, center_nodes: Optional[List[int]] = N
256
258
custom_error = False ,
257
259
)
258
260
261
+ node_properties = [pr_prop ]
262
+ if include_node_properties is not None :
263
+ node_properties .extend (include_node_properties )
264
+
259
265
result = self ._query_runner .call_procedure (
260
266
endpoint = "gds.graph.nodeProperties.stream" ,
261
267
params = CallParameters (
262
268
graph_name = visual_graph ,
263
- properties = [ pr_prop ] ,
269
+ properties = node_properties ,
264
270
nodeLabels = self .node_labels (),
265
271
config = dict (listNodeLabels = True ),
266
272
),
@@ -312,11 +318,17 @@ def visualize(self, node_count: int = 100, center_nodes: Optional[List[int]] = N
312
318
label_to_color = {label : self ._random_bright_color () for label in self .node_labels ()}
313
319
314
320
for _ , node in node_properties_df .iterrows ():
321
+ title = f"Node ID: { node ['nodeId' ]} \n Labels: { node ['nodeLabels' ]} "
322
+ if include_node_properties is not None :
323
+ title += f"\n Node properties:"
324
+ for prop in include_node_properties :
325
+ title += f"\n { prop } = { node [prop ]} "
326
+
315
327
net .add_node (
316
328
int (node ["nodeId" ]),
317
329
value = node [pr_prop ],
318
330
color = label_to_color [node ["nodeLabels" ][0 ]],
319
- title = str ( node [ "nodeId" ]) ,
331
+ title = title ,
320
332
)
321
333
322
334
# Add all the relationships
0 commit comments