Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import logging
from typing import Any, Dict


from .algorithm_handler import AlgorithmHandler
from .gds import projected_graph

Expand Down Expand Up @@ -292,7 +291,13 @@ def execute(self, arguments: Dict[str, Any]) -> Any:
class DegreeCentralityHandler(AlgorithmHandler):
def degree_centrality(self, **kwargs):
with projected_graph(self.gds) as G:
centrality = self.gds.degree.stream(G)
params = {
k: v
for k, v in kwargs.items()
if v is not None and k not in ["nodes", "nodeIdentifierProperty"]
}
logger.info(f"Degree centrality parameters: {params}")
centrality = self.gds.degree.stream(G, **params)

# Add node names to the results if nodeIdentifierProperty is provided
node_identifier_property = kwargs.get("nodeIdentifierProperty")
Expand Down Expand Up @@ -332,6 +337,7 @@ def execute(self, arguments: Dict[str, Any]) -> Any:
return self.degree_centrality(
nodes=arguments.get("nodes"),
nodeIdentifierProperty=arguments.get("nodeIdentifierProperty"),
orientation=arguments.get("orientation"),
)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,10 @@
"type": "string",
"description": "Property name to use for identifying nodes (e.g., 'name', 'Name', 'title'). Use get_node_properties_keys to find available properties.",
},
"orientation": {
"type": "string",
"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) ",
},
},
"required": [],
},
Expand Down