{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from francy_widget import FrancyWidget" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import networkx\n", "G1 = networkx.Graph([(1, 2), (2, 3), (3, 4)]) # graph from list of edges" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "w1 = FrancyWidget(G1, counter=0, title=\"Undirected Graph Example\")\n", "#w1.adapter.to_dict(G1, title=\"Undirected graph\")\n", "#w1.adapter.to_json(G1, title=\"Undirected Graph\")" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "w1" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "G2 = networkx.DiGraph([(1, 2)])\n", "w2 = FrancyWidget(G2, counter=50, title=\"Directed Graph Example\")\n", "w2" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "G3 = networkx.balanced_tree(2,1)\n", "w3 = FrancyWidget(G3, counter=100, title=\"Tree Graph as Directed\", height=200)\n", "#w3.adapter.to_json(G3, title=\"Tree Graph\", height=200, graphType=\"directed\", collapsed=False)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "w3" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "G33 = networkx.DiGraph([('1', 'G'), ('G', 'SG1'), ('G', 'SG2')])\n", "w33 = FrancyWidget(G33, counter=150, title=\"Example Tree Graph\", graphType=\"tree\", collapsed=False) #, nodeTypes=['square', 'circle', 'circle', 'circle'])\n", "#w33.adapter.to_json(G33, title=\"Example Tree Graph\", graphType=\"tree\", collapsed=False) #, nodeTypes=['square', 'circle', 'circle', 'circle'])" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "#w33.adapter.__dict__\n", "#w33.adapter.canvas.__dict__\n", "#w33.adapter.canvas.graph.__dict__\n", "#w33.adapter.to_json(G33)\n", "w33" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from francy_widget.francy_adapter import *\n", "m = FrancyMessage(text=\"There are 8 levels in this Group.\")\n", "m.to_json()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Exporting generated JSON\n", "import json\n", "myjson = json.loads(w33.json_data)\n", "dump = json.dumps(myjson, indent=4, sort_keys=False)\n", "print(dump)\n", "#open(\"test/myjson33.json\", 'w').write(dump)" ] } ], "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.1" } }, "nbformat": 4, "nbformat_minor": 2 }