Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MVP for the graph view (node-link diagrams) #7897

Closed
40 of 49 tasks
grtlr opened this issue Oct 24, 2024 · 1 comment
Closed
40 of 49 tasks

MVP for the graph view (node-link diagrams) #7897

grtlr opened this issue Oct 24, 2024 · 1 comment
Labels
feat-graph-view Everything related to the graph view 🎄 tracking issue issue that tracks a bunch of subissues

Comments

@grtlr
Copy link
Contributor

grtlr commented Oct 24, 2024

This will touch various areas of Rerun so we will split the work up over multiple PRs. This PR is a living document and will be updated to reflect the current status of the implementation.

MVP for 0.21

Initial PR: #7500

Nice to have but can live without

Future work

These item are not required for the 0.21 release

Data Model

Graph Layout & Viewer

We decided to start with implementing force-based layouts, because they support a wide variety of use cases and allow dynamic/temporal graphs out of the box.

  • Support of external layout algorithms through the positions: Position2D component (closed by Implement graph components and archetypes #7500)
  • Investigate other layout options in the Rust ecosystem (fdg, layout-rs, graphviz-rust). All of them have some shortcoming for our use cases.
  • Re-implement force-based layout from d3-force. (⌛ Ongoing)
    • Implementation currently lives here: https://github.com/grtlr/fjadra, but will likely change to Rerun org.
    • Re-implement d3-quadtree to enable Barnes-Hut approximation 🏎️
    • Implement PositionX and PositionY force
    • Implement Collide force
    • Implement ManyBody force
    • Implement remaining forces 🦉

Examples & SDK

@grtlr grtlr added other Generated by the "Other" issue template 👀 needs triage This issue needs to be triaged by the Rerun team labels Oct 24, 2024
@abey79 abey79 added 🎄 tracking issue issue that tracks a bunch of subissues feat-graph-view Everything related to the graph view and removed other Generated by the "Other" issue template 👀 needs triage This issue needs to be triaged by the Rerun team labels Oct 24, 2024
@abey79 abey79 changed the title [Tracking] Support for graphs (node-link diagrams) MVP for the graph view (node-link diagrams) Nov 25, 2024
@abey79 abey79 added this to the 0.21 - Streaming video, Undo milestone Nov 25, 2024
grtlr added a commit that referenced this issue Nov 25, 2024
<!--
Open the PR up as a draft until you feel it is ready for a proper
review.

Do not make PR:s from your own `main` branch, as that makes it difficult
for reviewers to add their own fixes.

Add any improvements to the branch as new commits to make it easier for
reviewers to follow the progress. All commits will be squashed to a
single commit once the PR is merged into `main`.

Make sure you mention any issues that this PR closes in the description,
as well as any other related issues.

To get an auto-generated PR description you can put "copilot:summary" or
"copilot:walkthrough" anywhere.
-->

Tracking issue: #7897 

This implements basic graph primitives in the Rerun data model. This is
a first step towards visualizing node-link diagrams in Rerun (related
issue: #6898).

In addition to the changes to the data model, this PR adds two example
crates, `node_link_graph` and `graph_view` to the Rust examples that
show how these primitives can be used.

## Design Decisions

- Nodes and edges are stored as `components` and can be batched. To have
a single node per entity we can use Rerun’s [[clamping
mechanism](https://rerun.io/docs/concepts/batches#component-clamping)](https://rerun.io/docs/concepts/batches#component-clamping).
- `GraphNodeId` is modeled as ~`u32` to improve performance when using
`petgraph`~ strings for better user experience.
- A node is unique identified by combining its `GraphNodeId` and its
`EntityPath`.
- Labels of the nodes can be set via the `labels` component and toggled
via `show_labels`
- ~Hierarchical graphs can be modeled through entity paths. For edges
that cross entity boundaries we can insert dummy nodes to properly
render subparts of the hierarchy.~
- ~Nodes and edges need to be logged to the same entity, otherwise the
selections will collide. We provider helper functions / conversions to
link nodes that are stored in different entities.~

> [!WARNING]
> This PR has changed considerably from its initial version:
> * No linking of nodes between entities (an therefore hierarchy) yet.
> * For now, Graphs are local only and therefore have to be logged to
the same entity.

## Logging example

```rs
rec.log(
        "simple",
        &rerun::GraphNodes::new(["a", "b", "c"])
            .with_positions([(0.0, 100.0), (-100.0, 0.0), (100.0, 0.0)])
            .with_labels(["A", "B", "C"]),
    )?;
    // Note: We log to the same entity here.
    rec.log(
        "simple",
        &rerun::GraphEdges::new([("a", "b"), ("b", "c"), ("c", "a")]).with_directed_edges(),
    )?;
```

## TODOs

- [x] ~Get rid of the `Default` derive for `GraphNodeId` and `GraphEdge`
in the flatbuffer definitions.~
- [x]  Improve ergonomics for generating graph edges during logging.
- [x]  Ensure that logging works from Python and C++ too.
- [x]  Fix remaining lints.

### Checklist
* [x] I have read and agree to [Contributor
Guide](https://github.com/rerun-io/rerun/blob/main/CONTRIBUTING.md) and
the [Code of
Conduct](https://github.com/rerun-io/rerun/blob/main/CODE_OF_CONDUCT.md)
* [x] I've included a screenshot or gif (if applicable)
* [x] I have tested the web demo (if applicable):
* Using examples from latest `main` build:
[rerun.io/viewer](https://rerun.io/viewer/pr/7500?manifest_url=https://app.rerun.io/version/main/examples_manifest.json)
* Using full set of examples from `nightly` build:
[rerun.io/viewer](https://rerun.io/viewer/pr/7500?manifest_url=https://app.rerun.io/version/nightly/examples_manifest.json)
* [x] The PR title and labels are set such as to maximize their
usefulness for the next release's CHANGELOG
* [x] If applicable, add a new check to the [release
checklist](https://github.com/rerun-io/rerun/blob/main/tests/python/release_checklist)!
* [x] If have noted any breaking changes to the log API in
`CHANGELOG.md` and the migration guide

- [PR Build Summary](https://build.rerun.io/pr/7500)
- [Recent benchmark results](https://build.rerun.io/graphs/crates.html)
- [Wasm size tracking](https://build.rerun.io/graphs/sizes.html)

To run all checks from `main`, comment on the PR with `@rerun-bot
full-check`.

---------

Co-authored-by: Antoine Beyeler <antoine@rerun.io>
Co-authored-by: Andreas Reich <r_andreas2@web.de>
emilk pushed a commit that referenced this issue Nov 25, 2024
<!--
Open the PR up as a draft until you feel it is ready for a proper
review.

Do not make PR:s from your own `main` branch, as that makes it difficult
for reviewers to add their own fixes.

Add any improvements to the branch as new commits to make it easier for
reviewers to follow the progress. All commits will be squashed to a
single commit once the PR is merged into `main`.

Make sure you mention any issues that this PR closes in the description,
as well as any other related issues.

To get an auto-generated PR description you can put "copilot:summary" or
"copilot:walkthrough" anywhere.
-->

Tracking issue: #7897 

This implements basic graph primitives in the Rerun data model. This is
a first step towards visualizing node-link diagrams in Rerun (related
issue: #6898).

In addition to the changes to the data model, this PR adds two example
crates, `node_link_graph` and `graph_view` to the Rust examples that
show how these primitives can be used.

## Design Decisions

- Nodes and edges are stored as `components` and can be batched. To have
a single node per entity we can use Rerun’s [[clamping
mechanism](https://rerun.io/docs/concepts/batches#component-clamping)](https://rerun.io/docs/concepts/batches#component-clamping).
- `GraphNodeId` is modeled as ~`u32` to improve performance when using
`petgraph`~ strings for better user experience.
- A node is unique identified by combining its `GraphNodeId` and its
`EntityPath`.
- Labels of the nodes can be set via the `labels` component and toggled
via `show_labels`
- ~Hierarchical graphs can be modeled through entity paths. For edges
that cross entity boundaries we can insert dummy nodes to properly
render subparts of the hierarchy.~
- ~Nodes and edges need to be logged to the same entity, otherwise the
selections will collide. We provider helper functions / conversions to
link nodes that are stored in different entities.~

> [!WARNING]
> This PR has changed considerably from its initial version:
> * No linking of nodes between entities (an therefore hierarchy) yet.
> * For now, Graphs are local only and therefore have to be logged to
the same entity.

## Logging example

```rs
rec.log(
        "simple",
        &rerun::GraphNodes::new(["a", "b", "c"])
            .with_positions([(0.0, 100.0), (-100.0, 0.0), (100.0, 0.0)])
            .with_labels(["A", "B", "C"]),
    )?;
    // Note: We log to the same entity here.
    rec.log(
        "simple",
        &rerun::GraphEdges::new([("a", "b"), ("b", "c"), ("c", "a")]).with_directed_edges(),
    )?;
```

## TODOs

- [x] ~Get rid of the `Default` derive for `GraphNodeId` and `GraphEdge`
in the flatbuffer definitions.~
- [x]  Improve ergonomics for generating graph edges during logging.
- [x]  Ensure that logging works from Python and C++ too.
- [x]  Fix remaining lints.

### Checklist
* [x] I have read and agree to [Contributor
Guide](https://github.com/rerun-io/rerun/blob/main/CONTRIBUTING.md) and
the [Code of
Conduct](https://github.com/rerun-io/rerun/blob/main/CODE_OF_CONDUCT.md)
* [x] I've included a screenshot or gif (if applicable)
* [x] I have tested the web demo (if applicable):
* Using examples from latest `main` build:
[rerun.io/viewer](https://rerun.io/viewer/pr/7500?manifest_url=https://app.rerun.io/version/main/examples_manifest.json)
* Using full set of examples from `nightly` build:
[rerun.io/viewer](https://rerun.io/viewer/pr/7500?manifest_url=https://app.rerun.io/version/nightly/examples_manifest.json)
* [x] The PR title and labels are set such as to maximize their
usefulness for the next release's CHANGELOG
* [x] If applicable, add a new check to the [release
checklist](https://github.com/rerun-io/rerun/blob/main/tests/python/release_checklist)!
* [x] If have noted any breaking changes to the log API in
`CHANGELOG.md` and the migration guide

- [PR Build Summary](https://build.rerun.io/pr/7500)
- [Recent benchmark results](https://build.rerun.io/graphs/crates.html)
- [Wasm size tracking](https://build.rerun.io/graphs/sizes.html)

To run all checks from `main`, comment on the PR with `@rerun-bot
full-check`.

---------

Co-authored-by: Antoine Beyeler <antoine@rerun.io>
Co-authored-by: Andreas Reich <r_andreas2@web.de>
grtlr added a commit that referenced this issue Nov 29, 2024
### Related

* This is one of the big action items of #7897

<!--
Include links to any related issues/PRs in a bulleted list, for example:
* Closes #1234
* Part of #1337
-->

### What

<!--
Make sure the PR title and labels are set to maximize their usefulness
for the CHANGELOG,
and our `git log`.

If you have noticed any breaking changes, include them in the migration
guide.

We track various metrics at <https://build.rerun.io>.

For maintainers:
* To run all checks from `main`, comment on the PR with `@rerun-bot
full-check`.
* To deploy documentation changes immediately after merging this PR, add
the `deploy docs` label.
-->

It changes two things:

1. Instead of using multiple `egui::Areas`, we now only have a single
top-level area.
2. We compute the sizes of the nodes (information that is important to
the layout) in a single preprocessing path instead of the weird
frame-to-frame computation that we did before.

Overall this will improve code quality, performance, and will unlock new
GraphViz-like layout algorithms (which require defined label size from
the beginning) down the road.

---------

Co-authored-by: Antoine Beyeler <antoine@rerun.io>
@abey79
Copy link
Member

abey79 commented Dec 17, 2024

Closing this as MVP is complete.

@abey79 abey79 closed this as completed Dec 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat-graph-view Everything related to the graph view 🎄 tracking issue issue that tracks a bunch of subissues
Projects
None yet
Development

No branches or pull requests

2 participants