Skip to content

Instantly share code, notes, and snippets.

@N-Coder
Last active March 7, 2023 15:23
Show Gist options
  • Save N-Coder/e221d47dc65b312a8dfa9c7b701b4c56 to your computer and use it in GitHub Desktop.
Save N-Coder/e221d47dc65b312a8dfa9c7b701b4c56 to your computer and use it in GitHub Desktop.
OGDF binder
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "daeb1a0c-878c-4873-9269-7653ad0a9408",
"metadata": {},
"outputs": [],
"source": [
"// conda doesn't properly set the install path of the OGDF, so set it manually\n",
"#pragma cling add_include_path(\"/srv/conda/envs/notebook/include/\") // contains ogdf/ folder with headers\n",
"#pragma cling add_library_path(\"/srv/conda/envs/notebook/lib/\") // contains libOGDF.so\n",
"#pragma cling load(\"libOGDF.so\")\n",
"\n",
"#include <ogdf/energybased/FMMMLayout.h>\n",
"#include <ogdf/fileformats/GraphIO.h>\n",
"#include <ogdf/basic/graph_generators/randomized.h>\n",
"\n",
"using namespace ogdf;\n",
" \n",
"Graph G;\n",
"GraphAttributes GA(G);\n",
"setSeed(1);\n",
"randomPlanarTriconnectedGraph(G, 20, 40);\n",
"\n",
"for (node v : G.nodes)\n",
" GA.width(v) = GA.height(v) = 5.0;\n",
"\n",
"FMMMLayout fmmm;\n",
"\n",
"fmmm.useHighLevelOptions(true);\n",
"fmmm.unitEdgeLength(15.0);\n",
"fmmm.newInitialPlacement(true);\n",
"fmmm.qualityVersusSpeed(FMMMOptions::QualityVsSpeed::GorgeousAndEfficient);\n",
"\n",
"fmmm.call(GA);\n",
"GraphIO::write(GA, \"output.gml\");\n",
"GraphIO::write(GA, \"output.svg\");"
]
},
{
"cell_type": "markdown",
"id": "4d29eec6-9287-4be3-96de-559517cdef41",
"metadata": {},
"source": [
"Edit this markdown cell and save it again to update the display.\n",
"![output.svg](./output.svg)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "C++17",
"language": "C++17",
"name": "xcpp17"
},
"language_info": {
"codemirror_mode": "text/x-c++src",
"file_extension": ".cpp",
"mimetype": "text/x-c++src",
"name": "c++",
"version": "17"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
name: default
channels:
- conda-forge
dependencies:
- cmake
- cxx-compiler
- xeus-cling
- pip:
- ogdf-python
# - ogdf-python-widget
- ogdf-wheel
Creator "ogdf::GraphIO::writeGML"
graph
[
directed 1
node
[
id 0
graphics
[
x 109.0000000000
y 17.0000000000
w 5.0000000000
h 5.0000000000
type "Rect"
]
]
node
[
id 1
graphics
[
x 104.0000000000
y 38.0000000000
w 5.0000000000
h 5.0000000000
type "Rect"
]
]
node
[
id 2
graphics
[
x 69.0000000000
y 57.0000000000
w 5.0000000000
h 5.0000000000
type "Rect"
]
]
node
[
id 3
graphics
[
x 23.0000000000
y 60.0000000000
w 5.0000000000
h 5.0000000000
type "Rect"
]
]
node
[
id 4
graphics
[
x 61.0000000000
y 76.0000000000
w 5.0000000000
h 5.0000000000
type "Rect"
]
]
node
[
id 5
graphics
[
x 100.0000000000
y 60.0000000000
w 5.0000000000
h 5.0000000000
type "Rect"
]
]
node
[
id 6
graphics
[
x 66.0000000000
y 67.0000000000
w 5.0000000000
h 5.0000000000
type "Rect"
]
]
node
[
id 7
graphics
[
x 17.0000000000
y 38.0000000000
w 5.0000000000
h 5.0000000000
type "Rect"
]
]
node
[
id 8
graphics
[
x 86.0000000000
y 72.0000000000
w 5.0000000000
h 5.0000000000
type "Rect"
]
]
node
[
id 9
graphics
[
x 64.0000000000
y 28.0000000000
w 5.0000000000
h 5.0000000000
type "Rect"
]
]
node
[
id 10
graphics
[
x 26.0000000000
y 50.0000000000
w 5.0000000000
h 5.0000000000
type "Rect"
]
]
node
[
id 11
graphics
[
x 43.0000000000
y 75.0000000000
w 5.0000000000
h 5.0000000000
type "Rect"
]
]
node
[
id 12
graphics
[
x 109.0000000000
y 37.0000000000
w 5.0000000000
h 5.0000000000
type "Rect"
]
]
node
[
id 13
graphics
[
x 85.0000000000
y 51.0000000000
w 5.0000000000
h 5.0000000000
type "Rect"
]
]
node
[
id 14
graphics
[
x 88.0000000000
y 27.0000000000
w 5.0000000000
h 5.0000000000
type "Rect"
]
]
node
[
id 15
graphics
[
x 108.0000000000
y 60.0000000000
w 5.0000000000
h 5.0000000000
type "Rect"
]
]
node
[
id 16
graphics
[
x 107.0000000000
y 80.0000000000
w 5.0000000000
h 5.0000000000
type "Rect"
]
]
node
[
id 17
graphics
[
x 85.0000000000
y 41.0000000000
w 5.0000000000
h 5.0000000000
type "Rect"
]
]
node
[
id 18
graphics
[
x 40.0000000000
y 35.0000000000
w 5.0000000000
h 5.0000000000
type "Rect"
]
]
node
[
id 19
graphics
[
x 46.0000000000
y 58.0000000000
w 5.0000000000
h 5.0000000000
type "Rect"
]
]
edge
[
source 0
target 1
graphics
[
type "line"
arrow "last"
]
]
edge
[
source 9
target 17
graphics
[
type "line"
arrow "last"
]
]
edge
[
source 9
target 18
graphics
[
type "line"
arrow "last"
]
]
edge
[
source 8
target 5
graphics
[
type "line"
arrow "last"
]
]
edge
[
source 13
target 6
graphics
[
type "line"
arrow "last"
]
]
edge
[
source 2
target 19
graphics
[
type "line"
arrow "last"
]
]
edge
[
source 11
target 4
graphics
[
type "line"
arrow "last"
]
]
edge
[
source 4
target 2
graphics
[
type "line"
arrow "last"
]
]
edge
[
source 2
target 17
graphics
[
type "line"
arrow "last"
]
]
edge
[
source 4
target 6
graphics
[
type "line"
arrow "last"
]
]
edge
[
source 6
target 11
graphics
[
type "line"
arrow "last"
]
]
edge
[
source 3
target 7
graphics
[
type "line"
arrow "last"
]
]
edge
[
source 13
target 8
graphics
[
type "line"
arrow "last"
]
]
edge
[
source 16
target 15
graphics
[
type "line"
arrow "last"
]
]
edge
[
source 14
target 9
graphics
[
type "line"
arrow "last"
]
]
edge
[
source 7
target 10
graphics
[
type "line"
arrow "last"
]
]
edge
[
source 19
target 3
graphics
[
type "line"
arrow "last"
]
]
edge
[
source 3
target 11
graphics
[
type "line"
arrow "last"
]
]
edge
[
source 0
target 12
graphics
[
type "line"
arrow "last"
]
]
edge
[
source 15
target 1
graphics
[
type "line"
arrow "last"
]
]
edge
[
source 1
target 13
graphics
[
type "line"
arrow "last"
]
]
edge
[
source 0
target 14
graphics
[
type "line"
arrow "last"
]
]
edge
[
source 14
target 12
graphics
[
type "line"
arrow "last"
]
]
edge
[
source 12
target 15
graphics
[
type "line"
arrow "last"
]
]
edge
[
source 8
target 16
graphics
[
type "line"
arrow "last"
]
]
edge
[
source 16
target 5
graphics
[
type "line"
arrow "last"
]
]
edge
[
source 5
target 17
graphics
[
type "line"
arrow "last"
]
]
edge
[
source 7
target 18
graphics
[
type "line"
arrow "last"
]
]
edge
[
source 18
target 10
graphics
[
type "line"
arrow "last"
]
]
edge
[
source 10
target 19
graphics
[
type "line"
arrow "last"
]
]
edge
[
source 8
target 4
graphics
[
type "line"
arrow "last"
]
]
edge
[
source 13
target 14
graphics
[
type "line"
arrow "last"
]
]
edge
[
source 19
target 4
graphics
[
type "line"
arrow "last"
]
]
edge
[
source 8
target 2
graphics
[
type "line"
arrow "last"
]
]
edge
[
source 19
target 11
graphics
[
type "line"
arrow "last"
]
]
edge
[
source 18
target 19
graphics
[
type "line"
arrow "last"
]
]
edge
[
source 8
target 6
graphics
[
type "line"
arrow "last"
]
]
edge
[
source 15
target 8
graphics
[
type "line"
arrow "last"
]
]
edge
[
source 17
target 12
graphics
[
type "line"
arrow "last"
]
]
edge
[
source 1
target 14
graphics
[
type "line"
arrow "last"
]
]
]
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment