mirror of
https://github.com/supermemoryai/supermemory.git
synced 2026-10-09 03:18:04 +00:00
Allow full large graph load with dense simulation mode
This commit is contained in:
parent
22367a1725
commit
93c2b7baa2
3 changed files with 15 additions and 3 deletions
|
|
@ -13,7 +13,7 @@ import { dmSansClassName } from "@/lib/fonts"
|
|||
import { ShareModal } from "./share-modal"
|
||||
import { shareParam } from "@/lib/search-params"
|
||||
|
||||
const GRAPH_MAX_NODES = 3000
|
||||
const GRAPH_MAX_NODES = 15000
|
||||
|
||||
export const GraphLayoutView = memo(function GraphLayoutView({
|
||||
onOpenDocument,
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@ import * as d3 from "d3-force"
|
|||
import type { DocumentNodeData, GraphEdge, GraphNode } from "../types"
|
||||
import { FORCE_CONFIG } from "../constants"
|
||||
|
||||
const DENSE_GRAPH_STATIC_THRESHOLD = 6000
|
||||
|
||||
export class ForceSimulation {
|
||||
private sim: d3.Simulation<GraphNode, GraphEdge> | null = null
|
||||
|
||||
|
|
@ -61,8 +63,17 @@ export class ForceSimulation {
|
|||
|
||||
this.sim.stop()
|
||||
this.sim.alpha(1)
|
||||
for (let i = 0; i < FORCE_CONFIG.preSettleTicks; i++) this.sim.tick()
|
||||
this.sim.alphaTarget(0).restart()
|
||||
const preSettleTicks =
|
||||
nodes.length > DENSE_GRAPH_STATIC_THRESHOLD
|
||||
? FORCE_CONFIG.densePreSettleTicks
|
||||
: FORCE_CONFIG.preSettleTicks
|
||||
for (let i = 0; i < preSettleTicks; i++) this.sim.tick()
|
||||
|
||||
if (nodes.length > DENSE_GRAPH_STATIC_THRESHOLD) {
|
||||
this.stop()
|
||||
} else {
|
||||
this.sim.alphaTarget(0).restart()
|
||||
}
|
||||
} catch (e) {
|
||||
console.error("ForceSimulation.init failed:", e)
|
||||
this.destroy()
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ export const FORCE_CONFIG = {
|
|||
velocityDecay: 0.45,
|
||||
alphaTarget: 0.3,
|
||||
preSettleTicks: 150,
|
||||
densePreSettleTicks: 12,
|
||||
}
|
||||
|
||||
export const GRAPH_SETTINGS = {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue