Skip to content

Commit 27c7b2e

Browse files
hkernbachaMahanna
andauthored
[GA-161] prefix node and edge collections by graph name in case of named graph (#22)
* prefox node and edge collections by graph name in case of named graph * undo changes in digraph.py * implement changes in main class and not in specific digraph class * rem newline --------- Co-authored-by: Anthony Mahanna <[email protected]> Co-authored-by: Anthony Mahanna <[email protected]>
1 parent 3f1ab2a commit 27c7b2e

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

nx_arangodb/classes/graph.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ def to_networkx_class(cls) -> type[nx.Graph]:
4040
def __init__(
4141
self,
4242
graph_name: str | None = None,
43-
default_node_type: str = "node",
44-
edge_type_func: Callable[[str, str], str] = lambda u, v: f"{u}_to_{v}",
43+
default_node_type: str | None = None,
44+
edge_type_func: Callable[[str, str], str] | None = None,
4545
db: StandardDatabase | None = None,
4646
*args: Any,
4747
**kwargs: Any,
@@ -70,6 +70,12 @@ def __init__(
7070

7171
self.symmetrize_edges = False # Does not apply to undirected graphs
7272

73+
prefix = f"{graph_name}_" if graph_name else ""
74+
if default_node_type is None:
75+
default_node_type = f"{prefix}node"
76+
if edge_type_func is None:
77+
edge_type_func = lambda u, v: f"{u}_to_{v}" # noqa: E731
78+
7379
self.default_node_type = default_node_type
7480
self.edge_type_func = edge_type_func
7581
self.default_edge_type = edge_type_func(default_node_type, default_node_type)

0 commit comments

Comments
 (0)