Skip to content

Commit

Permalink
Add the examples.
Browse files Browse the repository at this point in the history
  • Loading branch information
ggservice007 committed Jan 30, 2021
1 parent 0c32222 commit 33a6290
Show file tree
Hide file tree
Showing 22 changed files with 2,627 additions and 163 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,6 @@ python3.7 -m pip uninstall my-happy-graphviz

## how to use
See the examples directory in the project.

## notice
This version can not support the prog='sfdp'.
204 changes: 204 additions & 0 deletions examples/0201_0101_edge.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,204 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# edge"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## unix"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"digraph G {\n",
"size=\"12, 12\";\n",
"node [color=lightblue2, style=filled];\n",
"\"5th Edition\" -> \"6th Edition\";\n",
"\"5th Edition\" -> \"PWB 1.0\";\n",
"\"6th Edition\" -> LSX;\n",
"\"6th Edition\" -> \"1 BSD\";\n",
"\"6th Edition\" -> \"Mini Unix\";\n",
"\"6th Edition\" -> Wollongong;\n",
"\"6th Edition\" -> Interdata;\n",
"Interdata -> \"Unix/TS 3.0\";\n",
"Interdata -> \"PWB 2.0\";\n",
"Interdata -> \"7th Edition\";\n",
"\"7th Edition\" -> \"8th Edition\";\n",
"\"7th Edition\" -> \"32V\";\n",
"\"7th Edition\" -> V7M;\n",
"\"7th Edition\" -> \"Ultrix-11\";\n",
"\"7th Edition\" -> Xenix;\n",
"\"7th Edition\" -> \"UniPlus+\";\n",
"V7M -> \"Ultrix-11\";\n",
"\"8th Edition\" -> \"9th Edition\";\n",
"\"1 BSD\" -> \"2 BSD\";\n",
"\"2 BSD\" -> \"2.8 BSD\";\n",
"\"2.8 BSD\" -> \"Ultrix-11\";\n",
"\"2.8 BSD\" -> \"2.9 BSD\";\n",
"\"32V\" -> \"3 BSD\";\n",
"\"3 BSD\" -> \"4 BSD\";\n",
"\"4 BSD\" -> \"4.1 BSD\";\n",
"\"4.1 BSD\" -> \"4.2 BSD\";\n",
"\"4.1 BSD\" -> \"2.8 BSD\";\n",
"\"4.1 BSD\" -> \"8th Edition\";\n",
"\"4.2 BSD\" -> \"4.3 BSD\";\n",
"\"4.2 BSD\" -> \"Ultrix-32\";\n",
"\"PWB 1.0\" -> \"PWB 1.2\";\n",
"\"PWB 1.0\" -> \"USG 1.0\";\n",
"\"PWB 1.2\" -> \"PWB 2.0\";\n",
"\"USG 1.0\" -> \"CB Unix 1\";\n",
"\"USG 1.0\" -> \"USG 2.0\";\n",
"\"CB Unix 1\" -> \"CB Unix 2\";\n",
"\"CB Unix 2\" -> \"CB Unix 3\";\n",
"\"CB Unix 3\" -> \"Unix/TS++\";\n",
"\"CB Unix 3\" -> \"PDP-11 Sys V\";\n",
"\"USG 2.0\" -> \"USG 3.0\";\n",
"\"USG 3.0\" -> \"Unix/TS 3.0\";\n",
"\"PWB 2.0\" -> \"Unix/TS 3.0\";\n",
"\"Unix/TS 1.0\" -> \"Unix/TS 3.0\";\n",
"\"Unix/TS 3.0\" -> \"TS 4.0\";\n",
"\"Unix/TS++\" -> \"TS 4.0\";\n",
"\"CB Unix 3\" -> \"TS 4.0\";\n",
"\"TS 4.0\" -> \"System V.0\";\n",
"\"System V.0\" -> \"System V.2\";\n",
"\"System V.2\" -> \"System V.3\";\n",
"}\n",
"\n"
]
},
{
"data": {
"text/html": [
"<a href=\"data/output/images/0201_0101_unix.svg\" target=\"blank\"><h4>unix</h4></a>\n",
"<img src=\"data/output/images/0201_0101_unix.svg\" style=\"max-width: 100%\" />"
],
"text/plain": [
"<IPython.core.display.HTML object>"
]
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from my_happy_graphviz import pydot\n",
"from my_happy_jupyter_utils import (\n",
" image_utils\n",
")\n",
"\n",
"\n",
"G = pydot.Dot(graph_type='digraph')\n",
"G.set_size('12, 12')\n",
"\n",
"G.set_node_defaults(color='lightblue2', style='filled')\n",
"\n",
"\n",
"G.add_edge_str('5th Edition', '6th Edition')\n",
"G.add_edge_str('5th Edition', 'PWB 1.0')\n",
"G.add_edge_str('6th Edition', 'LSX')\n",
"G.add_edge_str('6th Edition', '1 BSD')\n",
"G.add_edge_str('6th Edition', 'Mini Unix')\n",
"G.add_edge_str('6th Edition', 'Wollongong')\n",
"G.add_edge_str('6th Edition', 'Interdata')\n",
"G.add_edge_str('Interdata', 'Unix/TS 3.0')\n",
"G.add_edge_str('Interdata', 'PWB 2.0')\n",
"G.add_edge_str('Interdata', '7th Edition')\n",
"G.add_edge_str('7th Edition', '8th Edition')\n",
"G.add_edge_str('7th Edition', '32V')\n",
"G.add_edge_str('7th Edition', 'V7M')\n",
"G.add_edge_str('7th Edition', 'Ultrix-11')\n",
"G.add_edge_str('7th Edition', 'Xenix')\n",
"G.add_edge_str('7th Edition', 'UniPlus+')\n",
"G.add_edge_str('V7M', 'Ultrix-11')\n",
"G.add_edge_str('8th Edition', '9th Edition')\n",
"G.add_edge_str('1 BSD', '2 BSD')\n",
"G.add_edge_str('2 BSD', '2.8 BSD')\n",
"G.add_edge_str('2.8 BSD', 'Ultrix-11')\n",
"G.add_edge_str('2.8 BSD', '2.9 BSD')\n",
"G.add_edge_str('32V', '3 BSD')\n",
"G.add_edge_str('3 BSD', '4 BSD')\n",
"G.add_edge_str('4 BSD', '4.1 BSD')\n",
"G.add_edge_str('4.1 BSD', '4.2 BSD')\n",
"G.add_edge_str('4.1 BSD', '2.8 BSD')\n",
"G.add_edge_str('4.1 BSD', '8th Edition')\n",
"G.add_edge_str('4.2 BSD', '4.3 BSD')\n",
"G.add_edge_str('4.2 BSD', 'Ultrix-32')\n",
"G.add_edge_str('PWB 1.0', 'PWB 1.2')\n",
"G.add_edge_str('PWB 1.0', 'USG 1.0')\n",
"G.add_edge_str('PWB 1.2', 'PWB 2.0')\n",
"G.add_edge_str('USG 1.0', 'CB Unix 1')\n",
"G.add_edge_str('USG 1.0', 'USG 2.0')\n",
"G.add_edge_str('CB Unix 1', 'CB Unix 2')\n",
"G.add_edge_str('CB Unix 2', 'CB Unix 3')\n",
"G.add_edge_str('CB Unix 3', 'Unix/TS++')\n",
"G.add_edge_str('CB Unix 3', 'PDP-11 Sys V')\n",
"G.add_edge_str('USG 2.0', 'USG 3.0')\n",
"G.add_edge_str('USG 3.0', 'Unix/TS 3.0')\n",
"G.add_edge_str('PWB 2.0', 'Unix/TS 3.0')\n",
"G.add_edge_str('Unix/TS 1.0', 'Unix/TS 3.0')\n",
"G.add_edge_str('Unix/TS 3.0', 'TS 4.0')\n",
"G.add_edge_str('Unix/TS++', 'TS 4.0')\n",
"G.add_edge_str('CB Unix 3', 'TS 4.0')\n",
"G.add_edge_str('TS 4.0', 'System V.0')\n",
"G.add_edge_str('System V.0', 'System V.2')\n",
"G.add_edge_str('System V.2', 'System V.3')\n",
"\n",
"print(G.to_string())\n",
"\n",
"file_name = '/'.join([\n",
" 'data/output/images',\n",
" '0201_0101_unix.svg'\n",
"])\n",
"\n",
"G.draw(file_name)\n",
"\n",
"image_utils.show_image_with_title_by_url({\n",
" 'file_path': file_name,\n",
" 'title': 'unix',\n",
"})"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"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.7.7"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
Loading

0 comments on commit 33a6290

Please sign in to comment.