Skip to content

Commit 80bb099

Browse files
authored
Merge pull request #66 from li3zhen1/ForceDescriptor<NodeID>
Add `NodeID` type parameter to `_ForceDescriptor`
2 parents ac4b6e7 + 37233b7 commit 80bb099

12 files changed

+444
-185
lines changed

Examples/ForceDirectedGraphExample/ForceDirectedGraphExample/Lattice.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,11 @@ struct Lattice: View {
5050
}
5151

5252
} force: {
53-
LinkForce(
53+
.link(
5454
originalLength: .constant(0.8),
5555
stiffness: .weightedByDegree { _, _ in 1.0 }
5656
)
57-
ManyBodyForce(strength: -0.8)
57+
.manyBody(strength: -0.8)
5858
}
5959
.toolbar {
6060
GraphStateToggle(graphStates: graphStates)

Examples/ForceDirectedGraphExample/ForceDirectedGraphExample/MermaidVisualization.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,9 @@ struct MermaidVisualization: View {
9999
.stroke(.black, StrokeStyle(lineWidth: 2.0, lineCap: .round, lineJoin: .round))
100100

101101
} force: {
102-
ManyBodyForce()
103-
LinkForce(originalLength: .constant(70))
104-
CenterForce()
102+
.manyBody()
103+
.link(originalLength: .constant(70))
104+
.center()
105105
} emittingNewNodesWithStates: { id in
106106
KineticState(position: getInitialPosition(id: id, r: 100))
107107
}

Examples/ForceDirectedGraphExample/ForceDirectedGraphExample/Miserables.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,11 @@ struct MiserableGraph: View {
6666
}
6767

6868
} force: {
69-
ManyBodyForce(strength: -20)
70-
CenterForce()
71-
LinkForce(
69+
.manyBody(strength: -20)
70+
.center()
71+
.link(
7272
originalLength: .constant(35.0),
73-
stiffness: .weightedByDegree(k: { _, _ in 1.0})
73+
stiffness: .weightedByDegree { _, _ in 1.0}
7474
)
7575
}
7676
.ignoresSafeArea()

Examples/ForceDirectedGraphExample/ForceDirectedGraphExample/MyRing.swift

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ struct MyRing: View {
1515
@State var graphStates = ForceDirectedGraphState()
1616

1717
var body: some View {
18-
18+
1919
ForceDirectedGraph(states: graphStates) {
2020
Series(0..<20) { i in
2121
NodeMark(id: 3 * i + 0)
@@ -32,26 +32,29 @@ struct MyRing: View {
3232
.symbolSize(radius:6.0)
3333
.foregroundStyle(.yellow)
3434
.stroke(.clear)
35-
35+
3636
LinkMark(from: 3 * i + 0, to: 3 * i + 1)
3737
LinkMark(from: 3 * i + 1, to: 3 * i + 2)
3838

3939
LinkMark(from: 3 * i + 0, to: 3 * ((i + 1) % 20) + 0)
4040
LinkMark(from: 3 * i + 1, to: 3 * ((i + 1) % 20) + 1)
4141
LinkMark(from: 3 * i + 2, to: 3 * ((i + 1) % 20) + 2)
42-
42+
4343

4444
}
45-
.stroke(.black, StrokeStyle(lineWidth: 1.5, lineCap: .round, lineJoin: .round))
45+
.stroke(
46+
.black,
47+
StrokeStyle(lineWidth: 1.5, lineCap: .round, lineJoin: .round)
48+
)
4649

4750
} force: {
48-
ManyBodyForce(strength: -15)
49-
LinkForce(
51+
.manyBody(strength: -15)
52+
.link(
5053
originalLength: .constant(20.0),
51-
stiffness: .weightedByDegree(k: { _, _ in 3.0})
54+
stiffness: .weightedByDegree { _, _ in 3.0}
5255
)
53-
CenterForce()
54-
CollideForce()
56+
.center()
57+
.collide()
5558
}
5659
.graphOverlay { proxy in
5760
Rectangle().fill(.clear).contentShape(Rectangle())

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,9 +167,9 @@ struct MyGraph: View {
167167
}
168168

169169
} force: {
170-
LinkForce()
171-
CenterForce()
172-
ManyBodyForce()
170+
.link()
171+
.center()
172+
.manyBody()
173173
}
174174
}
175175
}

0 commit comments

Comments
 (0)