Skip to content

Commit

Permalink
Merge branch 'main' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
li3zhen1 committed Oct 10, 2023
2 parents ecce85e + f6a5e67 commit a60e88c
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,19 @@ A visualization-purposed force simulation library.

<img width="712" alt="ForceDirectedGraphLight" src="https://github.com/li3zhen1/Grape/assets/45376537/e0e8049d-25c2-4e5c-9623-6bf43ddddfa5">

#### Examples
### Examples

This is a force directed graph visualizing the data from [Force Directed Graph Component](https://observablehq.com/@d3/force-directed-graph-component), running at 120FPS on a SwiftUI Canvas. Take a closer look at the animation:

https://github.com/li3zhen1/Grape/assets/45376537/5f57c223-0126-428a-a72d-d9a3ed38059d

https://github.com/li3zhen1/Grape/assets/45376537/6a1c9510-8af6-4967-9c05-c304b2af59ee


#### Features

| | Status (2D) | Status (3D) | Metal |

### Features

| | 2D simd | 3D simd | Metal |
| --- | --- | --- | --- |
| **NdTree** || 🚧 | |
| **Simulation** || 🚧 | 🚧 |
Expand All @@ -33,16 +35,15 @@ https://github.com/li3zhen1/Grape/assets/45376537/5f57c223-0126-428a-a72d-d9a3ed
| **SwiftUI View** | 🚧 | | |


#### Usage
### Usage

```swift
import ForceSimulation

// nodes with unique id
let nodes: [Identifiable] = ...
struct Node: Identifiable { ... }

// links with source and target, ID should be the same as the type of the id
let links: [(ID, ID)] = ...
let nodes: [Node] = ...
let links: [(Node.ID, Node.ID)] = ...

let sim = Simulation(nodes: nodes, alphaDecay: 0.0005)
sim.createManyBodyForce(strength: -30)
Expand All @@ -54,6 +55,6 @@ sim.createCollideForce(radius: .constant(5))

See [Example](https://github.com/li3zhen1/Grape/tree/main/Examples/GrapeView) for more details.

#### Perfomance
### Perfomance

Currently it takes 0.046 seconds to iterate 120 times over the example graph (with 77 vertices, 254 edges, with manybody, center and link forces, release build, on a 32GB M1 Max).
Grape uses simd to calculate position and velocity. Currently it takes 0.046 seconds to iterate 120 times over the example graph (with 77 vertices, 254 edges, with manybody, center and link forces, release build, on a 32GB M1 Max).

0 comments on commit a60e88c

Please sign in to comment.