Skip to content

GML-Graph v0.1.0

Latest

Choose a tag to compare

@Furia25 Furia25 released this 09 Jan 01:13
· 3 commits to main since this release

Added Features

  • DFS Implementation: Complete depth-first search algorithm with cycle detection support
  • Cycle Detection: New methods for finding cycles in both directed and undirected graphs
    • GetCycle() - Returns a cycle if one exists
    • HasCycle() / IsCyclic() / IsAcyclic() - Check for cycle existence
  • Advanced Graph Analysis:
    • GetTopologicalSort() - Topological ordering for directed acyclic graphs
    • GetDensity() - Calculate graph density ratio
    • IsDAG() - Check if graph is a directed acyclic graph
    • IsTree() - Verify tree structure
    • IsComplete() - Check if graph has all possible edges
  • Graph Manipulation:
    • Reverse() - Reverse all edge directions in-place (directed graphs)
    • GetReversed() - Create a new reversed graph
    • Merge() - Merge another graph into current graph
    • OptimizeForReading() - Pre-cache data for read-heavy operations
  • Random Selection: GetRandomNode() and GetRandomEdge() methods
  • Export Capabilities:
    • ToDOT() - Export to Graphviz DOT format for visualization
    • ToAdjacencyMatrix() - Export as 2D boolean adjacency matrix
  • Self-Loop Support: IsSelfLoopable() flag check for self-referencing edges
  • Builder System Enhancement: Constructor now accepts optional arguments for callable builders
  • Debug ID: GetDebugID() method to get unique graph instance identifier

Changed

  • BFS Return Structure: Changed from {visited: array} to {path: array, visited: struct, previous: struct} for consistency
  • Node Cache Removed: GetNodes() no longer uses caching (removed __node_cache and __node_dirty)
  • Edge Cache Cloning: GetEdges() now returns a clone of the cache instead of direct reference
  • Component Cache: GetComponents() returns direct reference instead of clone for better performance

Fixed

  • GetComponents(): Now correctly uses path field instead of visited from BFS results
  • Graph Builder: Constructor properly handles variable argument counts for callable builders
  • Self-Loop Validation: IsComplete() now properly accounts for GRAPH_ALLOW_SELF_LOOP flag

Optimizations

  • Removed redundant node caching system for better memory efficiency
  • Internal __DFSGetCycleDirected and __DFSGetCycleUndirected helper methods for efficient cycle detection
  • Better structure dirty flag management

Documentation

  • All new methods fully documented with JSDoc comments
  • Enhanced error messages reference specific graph operations
  • Added internal @ignore tags for private helper functions