SVG Graph Network API Documentation - v0.2.0
    Preparing search index...

    Class GraphNetwork<T>

    GraphNetwork - Modern modular interactive SVG graph visualization library

    Enhanced with full TypeScript support, comprehensive API, and modular architecture. Orchestrates physics simulation, rendering, UI management, and user interactions.

    const graph = new GraphNetwork<MyNodeType>('container-id', {
    data: { nodes: [...], links: [...] },
    config: {
    damping: 0.95,
    repulsionStrength: 6500,
    showControls: true
    }
    });

    Type Parameters

    Index

    Constructors

    Methods

    • Update physics configuration and notify physics engine

      Parameters

      • key: string

        Configuration key

      • value: any

        New value

      Returns void

    • Filter graph to show only specified node and its connections

      Parameters

      • nodeId: string

        ID of the node to filter by

      • depth: null | number = null

        Connection depth (defaults to config.filterDepth)

      Returns void

    • Reset all node positions to random locations

      Returns void

    • Zoom in towards the center

      Parameters

      • Optionalfactor: number

        Zoom factor (defaults to config-based calculation)

      Returns void

    • Zoom out from the center

      Parameters

      • Optionalfactor: number

        Zoom factor (defaults to config-based calculation)

      Returns void

    • Zoom to fit all nodes in the viewport

      Parameters

      • padding: number = 50

        Padding around the content (default: 50px)

      Returns void

    • Toggle between light and dark themes

      Returns void

    • Show tooltip for node

      Parameters

      • node: Node<T>

        Node to show tooltip for

      • position: null | Position = null

        Screen position for tooltip

      Returns void

    • Configure tooltip behavior

      Parameters

      • config: Partial<TooltipConfig>

        Tooltip configuration

      Returns void

    • Delete a node from the graph with enhanced orphaned edge handling

      Parameters

      • nodeId: string

        ID of the node to delete

      • options: DeletionOptions = {}

        Deletion options including animation and redraw control

      Returns boolean

    • Parameters

      • nodeId: string
      • redraw: boolean = true

      Returns boolean

      Use deleteNode() instead Legacy method for backward compatibility

    • Add a single link to the graph (backward compatibility)

      Parameters

      • linkData: LinkData

        Link data to add

      • redraw: boolean = true

        Whether to redraw the graph (default: true)

      Returns RenderLink<T>

    • Remove a link from the graph by source and target (backward compatibility)

      Parameters

      • sourceId: string

        Source node ID

      • targetId: string

        Target node ID

      • redraw: boolean = true

        Whether to redraw the graph (default: true)

      Returns boolean

    • Get all nodes as plain data objects

      Returns T[]

      Array of node data

    • Get node by ID

      Parameters

      • nodeId: string

        Node ID

      Returns null | T

      Node data or null if not found

    • Check if node exists

      Parameters

      • nodeId: string

        Node ID

      Returns boolean

      True if node exists

    • Check if edge exists

      Parameters

      • edgeId: string

        Edge ID

      Returns boolean

      True if edge exists

    • Update an existing node's properties

      Parameters

      • nodeId: string

        ID of the node to update

      • updates: Partial<Omit<T, "id">>

        Partial node data with updates

      • options: { skipRedraw?: boolean } = {}

        Update options

      Returns boolean

    • Update an existing edge's properties

      Parameters

      • edgeId: string

        ID of the edge to update

      • updates: Partial<Omit<EdgeData, "id" | "source" | "target">>

        Partial edge data with updates

      • options: { skipRedraw?: boolean } = {}

        Update options

      Returns boolean

    • Update multiple nodes in bulk with intelligent batching

      Parameters

      • nodesData: ({ id: string } & Partial<Omit<T, "id">>)[]

        Array of node updates with IDs

      • options: BulkUpdateOptions = {}

        Bulk update options

      Returns string[]

      Array of successfully updated node IDs

    • Update multiple edges in bulk with intelligent batching

      Parameters

      • edgesData: ({ id: string } & Partial<Omit<EdgeData, "id" | "source" | "target">>)[]

        Array of edge updates with IDs

      • options: BulkUpdateOptions = {}

        Bulk update options

      Returns string[]

      Array of successfully updated edge IDs

    • Clear all data from the graph with optional animation

      Parameters

      • options: { animate?: boolean; duration?: number } = {}

        Clear options with animation support

      Returns void

    • Start a new transaction for atomic operations

      Returns string

      Transaction ID for tracking

    • Commit the current transaction, applying all changes

      Returns { id: string; operationCount: number; duration: number }

      Transaction summary

    • Rollback the current transaction, undoing all changes

      Returns { id: string; operationCount: number; duration: number }

      Transaction summary

    • Get current transaction status

      Returns
          | null
          | {
              id: string;
              startTime: number;
              operationCount: number;
              duration: number;
          }

      Transaction info or null if no active transaction

    • Check if currently in a transaction

      Returns boolean

      True if transaction is active

    • Get internal node instance by ID (for advanced usage)

      Parameters

      • nodeId: string

        Node ID

      Returns null | Node<T>

      Node instance or null if not found

    • Get graph statistics and metrics

      Returns GraphStats

      Graph statistics

    • Export graph data in various formats

      Parameters

      • options: ExportOptions

        Export options

      Returns string | void

      Exported data or initiates download

    • Select a single node

      Parameters

      • nodeId: string

        ID of node to select

      • Optionaloptions: SelectionOptions

        Selection options

      Returns boolean

      True if selection changed

    • Select multiple nodes

      Parameters

      • nodeIds: string[]

        Array of node IDs to select

      • Optionaloptions: SelectionOptions

        Selection options

      Returns string[]

      Array of newly selected node IDs

    • Select a single edge

      Parameters

      • edgeId: string

        ID of edge to select

      • Optionaloptions: SelectionOptions

        Selection options

      Returns boolean

      True if selection changed

    • Select multiple edges

      Parameters

      • edgeIds: string[]

        Array of edge IDs to select

      • Optionaloptions: SelectionOptions

        Selection options

      Returns string[]

      Array of newly selected edge IDs

    • Deselect a node

      Parameters

      • nodeId: string

        ID of node to deselect

      Returns boolean

      True if deselection changed

    • Deselect an edge

      Parameters

      • edgeId: string

        ID of edge to deselect

      Returns boolean

      True if deselection changed

    • Toggle node selection

      Parameters

      • nodeId: string

        ID of node to toggle

      Returns boolean

      True if selection state changed

    • Toggle edge selection

      Parameters

      • edgeId: string

        ID of edge to toggle

      Returns boolean

      True if selection state changed

    • Check if node is selected

      Parameters

      • nodeId: string

        ID of node to check

      Returns boolean

      True if node is selected

    • Check if edge is selected

      Parameters

      • edgeId: string

        ID of edge to check

      Returns boolean

      True if edge is selected

    • Get all selected node IDs

      Returns string[]

      Array of selected node IDs

    • Get all selected edge IDs

      Returns string[]

      Array of selected edge IDs

    • Set selection mode

      Parameters

      • mode: "single" | "multi" | "box"

        Selection mode

      Returns void

    • Get current selection mode

      Returns "single" | "multi" | "box"

      Current selection mode

    • Set style for a specific node

      Parameters

      • nodeId: string

        ID of node to style

      • styles: NodeStyles

        Node styles to apply

      Returns void

    • Set style for a specific edge

      Parameters

      • edgeId: string

        ID of edge to style

      • styles: EdgeStyles

        Edge styles to apply

      Returns void

    • Get current style for a node

      Parameters

      • nodeId: string

        ID of node

      Returns null | NodeStyles

      Node styles or null if not found

    • Get current style for an edge

      Parameters

      • edgeId: string

        ID of edge

      Returns null | EdgeStyles

      Edge styles or null if not found

    • Highlight multiple nodes

      Parameters

      • nodeIds: string[]

        Array of node IDs to highlight

      • Optionalstyle: HighlightStyle

        Highlight style options

      Returns void

    • Highlight multiple edges

      Parameters

      • edgeIds: string[]

        Array of edge IDs to highlight

      • Optionalstyle: HighlightStyle

        Highlight style options

      Returns void

    • Highlight shortest path between two nodes

      Parameters

      • sourceId: string

        Source node ID

      • targetId: string

        Target node ID

      • Optionaloptions: PathHighlightOptions

        Path highlight options

      Returns null | string[]

      Array of highlighted element IDs or null if no path found

    • Highlight neighbors of a node

      Parameters

      • nodeId: string

        ID of node whose neighbors to highlight

      • Optionaloptions: NeighborHighlightOptions

        Neighbor highlight options

      Returns string[]

      Array of highlighted element IDs

    • Highlight all connections for a node

      Parameters

      • nodeId: string

        ID of node whose connections to highlight

      • Optionalstyle: HighlightStyle

        Highlight style options

      Returns string[]

      Array of highlighted element IDs

    • Clear highlight for a specific node

      Parameters

      • nodeId: string

        ID of node to clear highlight

      Returns void

    • Clear highlight for a specific edge

      Parameters

      • edgeId: string

        ID of edge to clear highlight

      Returns void

    • Check if node is highlighted

      Parameters

      • nodeId: string

        ID of node to check

      Returns boolean

      True if node is highlighted

    • Check if edge is highlighted

      Parameters

      • edgeId: string

        ID of edge to check

      Returns boolean

      True if edge is highlighted

    • Get all highlighted node IDs

      Returns string[]

      Array of highlighted node IDs

    • Get all highlighted edge IDs

      Returns string[]

      Array of highlighted edge IDs

    • Focus on a single node with smooth animation

      Parameters

      • nodeId: string

        ID of node to focus on

      • Optionaloptions: FocusOptions

        Focus animation options

      Returns Promise<void>

      Promise that resolves when animation completes

    • Focus on multiple nodes by fitting them in view

      Parameters

      • nodeIds: string[]

        Array of node IDs to focus on

      • Optionaloptions: FocusOptions

        Focus animation options

      Returns Promise<void>

      Promise that resolves when animation completes

    • Fit entire graph to view with padding

      Parameters

      • Optionalpadding: number

        Padding around graph in pixels

      Returns Promise<void>

      Promise that resolves when animation completes

    • Center the view on the graph center

      Returns Promise<void>

      Promise that resolves when animation completes

    • Check if camera animation is currently running

      Returns boolean

      True if animation is active

    • Stop current camera animation

      Returns void

    • Remove event listener

      Type Parameters

      • K extends string

      Parameters

      • event: K

        Event name

      • callback: EventCallback<any>

        Event callback to remove

      Returns void

    • Emit event to all listeners

      Type Parameters

      • K extends string

      Parameters

      • event: K

        Event name

      • data: any = {}

        Event data

      Returns void

    • Convert this graph to a serializable object for debugging

      Returns {
          stats: GraphStats;
          config: GraphConfig;
          data: GraphData;
          modules: { physics: any; renderer: any; ui: any; events: any };
          type: string;
          version: string;
      }

      Object representation of the graph state

    • Get list of available theme names

      Returns string[]

      Array of available theme names

    • Update the current theme with partial configuration

      Parameters

      • updates: Partial<ThemeConfig>

        Partial theme updates to apply

      Returns void

    • Enable or disable automatic color generation for undefined node types When enabled, node types without explicit color definitions will automatically receive visually distinct colors using a golden ratio algorithm.

      Parameters

      • enabled: boolean

        Whether to enable auto-coloring

      Returns void

    • Check if automatic color generation is enabled

      Returns boolean

      true if auto-coloring is enabled

    • Set visual state for an element

      Parameters

      • elementId: string

        ID of the element (node or edge)

      • state: VisualState

        Visual state to apply

      • enabled: boolean = true

        Whether to enable or disable the state

      Returns void

    • Get the theme manager instance for advanced usage

      Returns null | ThemeManager

      ThemeManager instance

    • Configure grid settings

      Parameters

      • options: { enabled?: boolean; color?: string; size?: number; opacity?: number }

      Returns void

    • Get current grid configuration

      Returns { enabled: boolean; color?: string; size?: number; opacity?: number }

    • Create a string representation of the graph network

      Returns string

      String representation