Skip to content

AlgoGraph v2.0.0 - Advanced Features

Latest

Choose a tag to compare

@queelius queelius released this 25 Nov 13:43
· 9 commits to main since this release

AlgoGraph v2.0.0 - Advanced Features

This major release brings AlgoTree-level API elegance to AlgoGraph with pipe-based transformers, declarative selectors, and lazy views—achieving ~90% code reduction for common operations.

Installation

pip install AlgoGraph

What's New

Transformer Pipelines

Compose graph operations using the | pipe operator:

from AlgoGraph.transformers import filter_vertices, largest_component, stats

result = (graph
    | filter_vertices(lambda v: v.get('active'))
    | largest_component()
    | stats())

12 Built-in Transformers:

  • filter_vertices, filter_edges - Filter by predicate
  • map_vertices, map_edges - Transform attributes
  • reverse, to_undirected, subgraph - Structure transformations
  • largest_component, minimum_spanning_tree - Algorithm-based
  • to_dict, to_adjacency_list, stats - Export operations

Declarative Selectors

Query vertices and edges with logical operators:

from AlgoGraph.graph_selectors import vertex as v, edge as e

# Complex queries with AND, OR, NOT, XOR
power_users = graph.select_vertices(
    v.attrs(active=True) & v.degree(min_degree=10) & ~v.attrs(banned=True)
)

admin_traffic = graph.select_edges(
    e.source(v.attrs(role='admin')) & e.weight(min_weight=100)
)

Selector Types:

  • vertex.id(pattern) - Glob/regex matching
  • vertex.attrs(**attrs) - Attribute matching with callable support
  • vertex.degree(min/max/exact) - Degree-based selection
  • edge.weight(), edge.source(), edge.target(), edge.attrs()

Lazy Views

Memory-efficient filtering without copying:

from AlgoGraph.views import filtered_view, neighborhood_view

# Create view without copying
view = filtered_view(large_graph, vertex_filter=lambda v: v.get('active'))

# Iterate lazily
for vertex in view.vertices():
    process(vertex)

# Materialize only when needed
small_graph = view.materialize()

# Explore k-hop neighborhood
local = neighborhood_view(graph, center='Alice', k=2)

6 View Types:

  • filtered_view - Filter vertices/edges
  • subgraph_view - View specific vertices
  • reversed_view - Reverse edge directions
  • undirected_view - View as undirected
  • component_view - View connected component
  • neighborhood_view - k-hop neighborhood

Statistics

  • 56+ Algorithms across 8 categories
  • 213 Tests passing
  • ~2,900 Lines of new code
  • Zero Breaking Changes - fully backward compatible with v1.x

Files Added

  • transformers.py (660 lines) - Pipe-based transformations
  • graph_selectors.py (626 lines) - Declarative pattern matching
  • views.py (478 lines) - Lazy graph filtering
  • test/test_phase3_features.py (536 lines) - Comprehensive tests
  • test/test_phase3_coverage.py (465 lines) - Additional coverage tests

Before/After Comparison

Before (v1.x):

active_verts = graph.find_vertices(lambda v: v.get('active') and graph.degree(v.id) >= 5)
subg = graph.subgraph({v.id for v in active_verts})
components = connected_components(subg)
largest = max(components, key=len)
comp_graph = subg.subgraph(largest)
stats = {'vertices': comp_graph.vertex_count, 'edges': comp_graph.edge_count}

After (v2.0.0):

from AlgoGraph.transformers import filter_vertices, largest_component, stats

result = (graph
    | filter_vertices(lambda v: v.get('active') and graph.degree(v.id) >= 5)
    | largest_component()
    | stats())

Links