Skip to content
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

7 visualization layouts #9

Merged
merged 6 commits into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
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
13 changes: 13 additions & 0 deletions notebooks/custom_layout.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"nodes": {
"color": {
"background": "red",
"border": "orange"
}
},
"init": {},
"rounding": {
"fractions": "False",
"digits": 2
}
}
47 changes: 19 additions & 28 deletions notebooks/die.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -12,36 +12,14 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"# Create a new model with the name \"Die\"\n",
"dtmc = stormvogel.model.new_dtmc(\"Die\")\n",
"\n",
"init = dtmc.get_initial_state()\n",
"\n",
"# From the initial state, add the transition to 6 new states with probability 1/6th.\n",
"init.set_transitions(\n",
" [(1 / 6, dtmc.new_state(f\"rolled{i}\", {\"rolled\": i})) for i in range(6)]\n",
")\n",
"\n",
"# Print the resulting model in dot format.\n",
"# print(dtmc.to_dot())"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"scrolled": true
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"diegraph.html\n"
"model.html\n"
]
},
{
Expand All @@ -51,23 +29,36 @@
" <iframe\n",
" width=\"100%\"\n",
" height=\"600px\"\n",
" src=\"diegraph.html\"\n",
" src=\"model.html\"\n",
" frameborder=\"0\"\n",
" allowfullscreen\n",
" \n",
" ></iframe>\n",
" "
],
"text/plain": [
"<IPython.lib.display.IFrame at 0x7efdc3cc9010>"
"<IPython.lib.display.IFrame at 0x7f91ac3f6d50>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"stormvogel.visualization.show(model=dtmc, name=\"diegraph\")"
"# Create a new model with the name \"Die\"\n",
"dtmc = stormvogel.model.new_dtmc(\"Die\")\n",
"\n",
"init = dtmc.get_initial_state()\n",
"\n",
"# From the initial state, add the transition to 6 new states with probability 1/6th.\n",
"init.set_transitions(\n",
" [(1 / 6, dtmc.new_state(f\"rolled{i}\", {\"rolled\": i})) for i in range(6)]\n",
")\n",
"\n",
"stormvogel.visualization.show(dtmc)\n",
"\n",
"# Print the resulting model in dot format.\n",
"# print(dtmc.to_dot())"
]
},
{
Expand Down
81 changes: 81 additions & 0 deletions notebooks/layouts.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "e0d2c1f7-3a10-4f30-a4d1-2d446de06487",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{'nodes': {'color': {'background': 'white', 'border': 'black'}}, 'init': {'borderWidth': 3, 'color': 'green', 'shape': 'circle'}, 'states': {'borderWidth': 1, 'color': 'None', 'shape': 'circle'}}\n"
]
}
],
"source": [
"import stormvogel.layout\n",
"from stormvogel.layout import DEFAULT"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "8c98f637-ed9c-430b-b414-09c665b307f8",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{'nodes': {'color': {'background': 'red', 'border': 'orange'}}, 'init': {'borderWidth': 3, 'color': 'green', 'shape': 'circle'}, 'states': {'borderWidth': 1, 'color': 'None', 'shape': 'circle'}}\n",
"{'nodes': {'color': {'background': 'red', 'border': 'orange'}}, 'init': {'borderWidth': 3, 'color': 'green', 'shape': 'circle'}, 'states': {'borderWidth': 1, 'color': 'None', 'shape': 'circle'}}\n"
]
}
],
"source": [
"# Import custom layout\n",
"l1 = stormvogel.layout.Layout(\"custom_layout.json\")\n",
"l2 = stormvogel.layout.Layout(path=\"/home/ivo/git/stormvogel/notebooks/custom_layout.json\", path_relative=False)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "0c0b4979-fd00-4393-bf8a-def6d8361ec8",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"id": "c44a1ec0-1d94-431a-b62f-a32df6d35884",
"metadata": {},
"outputs": [],
"source": []
}
],
"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.11.2"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Loading