Skip to content

Commit

Permalink
rename optional parameter to layout
Browse files Browse the repository at this point in the history
  • Loading branch information
fskpf committed Oct 16, 2024
1 parent e2aa31b commit 065897d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ The main class `Neo4jGraphWidget` provides the following API:

- `Neo4jGraphWidget`: Creates a new class instance with the following arguments

| Argument | Description | Default |
|--------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------|
| `driver` | The neo4j `driver` that is used to execute cypher queries. | `None` |
| `widget_layout` | Can be used to specify general widget appearance through css attributes. See ipywidget's [`layout`](https://ipywidgets.readthedocs.io/en/stable/examples/Widget%20Layout.html#the-layout-attribute) for more information. | `None` |
| `overview_enabled` | Enable graph overview component. Default behaviour depends on cell width. | `None` |
| `graph_layout` | Can be used to specify a general default node and edge layout. Available algorithms are: ["circular", "hierarchic", "organic", "orthogonal", "radial", "tree", "orthogonal_edge_router", "organic_edge_router", "interactive_organic_layout", "map"] | `organic` |
| Argument | Description | Default |
|--------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------|
| `driver` | The neo4j `driver` that is used to execute cypher queries. | `None` |
| `widget_layout` | Can be used to specify general widget appearance through css attributes. See ipywidget's [`layout`](https://ipywidgets.readthedocs.io/en/stable/examples/Widget%20Layout.html#the-layout-attribute) for more information. | `None` |
| `overview_enabled` | Enable graph overview component. Default behaviour depends on cell width. | `None` |
| `graph_layout` | Can be used to specify a general default node and edge layout. Available algorithms are: "circular", "hierarchic", "organic", "interactive_organic_layout", "orthogonal", "radial", "tree", "map", "orthogonal_edge_router", "organic_edge_router" | `organic` |

### Methods

Expand All @@ -64,14 +64,14 @@ The main class `Neo4jGraphWidget` provides the following API:
- `graph_layout`: The graph layout that is used. This overwrites the general graph_layout in this specific graph instance. The following arguments are supported:
- `hierarchic`
- `organic`
- `interactive_organic_layout`
- `circular`
- `orthogonal`
- `tree`
- `radial`
- `map`
- `orthogonal_edge_router`
- `organic_edge_router`
- `interactive_organic_layout`
- `map`
- `**kwargs`: Additional parameters that should be passed to the cypher query (e.g., see
the [selection example](https://github.com/yWorks/yfiles-jupyter-graphs-for-neo4j/blob/main/examples/selection_example.ipynb)).

Expand Down
16 changes: 10 additions & 6 deletions src/yfiles_jupyter_graphs_for_neo4j/Yfiles_Neo4j_Graphs.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
class Neo4jGraphWidget:
def __init__(self, driver=None, widget_layout=None,
overview_enabled=None, context_start_with=None, license=None,
autocomplete_relationships=False, graph_layout='organic'):
autocomplete_relationships=False, layout='organic'):
self._widget = GraphWidget()
self._driver = driver
self._session = driver.session()
Expand All @@ -27,7 +27,7 @@ def __init__(self, driver=None, widget_layout=None,
self._layout = widget_layout
self._context_start_with = context_start_with
self.set_autocomplete_relationships(autocomplete_relationships)
self._graph_layout = graph_layout
self._graph_layout = layout

self._node_configurations = {}
self._edge_configurations = {}
Expand Down Expand Up @@ -76,11 +76,15 @@ def _get_relationship_types_expression(self):
return "AND type(rel) IN $relationship_types"
return ""

def show_cypher(self, cypher, graph_layout=None, **kwargs):
def show_cypher(self, cypher, layout=None, **kwargs):
"""
main function
:param cypher: str, Send a data query to the neo4j database
**kwargs: variable declarations usable in cypher
layout: str, The graph layout for this request. Overwrites the general graph_layout in this specific graph
instance. Allowed values are (one of "circular", "hierarchic", "organic",
"interactive_organic_layout", "orthogonal", "radial", "tree", "map", "orthogonal_edge_router",
"organic_edge_router").
**kwargs: Variable declarations usable in cypher
"""
if self._driver is not None:
if self._is_autocomplete_enabled():
Expand Down Expand Up @@ -108,10 +112,10 @@ def show_cypher(self, cypher, graph_layout=None, **kwargs):
self.__apply_edge_mappings(widget)
self.__apply_heat_mapping({**self._node_configurations, **self._edge_configurations}, widget)
self.__apply_parent_mapping(widget)
if graph_layout is None:
if layout is None:
widget.set_graph_layout(self._graph_layout)
else:
widget.set_graph_layout(graph_layout)
widget.set_graph_layout(layout)

self._widget = widget
widget.show()
Expand Down

0 comments on commit 065897d

Please sign in to comment.