Skip to content

Commit 9b704ad

Browse files
Support orientation in degree centrality
1 parent 4dfdb89 commit 9b704ad

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

mcp_server/src/mcp_server_neo4j_gds/centrality_algorithm_handlers.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,13 @@ def execute(self, arguments: Dict[str, Any]) -> Any:
292292
class DegreeCentralityHandler(AlgorithmHandler):
293293
def degree_centrality(self, **kwargs):
294294
with projected_graph(self.gds) as G:
295-
centrality = self.gds.degree.stream(G)
295+
params = {
296+
k: v
297+
for k, v in kwargs.items()
298+
if v is not None and k not in ["nodes","nodeIdentifierProperty"]
299+
}
300+
logger.info(f"Degree centrality parameters: {params}")
301+
centrality = self.gds.degree.stream(G, **params)
296302

297303
# Add node names to the results if nodeIdentifierProperty is provided
298304
node_identifier_property = kwargs.get("nodeIdentifierProperty")
@@ -332,6 +338,7 @@ def execute(self, arguments: Dict[str, Any]) -> Any:
332338
return self.degree_centrality(
333339
nodes=arguments.get("nodes"),
334340
nodeIdentifierProperty=arguments.get("nodeIdentifierProperty"),
341+
orientation=arguments.get("orientation"),
335342
)
336343

337344

mcp_server/src/mcp_server_neo4j_gds/centrality_algorithm_specs.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,10 @@
186186
"type": "string",
187187
"description": "Property name to use for identifying nodes (e.g., 'name', 'Name', 'title'). Use get_node_properties_keys to find available properties.",
188188
},
189+
"orientation": {
190+
"type": "string",
191+
"description": "The orientation used to compute node degrees. Supported orientations are NATURAL (for out-degree), REVERSE (for in-degree) and UNDIRECTED (for both in-degree and out-degree) ",
192+
},
189193
},
190194
"required": [],
191195
},

0 commit comments

Comments
 (0)