Created
May 28, 2018 07:56
-
-
Save notionparallax/53c5b556c98764292f9f076113f033a6 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": 1, | |
"metadata": { | |
"ExecuteTime": { | |
"end_time": "2018-05-28T07:26:39.628000Z", | |
"start_time": "2018-05-28T07:26:38.656000Z" | |
} | |
}, | |
"outputs": [], | |
"source": [ | |
"import pandas as pd\n", | |
"import requests" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 2, | |
"metadata": { | |
"ExecuteTime": { | |
"end_time": "2018-05-28T07:26:41.403000Z", | |
"start_time": "2018-05-28T07:26:39.631000Z" | |
} | |
}, | |
"outputs": [], | |
"source": [ | |
"auth_headers = {'Authorization': 'Bearer keyYXkjYFw61SeWDk'}\n", | |
"techs_table = 'https://api.airtable.com/v0/appuaXpFiadmP89sq/Techs'\n", | |
"r = requests.get(\n", | |
" techs_table,\n", | |
" headers=auth_headers)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 17, | |
"metadata": { | |
"ExecuteTime": { | |
"end_time": "2018-05-28T07:37:47.951000Z", | |
"start_time": "2018-05-28T07:37:47.943000Z" | |
} | |
}, | |
"outputs": [], | |
"source": [ | |
"import ast\n", | |
"d = eval(ast.literal_eval(str(r.content)[1:]))\n", | |
"rowsD = [x[\"fields\"] for x in d[\"records\"]]" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 4, | |
"metadata": { | |
"ExecuteTime": { | |
"end_time": "2018-05-28T07:26:41.522000Z", | |
"start_time": "2018-05-28T07:26:41.499000Z" | |
} | |
}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/html": [ | |
"<div>\n", | |
"<style>\n", | |
" .dataframe thead tr:only-child th {\n", | |
" text-align: right;\n", | |
" }\n", | |
"\n", | |
" .dataframe thead th {\n", | |
" text-align: left;\n", | |
" }\n", | |
"\n", | |
" .dataframe tbody tr th {\n", | |
" vertical-align: top;\n", | |
" }\n", | |
"</style>\n", | |
"<table border=\"1\" class=\"dataframe\">\n", | |
" <thead>\n", | |
" <tr style=\"text-align: right;\">\n", | |
" <th></th>\n", | |
" <th>Field 1</th>\n", | |
" <th>LongName</th>\n", | |
" <th>Name</th>\n", | |
" <th>Other_people_involved</th>\n", | |
" <th>Owner</th>\n", | |
" <th>Type</th>\n", | |
" <th>percentComplete</th>\n", | |
" <th>precursors</th>\n", | |
" </tr>\n", | |
" </thead>\n", | |
" <tbody>\n", | |
" <tr>\n", | |
" <th>15</th>\n", | |
" <td>31</td>\n", | |
" <td>Robotic Desk Arrangement</td>\n", | |
" <td>robDesk</td>\n", | |
" <td>NaN</td>\n", | |
" <td>NaN</td>\n", | |
" <td>NaN</td>\n", | |
" <td>0%</td>\n", | |
" <td>AIlayout,lAmp,robSense</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>26</th>\n", | |
" <td>41</td>\n", | |
" <td>SLAM (Simultanious Location And Mapping)</td>\n", | |
" <td>SLAM</td>\n", | |
" <td>NaN</td>\n", | |
" <td>NaN</td>\n", | |
" <td>NaN</td>\n", | |
" <td>0%</td>\n", | |
" <td>NaN</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>8</th>\n", | |
" <td>36</td>\n", | |
" <td>Sensicorn 2</td>\n", | |
" <td>sensicorn2</td>\n", | |
" <td>NaN</td>\n", | |
" <td>NaN</td>\n", | |
" <td>NaN</td>\n", | |
" <td>0%</td>\n", | |
" <td>mApp,sensicorn1</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>3</th>\n", | |
" <td>10</td>\n", | |
" <td>Unit Desks</td>\n", | |
" <td>desks</td>\n", | |
" <td>NaN</td>\n", | |
" <td>[recHLT6IoCZXwwtp3]</td>\n", | |
" <td>NaN</td>\n", | |
" <td>0%</td>\n", | |
" <td>NaN</td>\n", | |
" </tr>\n", | |
" <tr>\n", | |
" <th>31</th>\n", | |
" <td>33</td>\n", | |
" <td>Robot Mounted Sensing</td>\n", | |
" <td>robSense</td>\n", | |
" <td>NaN</td>\n", | |
" <td>NaN</td>\n", | |
" <td>NaN</td>\n", | |
" <td>0%</td>\n", | |
" <td>basicRobot,sensors,SLAM</td>\n", | |
" </tr>\n", | |
" </tbody>\n", | |
"</table>\n", | |
"</div>" | |
], | |
"text/plain": [ | |
" Field 1 LongName Name \\\n", | |
"15 31 Robotic Desk Arrangement robDesk \n", | |
"26 41 SLAM (Simultanious Location And Mapping) SLAM \n", | |
"8 36 Sensicorn 2 sensicorn2 \n", | |
"3 10 Unit Desks desks \n", | |
"31 33 Robot Mounted Sensing robSense \n", | |
"\n", | |
" Other_people_involved Owner Type percentComplete \\\n", | |
"15 NaN NaN NaN 0% \n", | |
"26 NaN NaN NaN 0% \n", | |
"8 NaN NaN NaN 0% \n", | |
"3 NaN [recHLT6IoCZXwwtp3] NaN 0% \n", | |
"31 NaN NaN NaN 0% \n", | |
"\n", | |
" precursors \n", | |
"15 AIlayout,lAmp,robSense \n", | |
"26 NaN \n", | |
"8 mApp,sensicorn1 \n", | |
"3 NaN \n", | |
"31 basicRobot,sensors,SLAM " | |
] | |
}, | |
"execution_count": 4, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"project_data = pd.DataFrame(rowsD)\n", | |
"project_data.sample(5)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 5, | |
"metadata": { | |
"ExecuteTime": { | |
"end_time": "2018-05-28T07:26:41.529000Z", | |
"start_time": "2018-05-28T07:26:41.525000Z" | |
}, | |
"collapsed": true | |
}, | |
"outputs": [], | |
"source": [ | |
"node_description_pattern = \"{name} [label=\\\"{longName}\\\"];\"\n", | |
"edge_pattern = \"{from_node} -> {to_node};\"" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 15, | |
"metadata": { | |
"ExecuteTime": { | |
"end_time": "2018-05-28T07:36:39.029000Z", | |
"start_time": "2018-05-28T07:36:39.005000Z" | |
} | |
}, | |
"outputs": [], | |
"source": [ | |
"node_descriptions = []\n", | |
"edges = []\n", | |
"\n", | |
"for i, row in project_data.iterrows():\n", | |
" n = node_description_pattern.format(name=row[\"Name\"], longName=row[\"LongName\"])\n", | |
" node_descriptions.append(n)\n", | |
" if type(row[\"precursors\"]) is str:\n", | |
" precursors = row[\"precursors\"].split(\",\")\n", | |
" for p in precursors:\n", | |
" e = edge_pattern.format(from_node=row[\"Name\"], to_node=p)\n", | |
" edges.append(e)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 16, | |
"metadata": { | |
"ExecuteTime": { | |
"end_time": "2018-05-28T07:36:40.348000Z", | |
"start_time": "2018-05-28T07:36:40.341000Z" | |
} | |
}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"\n", | |
"digraph G {\n", | |
" rankdir = \"LR\";\n", | |
" label = \"Tech Tree of OATMEAL Projects\";\n", | |
" labelloc = \"t\";\n", | |
" node [style=filled, color=\"black\", fontcolor=\"white\"];\n", | |
" \n", | |
" potPaper [label=\"A Plane of Thrones Paper\"];\n", | |
" robPaper [label=\"Robotics Papers\"];\n", | |
" deskSenseDn [label=\"Below Desk Sensing\"];\n", | |
" desks [label=\"Unit Desks\"];\n", | |
" deskSenseUp [label=\"Above Desk Sensing\"];\n", | |
" mApp [label=\"Mobile App\"];\n", | |
" geoEthno2 [label=\"Geographic/ Ethnographic data 2\"];\n", | |
" basicBeacon [label=\"iBeacon Awareness\"];\n", | |
" sensicorn2 [label=\"Sensicorn 2\"];\n", | |
" geoEthno1 [label=\"Geographic/ Ethnographic data 1\"];\n", | |
" emailData [label=\"Email Data\"];\n", | |
" RBTM [label=\"Robotic Building Topology Modification\"];\n", | |
" basicRobot [label=\"Awareness of Robots\"];\n", | |
" timeData [label=\"Timesheet Data\"];\n", | |
" SNA [label=\"Social Network Analysis\"];\n", | |
" robDesk [label=\"Robotic Desk Arrangement\"];\n", | |
" Shakedown [label=\"Shakedown data capture\"];\n", | |
" phone [label=\"Access To Phones\"];\n", | |
" halo [label=\"Robotic Weaving\"];\n", | |
" SNAblog [label=\"nan\"];\n", | |
" SydStudioSeating [label=\"Sydney Studio Seating\"];\n", | |
" revit2ML [label=\"Revit Layout Extraction\"];\n", | |
" data [label=\"Data Literacy\"];\n", | |
" sensicorn1 [label=\"Sensicorn 1\"];\n", | |
" SydStudioSeating2 [label=\"Better Sydney Studio Seating\"];\n", | |
" diary [label=\"Diary Studies\"];\n", | |
" SLAM [label=\"SLAM (Simultanious Location And Mapping)\"];\n", | |
" bravo [label=\"Bravo Victor November\"];\n", | |
" pot [label=\"A Plane of Thrones Framework\"];\n", | |
" deskLoc [label=\"Desk Location\"];\n", | |
" electron [label=\"Desktop App\"];\n", | |
" robSense [label=\"Robot Mounted Sensing\"];\n", | |
" boom [label=\"Distribution Boom\"];\n", | |
" AIlayout [label=\"AI Layout\"];\n", | |
" lAmp [label=\"Learning Amplified Seating Plans\"];\n", | |
" bizCap [label=\"Capturing Business Metrics\"];\n", | |
" loTraining [label=\"Layout Training Data\"];\n", | |
" cadd [label=\"Continuous Analysis, Design & Delivery\"];\n", | |
" geoEthno3 [label=\"Geographic/ Ethnographic data 3\"];\n", | |
" ShakedownPaper [label=\"Shakedown Paper\"];\n", | |
" s3 [label=\"S3\"];\n", | |
" sensors [label=\"Sensor Literacy\"];\n", | |
" pathVis [label=\"Path Visualisation\"];\n", | |
" lExp [label=\"Learning Experiment\"];\n", | |
" systemReef [label=\"Systems Reef\"];\n", | |
" Shakedown2 [label=\"Shakedown (with stalls) Product\"];\n", | |
" hardware [label=\"Hardware Design\"];\n", | |
" BTARATA [label=\"Buildings That Are Right All The Time\"];\n", | |
" potPaper -> pot;\n", | |
" potPaper -> revit2ML;\n", | |
" robPaper -> halo;\n", | |
" deskSenseUp -> electron;\n", | |
" deskSenseUp -> s3;\n", | |
" mApp -> phone;\n", | |
" geoEthno2 -> geoEthno1;\n", | |
" geoEthno2 -> deskSenseDn;\n", | |
" sensicorn2 -> mApp;\n", | |
" sensicorn2 -> sensicorn1;\n", | |
" geoEthno1 -> deskLoc;\n", | |
" geoEthno1 -> deskSenseUp;\n", | |
" geoEthno1 -> diary;\n", | |
" RBTM -> robDesk;\n", | |
" SNA -> emailData;\n", | |
" SNA -> timeData;\n", | |
" robDesk -> AIlayout;\n", | |
" robDesk -> lAmp;\n", | |
" robDesk -> robSense;\n", | |
" Shakedown -> sensors;\n", | |
" halo -> basicRobot;\n", | |
" SNAblog -> bravo;\n", | |
" SydStudioSeating -> pot;\n", | |
" sensicorn1 -> hardware;\n", | |
" sensicorn1 -> pathVis;\n", | |
" SydStudioSeating2 -> lAmp;\n", | |
" SydStudioSeating2 -> SydStudioSeating;\n", | |
" diary -> electron;\n", | |
" deskLoc -> basicBeacon;\n", | |
" deskLoc -> desks;\n", | |
" robSense -> basicRobot;\n", | |
" robSense -> sensors;\n", | |
" robSense -> SLAM;\n", | |
" boom -> systemReef;\n", | |
" AIlayout -> loTraining;\n", | |
" lAmp -> lExp;\n", | |
" lAmp -> pot;\n", | |
" lAmp -> SNA;\n", | |
" cadd -> bizCap;\n", | |
" cadd -> geoEthno3;\n", | |
" cadd -> RBTM;\n", | |
" geoEthno3 -> sensicorn2;\n", | |
" geoEthno3 -> geoEthno2;\n", | |
" ShakedownPaper -> Shakedown;\n", | |
" s3 -> hardware;\n", | |
" s3 -> sensors;\n", | |
" sensors -> data;\n", | |
" lExp -> revit2ML;\n", | |
" Shakedown2 -> Shakedown;\n", | |
" BTARATA -> cadd;\n", | |
"}\n", | |
"\n" | |
] | |
} | |
], | |
"source": [ | |
"g = \"\"\"\n", | |
"digraph G {{\n", | |
" rankdir = \"LR\";\n", | |
" label = \"Tech Tree of OATMEAL Projects\";\n", | |
" labelloc = \"t\";\n", | |
" node [style=filled, color=\"black\", fontcolor=\"white\"];\n", | |
" \n", | |
" {nodes}\n", | |
" {edges}\n", | |
"}}\n", | |
"\"\"\".format(edges=\"\\n \".join(edges), nodes=\"\\n \".join(node_descriptions))\n", | |
"\n", | |
"print(g)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 23, | |
"metadata": { | |
"ExecuteTime": { | |
"end_time": "2018-05-28T07:44:49.263000Z", | |
"start_time": "2018-05-28T07:44:49.205000Z" | |
} | |
}, | |
"outputs": [ | |
{ | |
"ename": "FileNotFoundError", | |
"evalue": "[WinError 2] \"dot.exe\" not found in path.", | |
"output_type": "error", | |
"traceback": [ | |
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", | |
"\u001b[1;31mFileNotFoundError\u001b[0m Traceback (most recent call last)", | |
"\u001b[1;32m~\\AppData\\Local\\Continuum\\anaconda3\\envs\\py35\\lib\\site-packages\\pydot.py\u001b[0m in \u001b[0;36mcreate\u001b[1;34m(self, prog, format, encoding)\u001b[0m\n\u001b[0;32m 1860\u001b[0m \u001b[0mshell\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;32mFalse\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 1861\u001b[1;33m stderr=subprocess.PIPE, stdout=subprocess.PIPE)\n\u001b[0m\u001b[0;32m 1862\u001b[0m \u001b[1;32mexcept\u001b[0m \u001b[0mOSError\u001b[0m \u001b[1;32mas\u001b[0m \u001b[0me\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", | |
"\u001b[1;32m~\\AppData\\Local\\Continuum\\anaconda3\\envs\\py35\\lib\\subprocess.py\u001b[0m in \u001b[0;36m__init__\u001b[1;34m(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds)\u001b[0m\n\u001b[0;32m 675\u001b[0m \u001b[0merrread\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0merrwrite\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 676\u001b[1;33m restore_signals, start_new_session)\n\u001b[0m\u001b[0;32m 677\u001b[0m \u001b[1;32mexcept\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", | |
"\u001b[1;32m~\\AppData\\Local\\Continuum\\anaconda3\\envs\\py35\\lib\\subprocess.py\u001b[0m in \u001b[0;36m_execute_child\u001b[1;34m(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, unused_restore_signals, unused_start_new_session)\u001b[0m\n\u001b[0;32m 956\u001b[0m \u001b[0mcwd\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 957\u001b[1;33m startupinfo)\n\u001b[0m\u001b[0;32m 958\u001b[0m \u001b[1;32mfinally\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", | |
"\u001b[1;31mFileNotFoundError\u001b[0m: [WinError 2] The system cannot find the file specified", | |
"\nDuring handling of the above exception, another exception occurred:\n", | |
"\u001b[1;31mFileNotFoundError\u001b[0m Traceback (most recent call last)", | |
"\u001b[1;32m<ipython-input-23-24a4539d4ea6>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[0;32m 23\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 24\u001b[0m \u001b[1;31m# ok, we are set, let's save our graph into a file\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 25\u001b[1;33m \u001b[0mgraph\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mwrite_png\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m'example1_graph.png'\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m", | |
"\u001b[1;32m~\\AppData\\Local\\Continuum\\anaconda3\\envs\\py35\\lib\\site-packages\\pydot.py\u001b[0m in \u001b[0;36mnew_method\u001b[1;34m(path, f, prog, encoding)\u001b[0m\n\u001b[0;32m 1671\u001b[0m self.write(\n\u001b[0;32m 1672\u001b[0m \u001b[0mpath\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mformat\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mf\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mprog\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mprog\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 1673\u001b[1;33m encoding=encoding)\n\u001b[0m\u001b[0;32m 1674\u001b[0m \u001b[0mname\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;34m'write_{fmt}'\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mformat\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mfmt\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mfrmt\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 1675\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m__setattr__\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mname\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mnew_method\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", | |
"\u001b[1;32m~\\AppData\\Local\\Continuum\\anaconda3\\envs\\py35\\lib\\site-packages\\pydot.py\u001b[0m in \u001b[0;36mwrite\u001b[1;34m(self, path, prog, format, encoding)\u001b[0m\n\u001b[0;32m 1754\u001b[0m \u001b[0mf\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mwrite\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0ms\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 1755\u001b[0m \u001b[1;32melse\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 1756\u001b[1;33m \u001b[0ms\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mcreate\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mprog\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mformat\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mencoding\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mencoding\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 1757\u001b[0m \u001b[1;32mwith\u001b[0m \u001b[0mio\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mopen\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mpath\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mmode\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;34m'wb'\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;32mas\u001b[0m \u001b[0mf\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 1758\u001b[0m \u001b[0mf\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mwrite\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0ms\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", | |
"\u001b[1;32m~\\AppData\\Local\\Continuum\\anaconda3\\envs\\py35\\lib\\site-packages\\pydot.py\u001b[0m in \u001b[0;36mcreate\u001b[1;34m(self, prog, format, encoding)\u001b[0m\n\u001b[0;32m 1865\u001b[0m args[1] = '\"{prog}\" not found in path.'.format(\n\u001b[0;32m 1866\u001b[0m prog=prog)\n\u001b[1;32m-> 1867\u001b[1;33m \u001b[1;32mraise\u001b[0m \u001b[0mOSError\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m*\u001b[0m\u001b[0margs\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 1868\u001b[0m \u001b[1;32melse\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 1869\u001b[0m \u001b[1;32mraise\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", | |
"\u001b[1;31mFileNotFoundError\u001b[0m: [WinError 2] \"dot.exe\" not found in path." | |
] | |
} | |
], | |
"source": [ | |
"import pydot\n", | |
"\n", | |
"graph = pydot.Dot(graph_type='graph')\n", | |
"for i in range(3):\n", | |
" # we can get right into action by \"drawing\" edges between the nodes in our graph\n", | |
" # we do not need to CREATE nodes, but if you want to give them some custom style\n", | |
" # then I would recomend you to do so... let's cover that later\n", | |
" # the pydot.Edge() constructor receives two parameters, a source node and a destination\n", | |
" # node, they are just strings like you can see\n", | |
" edge = pydot.Edge(\"king\", \"lord%d\" % i)\n", | |
" # and we obviosuly need to add the edge to our graph\n", | |
" graph.add_edge(edge)\n", | |
"\n", | |
"# now let us add some vassals\n", | |
"vassal_num = 0\n", | |
"for i in range(3):\n", | |
" # we create new edges, now between our previous lords and the new vassals\n", | |
" # let us create two vassals for each lord\n", | |
" for j in range(2):\n", | |
" edge = pydot.Edge(\"lord%d\" % i, \"vassal%d\" % vassal_num)\n", | |
" graph.add_edge(edge)\n", | |
" vassal_num += 1\n", | |
"\n", | |
"# ok, we are set, let's save our graph into a file\n", | |
"graph.write_png('example1_graph.png')" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": { | |
"ExecuteTime": { | |
"end_time": "2018-05-28T07:46:38.393000Z", | |
"start_time": "2018-05-28T07:46:38.374000Z" | |
} | |
}, | |
"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.5.4" | |
}, | |
"toc": { | |
"nav_menu": {}, | |
"number_sections": true, | |
"sideBar": true, | |
"skip_h1_title": false, | |
"toc_cell": false, | |
"toc_position": {}, | |
"toc_section_display": "block", | |
"toc_window_display": false | |
}, | |
"varInspector": { | |
"cols": { | |
"lenName": 16, | |
"lenType": 16, | |
"lenVar": 40 | |
}, | |
"kernels_config": { | |
"python": { | |
"delete_cmd_postfix": "", | |
"delete_cmd_prefix": "del ", | |
"library": "var_list.py", | |
"varRefreshCmd": "print(var_dic_list())" | |
}, | |
"r": { | |
"delete_cmd_postfix": ") ", | |
"delete_cmd_prefix": "rm(", | |
"library": "var_list.r", | |
"varRefreshCmd": "cat(var_dic_list()) " | |
} | |
}, | |
"types_to_exclude": [ | |
"module", | |
"function", | |
"builtin_function_or_method", | |
"instance", | |
"_Feature" | |
], | |
"window_display": false | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 2 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment