Skip to content

Knows v3.0.0: Define your own graph! 🎨

Latest

Choose a tag to compare

@github-actions github-actions released this 05 Jan 06:57
· 6 commits to main since this release

This is a major release introducing custom schema support, improved visualization controls, and important fixes.

✨ New Features

🎨 Custom Schema Support (GQL-Inspired)

Define your own graph structures using JSON schema files! This powerful new feature allows you to:

  • Custom node and edge labels - No longer limited to Person/knows
  • 25+ property types - String, Int, Float, Boolean, Date, DateTime, Email, UUID, and more
  • Type constraints - Set min, max, precision for numeric types; date ranges for dates
  • Enum values - Define fixed sets of allowed values
  • Symmetric edge properties - Ensure Aβ†’B and Bβ†’A share consistent values
  • Computed node properties - Calculate values from graph structure (e.g., degree)
# Use a custom schema
knows -n 100 -e 200 --schema my_schema.json

πŸ“– Full documentation: SCHEMA.md

πŸ“‚ 14 Ready-to-Use Example Schemas

New schema-examples/ directory with templates for various domains:

Simple Examples Real-World Examples
πŸ‘₯ simple_friendship_schema.json 🏒 employee_schema.json
βœ… simple_task_schema.json πŸ›’ ecommerce_schema.json
🌐 simple_webpage_schema.json πŸ“š citation_network_schema.json
πŸ’¬ simple_message_schema.json 🎬 movie_database_schema.json
πŸš‡ transportation_schema.json
πŸ’° financial_schema.json
πŸ–₯️ infrastructure_schema.json
🧠 knowledge_graph_schema.json
πŸ“± social_network_schema.json

πŸ“Š Large Graph Visualization Controls

New options for handling large graphs in visual outputs (svg, png, jpg, pdf, -d):

  • -l N, --limit N - Maximum nodes to display (default: 50)
  • --no-limit - Show full graph without truncation
  • --hide-info - Hide node count indicator from output
# Display up to 100 nodes
knows -n 500 -e 1000 -f svg -l 100 > graph.svg

# Show all nodes (may be slow for large graphs)
knows -n 200 -e 400 -f png --no-limit graph.png

Visualizations now use BFS-based subgraph extraction centered on the most connected nodes, with improved spring layout spacing.

πŸ’” Breaking Changes

🎯 friendCount Now Reflects Actual Connections

friendCount property was previously generated as a random number (1-1000), which didn't match the actual graph topology. Now friendCount is computed as the actual node degree (number of unique connections) after graph generation. This ensures the property accurately represents the node's connectivity in the graph.

🐍 Python 3.10+ Required

Dropped support for Python 3.9 (end of life). Minimum required version is now Python 3.10.

πŸ“¦ Updated Dependencies

Package Old Version New Version
networkx β‰₯3.2.0 β‰₯3.4.0
matplotlib β‰₯3.8.4 β‰₯3.10.0
scipy β‰₯1.12.0 β‰₯1.14.0
pytest β‰₯8.0.0 β‰₯8.4.0

πŸ†• New Dependency

  • jsonschema β‰₯4.22.0 (for schema validation)

πŸ“ Other Changes

  • πŸ“š New documentation: Comprehensive SCHEMA.md with examples
  • βœ… JSON Schema for validation: IDE autocompletion and validation support via knows/schema.json
  • 🧹 Simplified codebase: Removed NetworkX version compatibility workarounds (now requires 3.4+)
  • πŸ§ͺ Expanded test suite: 737 new lines of tests for schema functionality
  • 🎯 Type hints: Improved type annotations throughout the codebase
  • πŸ“‹ CLI updates: New argument group for graphics output options

πŸ“₯ Install/Update

pip install knows --upgrade

Or with Docker:

docker pull lszeremeta/knows:3.0.0

πŸ“‹ Full Changelog

Files Added

  • SCHEMA.md - Schema documentation
  • knows/schema.py - Schema loading and validation
  • knows/schema.json - JSON Schema for IDE validation
  • tests/test_schema.py - Schema tests
  • schema-examples/ - 14 example schema files

Files Modified

  • knows/__init__.py - Version bump
  • knows/__main__.py - Schema and visualization options integration
  • knows/command_line_interface.py - New CLI arguments
  • knows/graph.py - Schema support, computed properties
  • knows/graph_drawer.py - Subgraph extraction, layout improvements
  • knows/output_format.py - Visualization limit support
  • pyproject.toml - Version, dependencies, Python version
  • README.md - Updated documentation
  • All test files - Updated for new features

Full Changelog: v2.0.5...v3.0.0