Skip to content

[GA-161] prefix node and edge collections by graph name in case of named graph #22

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Aug 6, 2024
Merged
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
10 changes: 8 additions & 2 deletions nx_arangodb/classes/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand Down