diff --git a/Examples/ForceDirectedGraph3D/ForceDirectedGraph3D/ContentView.swift b/Examples/ForceDirectedGraph3D/ForceDirectedGraph3D/ContentView.swift index 3a375d9..ec6644f 100644 --- a/Examples/ForceDirectedGraph3D/ForceDirectedGraph3D/ContentView.swift +++ b/Examples/ForceDirectedGraph3D/ForceDirectedGraph3D/ContentView.swift @@ -44,11 +44,7 @@ func buildSimulation() -> Simulation3D { forceField: My3DForce() ) -<<<<<<< HEAD for _ in 0..<720 { -======= - for i in 0..<720 { ->>>>>>> main sim.tick() } return sim diff --git a/Examples/ForceDirectedGraphExample/ForceDirectedGraphExample.xcodeproj/project.pbxproj b/Examples/ForceDirectedGraphExample/ForceDirectedGraphExample.xcodeproj/project.pbxproj index 4217179..b34a858 100644 --- a/Examples/ForceDirectedGraphExample/ForceDirectedGraphExample.xcodeproj/project.pbxproj +++ b/Examples/ForceDirectedGraphExample/ForceDirectedGraphExample.xcodeproj/project.pbxproj @@ -11,11 +11,7 @@ B70B52AF2AF822FF00A1E6CD /* Grape in Frameworks */ = {isa = PBXBuildFile; productRef = B70B52AE2AF822FF00A1E6CD /* Grape */; }; B71759592AFBFC4B000DF006 /* Miserables.swift in Sources */ = {isa = PBXBuildFile; fileRef = B71759582AFBFC4B000DF006 /* Miserables.swift */; }; B717595B2AFBFDBD000DF006 /* Lattice.swift in Sources */ = {isa = PBXBuildFile; fileRef = B717595A2AFBFDBD000DF006 /* Lattice.swift */; }; -<<<<<<< HEAD B762092F2B49FCD000476B93 /* MermaidVisualization.swift in Sources */ = {isa = PBXBuildFile; fileRef = B762092E2B49FCD000476B93 /* MermaidVisualization.swift */; }; -======= - B719E4112AE5FBFC009D6C24 /* ForceDirectedLatticeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B719E4102AE5FBFC009D6C24 /* ForceDirectedLatticeView.swift */; }; ->>>>>>> main B780DD7A2AF84ECB001C605F /* MyRing.swift in Sources */ = {isa = PBXBuildFile; fileRef = B780DD792AF84ECB001C605F /* MyRing.swift */; }; B7AFA55B2ADF4997009C7154 /* ForceDirectedGraphExampleApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = B7AFA55A2ADF4997009C7154 /* ForceDirectedGraphExampleApp.swift */; }; B7AFA55D2ADF4997009C7154 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B7AFA55C2ADF4997009C7154 /* ContentView.swift */; }; @@ -28,11 +24,7 @@ /* Begin PBXFileReference section */ B71759582AFBFC4B000DF006 /* Miserables.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Miserables.swift; sourceTree = ""; }; B717595A2AFBFDBD000DF006 /* Lattice.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Lattice.swift; sourceTree = ""; }; -<<<<<<< HEAD B762092E2B49FCD000476B93 /* MermaidVisualization.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MermaidVisualization.swift; sourceTree = ""; }; -======= - B719E4102AE5FBFC009D6C24 /* ForceDirectedLatticeView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ForceDirectedLatticeView.swift; sourceTree = ""; }; ->>>>>>> main B780DD792AF84ECB001C605F /* MyRing.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MyRing.swift; sourceTree = ""; }; B7AFA5572ADF4997009C7154 /* ForceDirectedGraphExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ForceDirectedGraphExample.app; sourceTree = BUILT_PRODUCTS_DIR; }; B7AFA55A2ADF4997009C7154 /* ForceDirectedGraphExampleApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ForceDirectedGraphExampleApp.swift; sourceTree = ""; }; @@ -77,10 +69,6 @@ isa = PBXGroup; children = ( B780DD792AF84ECB001C605F /* MyRing.swift */, -<<<<<<< HEAD -======= - B719E4102AE5FBFC009D6C24 /* ForceDirectedLatticeView.swift */, ->>>>>>> main B7AFA55A2ADF4997009C7154 /* ForceDirectedGraphExampleApp.swift */, B7AFA55C2ADF4997009C7154 /* ContentView.swift */, B7AFA55E2ADF4999009C7154 /* Assets.xcassets */, @@ -89,10 +77,7 @@ B7AFA56E2ADF49D6009C7154 /* Data.swift */, B71759582AFBFC4B000DF006 /* Miserables.swift */, B717595A2AFBFDBD000DF006 /* Lattice.swift */, -<<<<<<< HEAD B762092E2B49FCD000476B93 /* MermaidVisualization.swift */, -======= ->>>>>>> main ); path = ForceDirectedGraphExample; sourceTree = ""; @@ -188,10 +173,7 @@ B7AFA55D2ADF4997009C7154 /* ContentView.swift in Sources */, B719E4112AE5FBFC009D6C24 /* ForceDirectedLatticeView.swift in Sources */, B7AFA56F2ADF49D6009C7154 /* Data.swift in Sources */, -<<<<<<< HEAD B762092F2B49FCD000476B93 /* MermaidVisualization.swift in Sources */, -======= ->>>>>>> main B71759592AFBFC4B000DF006 /* Miserables.swift in Sources */, B7AFA55B2ADF4997009C7154 /* ForceDirectedGraphExampleApp.swift in Sources */, ); diff --git a/Examples/ForceDirectedGraphExample/ForceDirectedGraphExample/ContentView.swift b/Examples/ForceDirectedGraphExample/ForceDirectedGraphExample/ContentView.swift index 9f779b1..f1a72af 100644 --- a/Examples/ForceDirectedGraphExample/ForceDirectedGraphExample/ContentView.swift +++ b/Examples/ForceDirectedGraphExample/ForceDirectedGraphExample/ContentView.swift @@ -71,14 +71,9 @@ enum ExampleKind { case ring case classicMiserable case lattice -<<<<<<< HEAD case mermaid static let list: [ExampleKind] = [.ring, .classicMiserable, .lattice, .mermaid] -======= - - static let list: [ExampleKind] = [.ring, .classicMiserable, .lattice] ->>>>>>> main } extension ExampleKind { @@ -90,11 +85,8 @@ extension ExampleKind { return "Miserables" case .lattice: return "Lattice" -<<<<<<< HEAD case .mermaid: return "Mermaid visualization" -======= ->>>>>>> main } } } @@ -116,11 +108,8 @@ struct ContentView: View { MiserableGraph() case .lattice: Lattice() -<<<<<<< HEAD case .mermaid: MermaidVisualization() -======= ->>>>>>> main } } } diff --git a/Examples/ForceDirectedGraphExample/ForceDirectedGraphExample/Lattice.swift b/Examples/ForceDirectedGraphExample/ForceDirectedGraphExample/Lattice.swift index 0338518..1a088fb 100644 --- a/Examples/ForceDirectedGraphExample/ForceDirectedGraphExample/Lattice.swift +++ b/Examples/ForceDirectedGraphExample/ForceDirectedGraphExample/Lattice.swift @@ -33,44 +33,25 @@ struct Lattice: View { @inlinable var body: some View { ForceDirectedGraph($isRunning) { -<<<<<<< HEAD Repeated(0..<(width*width)) { i in let _i = Double(i / width) / Double(width) let _j = Double(i % width) / Double(width) -======= - ForEach(Array(0..<(width*width)), id:\.self) { i in - - let _i = Double(i / width) / Double(width) - let _j = Double(i % width) / Double(width) - ->>>>>>> main NodeMark(id: i, radius: 3.0) .foregroundStyle(Color(red: 1, green: _i, blue: _j)) .stroke() } -<<<<<<< HEAD Repeated(edge) { LinkMark(from: $0.0, to: $0.1) } -======= - for l in edge { - - LinkMark(from: l.0, to: l.1) - } ->>>>>>> main } force: { LinkForce( originalLength: .constant(0.8), stiffness: .weightedByDegree(k: { _, _ in 1}) ) ManyBodyForce(strength: -0.8) -<<<<<<< HEAD -======= - ->>>>>>> main } .toolbar { Button { @@ -80,9 +61,6 @@ struct Lattice: View { Text(isRunning ? "Pause" : "Start") } } -<<<<<<< HEAD -======= ->>>>>>> main } } diff --git a/Examples/ForceDirectedGraphExample/ForceDirectedGraphExample/Miserables.swift b/Examples/ForceDirectedGraphExample/ForceDirectedGraphExample/Miserables.swift index 7ce6982..6f45d36 100644 --- a/Examples/ForceDirectedGraphExample/ForceDirectedGraphExample/Miserables.swift +++ b/Examples/ForceDirectedGraphExample/ForceDirectedGraphExample/Miserables.swift @@ -1,9 +1,5 @@ // -<<<<<<< HEAD // Miserables.swift -======= -// ForceDirectedGraphSwiftUIExample.swift ->>>>>>> main // ForceDirectedGraphExample // // Created by li3zhen1 on 11/5/23. @@ -12,7 +8,6 @@ import Foundation import Grape import SwiftUI -<<<<<<< HEAD import Charts @@ -54,62 +49,6 @@ struct MiserableGraph: View { LinkMark(from: l.source, to: l.target) } // -======= -import ForceSimulation -import Charts - - -//struct MyForceField: ForceField { -// -// typealias Vector = SIMD2 -// -// public var force = CompositedForce { -// LinkForce( -// originalLength: .constant(20.0), -// stiffness: .weightedByDegree(k: { _, _ in 3.0}) -// ) -// CenterForce() -// ManyBodyForce(strength: -15) -// } -//} - - - -struct MiserableGraph: View { - - @State var isRunning = false - let graphData = getData(miserables) - - var body: some View { - ForceDirectedGraph($isRunning) { - - for l in graphData.links { - let fromID = graphData.nodes.firstIndex { mn in - mn.id == l.source - }! - let toID = graphData.nodes.firstIndex { mn in - mn.id == l.target - }! - LinkMark(from: fromID, to: toID) - } - ForEach(graphData.nodes.indices, id: \.self) { i in - NodeMark(id: i) - .symbol(.asterisk) - .symbolSize(radius: 12.0) - .foregroundStyle( - colors[graphData.nodes[i].group % colors.count] - .shadow(.inner(color:colors[graphData.nodes[i].group % colors.count].opacity(0.3), radius: 3, x:0, y: 1.5)) - .shadow(.drop(color:colors[graphData.nodes[i].group % colors.count].opacity(0.12), radius: 12, x:0, y: 8)) - ) - .stroke() - .label(offset: CGVector(dx: 0.0, dy: 12.0)) { -// if i.isMultiple(of: 5) { - Text(graphData.nodes[i].id) - .font(.title3) -// } - } - } ->>>>>>> main } force: { ManyBodyForce(strength: -20) LinkForce( @@ -117,7 +56,6 @@ struct MiserableGraph: View { stiffness: .weightedByDegree(k: { _, _ in 1.0}) ) CenterForce() -<<<<<<< HEAD } .onNodeTapped { node in inspectorPresented = true @@ -134,16 +72,6 @@ struct MiserableGraph: View { if opacity < 1 { opacity = 1 } -======= -// CollideForce() - } - .onNodeTapped { - print($0) - } - .toolbar { - Button { - isRunning = !isRunning ->>>>>>> main } label: { Image(systemName: isRunning ? "pause.fill" : "play.fill") Text(isRunning ? "Pause" : "Start") diff --git a/Examples/ForceDirectedGraphExample/ForceDirectedGraphExample/MyRing.swift b/Examples/ForceDirectedGraphExample/ForceDirectedGraphExample/MyRing.swift index 0d33565..db4f377 100644 --- a/Examples/ForceDirectedGraphExample/ForceDirectedGraphExample/MyRing.swift +++ b/Examples/ForceDirectedGraphExample/ForceDirectedGraphExample/MyRing.swift @@ -35,11 +35,7 @@ struct MyRing: View { ForceDirectedGraph($isRunning) { -<<<<<<< HEAD Repeated(0..<20) { i in -======= - ForEach(Array(0..<20), id: \.self) { i in ->>>>>>> main NodeMark(id: 3 * i + 0) .symbol(.circle) .symbolSize(radius:4.0) @@ -53,7 +49,6 @@ struct MyRing: View { .symbolSize(radius:6.0) .foregroundStyle(.yellow) -<<<<<<< HEAD LinkMark(from: 3 * i + 0, to: 3 * i + 1) @@ -63,14 +58,6 @@ struct MyRing: View { LinkMark(from: 3 * i + 1, to: 3 * ((i + 1) % 20) + 1) LinkMark(from: 3 * i + 2, to: 3 * ((i + 1) % 20) + 2) -======= - LinkMark(from: 3 * i + 0, to: 3 * i + 1) - LinkMark(from: 3 * i + 1, to: 3 * i + 2) - - for j in 0..<3 { - LinkMark(from: 3 * i + j, to: 3 * ((i + 1) % 20) + j) - } ->>>>>>> main } } force: { ManyBodyForce(strength: -15)