Skip to content

Commit e0a8195

Browse files
authored
refactor(cxx): move igraph to the standard library (#83)
This PR completely overhauls and unifies handling of the graph-like structures and visualizations on the library. This is a Phase 1 -- functionally complete, with the core tests added and working, but there are some leftover issues and polish that can be added in some follow-up PR. The changes in this PR are split into several categories - Utility and testing additions to the `hstd::` library: geometry types, geometry checks, various assertions etc, required to test or implement the main graph structure - Base graph implementation: initial idea partially migrated from the org diagramming tool, but updated and expanded to accommodate various graph structures and accomodations. The base graph structure is designed to accommodate visualization needs (hierarchical vertex structures, ports), but everything should be abstracted. - Base visualization class and visualiation backends for ELK, graphviz, libavoid and custom kiwi-based constraint placement solution. - Cascading changes that were implemented to accommodate for the updated API The code removed - `org_diagram` tool -- the idea of using org-mode as a description for the diagram is sound, but the - `adaptagrams_ir` and the adaptagrams wrapeprs: the libadaptagrams library, specifically the libcola component, proved to be too buggy and unreliable to use them consistently, so the whole part of the code was completely removed and replaced with the new, kiwi-based layout solution, which is much more precise and flexible (at the expense of having to specify a lot more underlying elements and not having any overlap avoidance mechanism) The python interoperability for the new implementation is going to be done through protobuf data exchange. - More complex parts of the imgui demo applications, or parts that relied on the old graph IR/visualization to function. This code was a poor example (too complex) and a poor tool (not polished enough, unlikely to be finished). # Overall architecture of the new code ## Base graph structure The graph structure is split into three parts: graph containers, graph objects and graphs IDs. Overall API is similar to the DOD in a sense that objects stored in the collection don't have access to the IDs, and relations between objects are managed through a separate lookup tables/map. The design differs from the regular DOD in a way the data is stored: the stores are virtual classes and may implement set/get functionality in any way they can. Additionally, each object is required to have a unique string ID and it might be used for the reverse lookup. All collection types *may* store the associated objects, but *are not required to*. - `IGraph`: main storage class, holds a collection of vertices and manages `Vertex <> ID` association. Holds the list of other collections: vertex hierarchies, edge collections and port collections. The `IGraph` has a single collection of vertices and vertex IDs that are used in any other operations. - `IEdgeProvider`: base class for edge operations. Edges are managed as an additional overlay on top of the existing vertex collections. Does not support hyper-edges. - `IVertexHierarchy`: tree-like arrangement of the nodes in the graph. Primarily used for the visualization purposes, but is designed in a way that would make it usable for a general tree-like data structures. - `IEdgeCollection`: free-form collection of the edges. Each edge has its own unique associated ID, so the multi-edges and self-loops are possible. - `IPortCollection`: collection of the ports associated with every vertex. The port connection can be related to a vertex or an intersection of a vertex and edge. The ports are not structural elements of the graph, instead they are managed as another overlay on top of the edges+vertices structure. Collections associate IDs (`VertexID`, `PortID`, `EdgeID`) with the corresponding objects (`IVertex`, `IPort`, `IEdge`) respectively, and provide a way to track and un-track the elements in the graph. Each object has a list of attributes: extra data associated with the graph object, in addition to the fields in the derived object itself. The attributes are currently used in the visualization backend to provide a general way to access the visualization data. If protobuf build is enabled, every graph element: collection and object, can be serialized into a predefined protobuf schema, and de-serialized back from it. ## Visualization logic All graph visualization backends were rewritten under a unified API structure, now it is possible to combine the different visualization backends together, and even partially route the edges across different backends. The general algorithm for the visualization is based on the `IVisualAttribute` and its derivatives. - Each backend may associate one visual-attribute derived object with each vertex. - The attributes hold the necessary layout data for the backend. - `IGroupVisualAttribute` holds additional context in form of the `IPlacementAlgorithm`-derived type. This type implements the actual layout logic and returns a mapping `(Vertex|Edge|Port)ID -> ILayoutAttribute` for placing the nodes. All results are relative to the parent, so the each layout algorithm does not require any additional context. ## Visualization backends - **graphviz**: update and refactor of the existing backend, while leaving the original utility API in place. It is still possible to create a quick debug graphviz graph and render it to the PNG file - **kiwi**: new backend created as a replacement to the removed cola constraints. Based on the kiwi constraint solving library, allows to describe the diagram structure as a collection of inequalities and higher-level constraints. The API is simiar to the cola, but less buggy. The backend uses libavoid to route the edges. - **ELK**: Eclipse Layout Kernel, backend already existed in the `org_diagram` tool, now it is moved and integrated into the full package.
2 parents 496f297 + 7d85c8b commit e0a8195

297 files changed

Lines changed: 31195 additions & 29683 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.clang-tidy

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
---
2-
Checks: '-clang-analyzer-core.CallAndMessage'
2+
Checks: '-clang-analyzer-core.CallAndMessage,bugprone-argument-comment,modernize-use-ranges'
33
WarningsAsErrors: true
44
HeaderFilterRegex: ''
55
FormatStyle: google
66
CheckOptions:
77
- key: cert-dcl16-c.NewSuffixes
88
value: 'L;LL;LU;LLU'
9+
# Enables enforcement for boolean and integer literals
10+
- key: bugprone-argument-comment.IgnoreSingleArgument
11+
value: 'true'
12+
# Ensures the comment exactly matches the parameter name
13+
- key: bugprone-argument-comment.StrictMode
14+
value: 'true'

.clangd

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
Hover:
2+
ShowAKA: Yes
3+
Diagnostics:
4+
UnusedIncludes: Strict
5+
Suppress:
6+
- ext_pp_counter
7+
CompileFlags:
8+
CompilationDatabase: build/haxorg_debug_qt/
9+
Add:
10+
- "-Wno-unknown-attributes"
11+
- "-Wno-unused-parameter"
12+
- "-Wno-extra-semi"
13+
- "-Wno-deprecated-copy"
14+
- "-Wno-pedantic"
15+
- "-Wno-missing-field-initializers"
16+
- "-Wno-reorder-init-list"
17+
- "--log=verbose"

.envrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,4 @@ export UV_VERBOSE=1
1717
export HAXORG_REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
1818
# export UV_ENV_FILE=/home/haxscramper/defaultdirs/workspace/haxorg/build/haxorg_release/dev_env
1919
export CMAKE_BUILD_PARALLEL_LEVEL=28
20+
export KDE_DEBUG=1

.fdignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@ thirdparty
33
profdata_merger.sql
44
src/wrappers/js/nodehaxorg.cpp
55

6-
scripts/py_wrappers/py_wrappers/py_adaptagrams.pyi
7-
src/py_libs/py_adaptagrams/adaptagrams_py_wrap.cpp
8-
96
src/wrappers/c/haxorg_c.cpp
107
src/wrappers/c/haxorg_c.h
118
src/wrappers/c/haxorg_c_vtables.cpp

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -550,3 +550,5 @@ CMakeUserPresets.json
550550
!scripts/build
551551
-b
552552
.qtcreator
553+
.haxscramper-code-index.sqlite
554+
**/*.pb.**

.gitmodules

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,9 @@
7373
[submodule "thirdparty/nanobind"]
7474
path = thirdparty/nanobind
7575
url = https://github.com/wjakob/nanobind.git
76+
[submodule "thirdparty/graphviz"]
77+
path = thirdparty/graphviz
78+
url = https://gitlab.com/graphviz/graphviz.git
79+
[submodule "thirdparty/kiwi"]
80+
path = thirdparty/kiwi
81+
url = https://github.com/nucleic/kiwi.git

.pre-commit-config.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
exclude: |
22
(?x)^(
3-
scripts/py_wrappers/py_wrappers/py_adaptagrams\.pyi|
4-
src/py_libs/py_adaptagrams/adaptagrams_py_wrap\.cpp|
53
src/wrappers/js/haxorg_wasm\.cpp|
64
src/wrappers/js/haxorg_wasm_types\.d\.ts|
75
src/wrappers/js/haxorg_c\.cpp|

ARCHITECTURE.org

Lines changed: 0 additions & 104 deletions
This file was deleted.

0 commit comments

Comments
 (0)