-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
180 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,158 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"id": "4fba42bb-4dc4-44ce-bc12-bd2ca942c95f", | ||
"metadata": {}, | ||
"source": [ | ||
"# yFiles Graphs for Jupyter v1.9 <a target=\"_blank\" href=\"https://colab.research.google.com/github/yWorks/yfiles-jupyter-graphs/blob/main/examples/feature-releases/v1.9.ipynb\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>\n", | ||
"\n", | ||
"Before using the graph widget, install all necessary packages and initialize your widget." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "e3d2ef93-7793-4a32-b3d6-e1b31cb54846", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"%pip install yfiles_jupyter_graphs --quiet\n", | ||
"from yfiles_jupyter_graphs import GraphWidget\n", | ||
"\n", | ||
"# sample graph for this notebook\n", | ||
"%pip install networkx --quiet\n", | ||
"from networkx import florentine_families_graph" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "37116e66-b781-458f-8983-d6d613d4002f", | ||
"metadata": {}, | ||
"source": [ | ||
"You can also open this notebook in Google Colab when Google Colab's custom widget manager is enabled:" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "e971e703-1a83-432b-a7f5-c3a9c62c5afd", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"try:\n", | ||
" import google.colab\n", | ||
" from google.colab import output\n", | ||
" output.enable_custom_widget_manager()\n", | ||
"except:\n", | ||
" pass" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "d8a0a973-6626-4f88-9d90-425785af20fd", | ||
"metadata": {}, | ||
"source": [ | ||
"<a target=\"_blank\" href=\"https://colab.research.google.com/github/yWorks/yfiles-jupyter-graphs/blob/main/examples/feature-releases/v1.9.ipynb\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "29e0f82c-2662-4130-92f9-c2660e42b5b5", | ||
"metadata": {}, | ||
"source": [ | ||
"# Changelog\n", | ||
"\n", | ||
"## New features\n", | ||
"* Support a configurable node-to-cell mapping that is considered by the automatic layout algorithms such that nodes are placed in the given grid cell. Typical use cases may be to highlight a critical path structurally by aligning these nodes in a row/column.\n", | ||
"* Added `circular_straight_line` as new layout option that creates a circular layout with straight connections, instead of the bundled connections of the existing `circular` layout.\n", | ||
"\n", | ||
"## Improvements\n", | ||
"* Adjusted the interactive organic layout settings to make the result more airy.\n", | ||
"* Saved the executed Google Colab state in the example notebooks such that the widget can be tried without executing the notebook in Google Colab.\n", | ||
"\n", | ||
"## Bugfixes\n", | ||
"* Fixed widget resizing issue after switching from map-view to the normal graph view." | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "76b5303d-66f7-4476-b6bb-268889721efa", | ||
"metadata": {}, | ||
"source": [ | ||
"# Node-cell mapping\n", | ||
"\n", | ||
"The new `node_cell` mapping allows to assign specific cells for nodes. This information is considered by the automatic layout algorithms and helps to fine-tune the result, for example to highlight specific structures of the graph or to convey critical information." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "0181b651-b887-4372-9d44-192f7e291f22", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"w = GraphWidget(graph=florentine_families_graph())\n", | ||
"\n", | ||
"# highlight Medici marriage line\n", | ||
"medici_line = [\"Acciaiuoli\", \"Medici\", \"Albizzi\", \"Guadagni\", \"Lamberteschi\"]\n", | ||
"w.node_color_mapping = lambda node: \"#FF5722\" if node[\"properties\"][\"label\"] in medici_line else \"#78909C\"\n", | ||
"\n", | ||
"# separate the Medici marriage line from the other families in the graph\n", | ||
"def node_to_cell_mapping(node):\n", | ||
" family = node[\"properties\"][\"label\"]\n", | ||
" return (0, 0) if family in medici_line else (0, 2)\n", | ||
"\n", | ||
"w.node_cell_mapping = node_to_cell_mapping\n", | ||
"w.hierarchic_layout()\n", | ||
"display(w)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "86f0af76-445c-4486-acd0-8a58a19670a9", | ||
"metadata": {}, | ||
"source": [ | ||
"# New `circular_straight_line` layout option" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "5cdbeb2a-d7bf-41ec-a63e-859ebeda3156", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from networkx import florentine_families_graph\n", | ||
"\n", | ||
"w = GraphWidget(graph=florentine_families_graph())\n", | ||
"\n", | ||
"# configure a circular layout with straight, unbundled connections\n", | ||
"w.circular_straight_line_layout()\n", | ||
"\n", | ||
"display(w)" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3 (ipykernel)", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.12.3" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters