Skip to content

Comments

Implement RSMs reachability algorithm#7

Open
Zestria wants to merge 3 commits intoSparseLinearAlgebra:stablefrom
Zestria:feat/rsm-reach
Open

Implement RSMs reachability algorithm#7
Zestria wants to merge 3 commits intoSparseLinearAlgebra:stablefrom
Zestria:feat/rsm-reach

Conversation

@Zestria
Copy link

@Zestria Zestria commented Dec 3, 2025

This patch implements a context-free path query algorithm using recursive state machines (RSMs) over edge-labeled directed graphs. It extends the approach of the previously unified regular path search algorithm by using linear algebra operations on adjacency matrices, as presented in https://arxiv.org/abs/2412.10287.

GRB_TRY(GrB_eWiseAdd(P, GrB_NULL, GrB_NULL, GrB_LOR, P, next_frontier, GrB_NULL));
GRB_TRY(GrB_Matrix_nvals(&states, next_frontier));

if (iteration > 3000)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What?

GRB_TRY(GrB_eWiseAdd(K, GrB_NULL, GrB_NULL, GrB_LOR, K, next_frontier, GrB_NULL));
GRB_TRY(GrB_Matrix_nvals(&states, next_frontier));

if (iteration > 3000)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What?

@@ -0,0 +1,333 @@
#include <GraphBLAS.h>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add tests for graphs, not linear input. e.g.
Graph: 0 -a-> 1; 1 -a-> 2; 2 -a-> 0; 0 -b->3 3 -b-> 0;
Grammar: S -> a S b | a b
Start vertex: 1
Reachable: 0 and 3

Graph: 0 -a-> 0; 0 -a-> 1; 1 -b-> 1
Grammar: S -> a S b | a b
Start vertex: 0
Reachable: 1

Graph: 0 -a-> 0; 0 -b-> 0;
Grammar: S -> a S b | a b
Start vertex: 0
Reachable: 0

Graph: 0 -a-> 0; 0 -c-> 1; 1 -b-> 1;
Grammar: S -> a S b | c
Start vertex: 0
Reachable: 1

Graph: 0 -a-> 1; 1 -a-> 0; 0 -c-> 2; 2 -b->3; 3 -b-> 2;
Grammar: S -> a S b | c
Start vertex: 1
Reachable: 3

Graph: 0 -a-> 1; 1 -a-> 0; 0 -c-> 2; 2 -b->2
Grammar: S -> a S b | c
Start vertex: 1
Reachable: 2

Graph: 0 -a-> 1; 1 -a-> 0; 0 -c-> 2; 2 -b->3; 3-b->4; 4-b->2;
Grammar: S -> a S b | c
Start vertex: 0
Reachable: 2;3;4

Graph: 0 -a-> 1; 1 -a-> 0; 0 -c-> 2; 2 -b->3; 3-b->4; 4-b->2;
Grammar: S -> a S b | c
Start vertex: 1
Reachable: 2;3;4

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Graph: 0 -a-> 1; 1 -a-> 2; 2 -a-> 0; 2 -b->3; 3-b->2; 3-c->4; 4-c->5; 5-c->3; 5-d->2; 2 -d->5;
Grammar (S -- start non-terminal):
S -> X | Y | S X | S Y
X -> a S b | a b
Y -> c S d | c d
Start vertex: 0
Reachable: 2;3;5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants