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 AlgoGraphWhat'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 predicatemap_vertices,map_edges- Transform attributesreverse,to_undirected,subgraph- Structure transformationslargest_component,minimum_spanning_tree- Algorithm-basedto_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 matchingvertex.attrs(**attrs)- Attribute matching with callable supportvertex.degree(min/max/exact)- Degree-based selectionedge.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/edgessubgraph_view- View specific verticesreversed_view- Reverse edge directionsundirected_view- View as undirectedcomponent_view- View connected componentneighborhood_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 transformationsgraph_selectors.py(626 lines) - Declarative pattern matchingviews.py(478 lines) - Lazy graph filteringtest/test_phase3_features.py(536 lines) - Comprehensive teststest/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
- PyPI: https://pypi.org/project/AlgoGraph/2.0.0/
- Documentation: https://queelius.github.io/AlgoGraph/
- Repository: https://github.com/queelius/AlgoGraph