From e04ee8fadcd96ffbdc755640d101939560c5c7bd Mon Sep 17 00:00:00 2001 From: hkernbach Date: Tue, 6 Aug 2024 09:24:58 +0200 Subject: [PATCH 1/4] prefox node and edge collections by graph name in case of named graph --- nx_arangodb/classes/digraph.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/nx_arangodb/classes/digraph.py b/nx_arangodb/classes/digraph.py index e92e049f..a0c3b471 100644 --- a/nx_arangodb/classes/digraph.py +++ b/nx_arangodb/classes/digraph.py @@ -32,8 +32,14 @@ def __init__( *args: Any, **kwargs: Any, ): + self.edge_type_func = edge_type_func + self.default_node_type = default_node_type + if graph_name is not None: + self.edge_type_func = lambda u, v: f"{graph_name}_{u}_to_{v}" + self.default_node_type = f"{graph_name}_node" + super().__init__( - graph_name, default_node_type, edge_type_func, db, *args, **kwargs + graph_name, self.default_node_type, self.edge_type_func, db, *args, **kwargs ) self.symmetrize_edges = symmetrize_edges From 3c76554eeaa257c78f20c6b12b2843b066048d2d Mon Sep 17 00:00:00 2001 From: hkernbach Date: Tue, 6 Aug 2024 17:04:04 +0200 Subject: [PATCH 2/4] undo changes in digraph.py --- nx_arangodb/classes/digraph.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/nx_arangodb/classes/digraph.py b/nx_arangodb/classes/digraph.py index a0c3b471..0aa62339 100644 --- a/nx_arangodb/classes/digraph.py +++ b/nx_arangodb/classes/digraph.py @@ -32,14 +32,9 @@ def __init__( *args: Any, **kwargs: Any, ): - self.edge_type_func = edge_type_func - self.default_node_type = default_node_type - if graph_name is not None: - self.edge_type_func = lambda u, v: f"{graph_name}_{u}_to_{v}" - self.default_node_type = f"{graph_name}_node" super().__init__( - graph_name, self.default_node_type, self.edge_type_func, db, *args, **kwargs + graph_name, default_node_type, edge_type_func, db, *args, **kwargs ) self.symmetrize_edges = symmetrize_edges From 01bb210ba3f1029d8562f65e4355d71aabe328d5 Mon Sep 17 00:00:00 2001 From: hkernbach Date: Tue, 6 Aug 2024 17:18:02 +0200 Subject: [PATCH 3/4] implement changes in main class and not in specific digraph class --- nx_arangodb/classes/graph.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/nx_arangodb/classes/graph.py b/nx_arangodb/classes/graph.py index bd8244b1..9cc69b9a 100644 --- a/nx_arangodb/classes/graph.py +++ b/nx_arangodb/classes/graph.py @@ -40,8 +40,8 @@ def to_networkx_class(cls) -> type[nx.Graph]: def __init__( self, graph_name: str | None = None, - default_node_type: str = "node", - edge_type_func: Callable[[str, str], str] = lambda u, v: f"{u}_to_{v}", + default_node_type: str | None = None, + edge_type_func: Callable[[str, str], str] | None = None, db: StandardDatabase | None = None, *args: Any, **kwargs: Any, @@ -70,6 +70,12 @@ def __init__( self.symmetrize_edges = False # Does not apply to undirected graphs + prefix = f"{graph_name}_" if graph_name else "" + if default_node_type is None: + default_node_type = f"{prefix}node" + if edge_type_func is None: + edge_type_func = lambda u, v: f"{u}_to_{v}" # noqa: E731 + self.default_node_type = default_node_type self.edge_type_func = edge_type_func self.default_edge_type = edge_type_func(default_node_type, default_node_type) From dafd1e062b1c9f7e7bdc2b10d4262178378808c1 Mon Sep 17 00:00:00 2001 From: Anthony Mahanna Date: Tue, 6 Aug 2024 16:28:39 -0400 Subject: [PATCH 4/4] rem newline --- nx_arangodb/classes/digraph.py | 1 - 1 file changed, 1 deletion(-) diff --git a/nx_arangodb/classes/digraph.py b/nx_arangodb/classes/digraph.py index 0aa62339..e92e049f 100644 --- a/nx_arangodb/classes/digraph.py +++ b/nx_arangodb/classes/digraph.py @@ -32,7 +32,6 @@ def __init__( *args: Any, **kwargs: Any, ): - super().__init__( graph_name, default_node_type, edge_type_func, db, *args, **kwargs )