Skip to content

Commit daf0422

Browse files
committed
add '*' for edges
1 parent b4c10ed commit daf0422

File tree

3 files changed

+12
-13
lines changed

3 files changed

+12
-13
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ functions:
102102
which affects the automatic positioning of nodes (same "type"s are preferred to be placed next to each other).
103103
- `parent_configuration`: Configure grouping for this node label. See [configurations_example.ipynb](https://github.com/yWorks/yfiles-jupyter-graphs-for-sparql/blob/main/examples/configurations_example.ipynb)
104104
for examples.
105-
- `heat`: A heat value in between 0 and 1
105+
- `heat`: A heat value in between 0 and 1.
106106

107107
- `add_object_configuration(predicate: Union[str, list[str]], **kwargs: Dict[str, Any])`
108108
- `predicate`: The predicate of the object this configuration should be used for.
@@ -118,16 +118,16 @@ functions:
118118
which affects the automatic positioning of nodes (same "type"s are preferred to be placed next to each other).
119119
- `parent_configuration`: Configure grouping for this node label. See [configurations_example.ipynb](https://github.com/yWorks/yfiles-jupyter-graphs-for-sparql/blob/main/examples/configurations_example.ipynb)
120120
for examples.
121-
- `heat`: A heat value in between 0 and 1
121+
- `heat`: A heat value in between 0 and 1.
122122

123123
- `add_predicate_configuration(type: Union[str, list[str]], **kwargs: Dict[str, Any])`
124-
- `type`: The predicate type for which this configuration should be used.
124+
- `type`: The predicate type(s) for which this configuration should be used. Supports `*` to address all types.
125125
- `**kwargs`: Visualization configuration for the given predicate type. The following arguments are supported:
126126
- `text`: The text that displayed at the edge. By default, the predicate's type is used.
127127
- `color`: The edge's color.
128128
- `thickness_factor`: The edge's stroke thickness factor. By default, `1`.
129129
- `property`: Allows to specify additional properties on the edge, which may be bound by other bindings.
130-
- `heat`: A heat value in between 0 and 1
130+
- `heat`: A heat value in between 0 and 1.
131131

132132

133133
- `add_parent_relationship_configuration(type: Union[str, list[str]], reverse: Optional[bool] = False) -> None`

examples/configurations_example.ipynb

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
},
8484
{
8585
"cell_type": "code",
86-
"execution_count": 3,
86+
"execution_count": 6,
8787
"id": "2407a4f9-c0a0-40e8-8647-b203e7c30fcf",
8888
"metadata": {
8989
"colab": {
@@ -101,7 +101,7 @@
101101
{
102102
"data": {
103103
"application/vnd.jupyter.widget-view+json": {
104-
"model_id": "5187b79b0f1a464e8df29b859a91d8c5",
104+
"model_id": "0f30d0125d424b1c8c265a8a8b212038",
105105
"version_major": 2,
106106
"version_minor": 0
107107
},
@@ -142,7 +142,8 @@
142142
"\n",
143143
"sgw.add_object_configuration('starring', color='purple') #actors\n",
144144
"sgw.add_subject_configuration('director', color='blue', heat=random_heat) #movies\n",
145-
"sgw.add_predicate_configuration(['producer', 'director'], color='orange', heat=lambda edge: 0.5 if edge['properties']['label'] == 'director' else 0.2) # edges\n",
145+
"sgw.add_predicate_configuration(['producer', 'director'], color='orange', heat=lambda edge: 0.5 if edge['properties']['label'] == 'director' else 0.2) # producer and director edges\n",
146+
"sgw.add_predicate_configuration('*', thickness_factor= 2) # all edges, where no specific configuration is given\n",
146147
"sgw.show_query(query)"
147148
]
148149
},
@@ -167,7 +168,7 @@
167168
{
168169
"data": {
169170
"application/vnd.jupyter.widget-view+json": {
170-
"model_id": "e4cde6b70c5c4449aa5fa254bd2577d8",
171+
"model_id": "f4e0d180dc0f4752b8646578d3bc38cc",
171172
"version_major": 2,
172173
"version_minor": 0
173174
},
@@ -217,7 +218,7 @@
217218
{
218219
"data": {
219220
"application/vnd.jupyter.widget-view+json": {
220-
"model_id": "4778c731d6b3466a873034c643030b6a",
221+
"model_id": "830f384f495546c3bcf40ba9e4a615ca",
221222
"version_major": 2,
222223
"version_minor": 0
223224
},

src/yfiles_jupyter_graphs_for_sparql/Yfiles_Sparql_Graphs.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,6 @@ def __init__(self, wrapper=None, limit=50, layout: Optional[str] = 'organic'):
5959
self._wrapper = wrapper
6060
self._graph_layout = layout
6161
self.graph = None
62-
self._node_styling = None
63-
self._edge_styling = None
6462

6563
def set_limit(self, limit):
6664
self.limit = limit
@@ -337,9 +335,9 @@ def mapping(index, item: Dict):
337335
elif label in affected_subjects:
338336
configurations = self._subject_configurations
339337
predicate = affected_subjects[label]
340-
elif label in edge_predicate:
338+
elif label in edge_predicate or '*' in self._edge_configurations:
341339
configurations = self._edge_configurations
342-
predicate = label
340+
predicate = label if label in edge_predicate else '*'
343341

344342
if predicate in configurations and binding_key in configurations[predicate]: # or '*' in configurations
345343
if binding_key == 'parent_configuration':

0 commit comments

Comments
 (0)