Skip to content

Conversation

@homka122
Copy link
Contributor

Implementation of Context-Free Path Query Algorithm

This pull request adds an implementation of the Context-Free Path Query algorithm for solving the reachability problem using linear algebra. This algorithm was presented in the work available at this link.

Overview

The algorithm takes as input an edge-labeled graph and a context-free grammar, and it outputs all pairs of vertices between which there is at least one path such that the concatenation of edge labels forms a word in the language generated by the grammar.

Inputs

  • Context-Free Grammar: An array of rules representing the context-free grammar.
  • Graph: The graph is provided as a decomposition into adjacency matrices.

Output

The algorithm produces a set of matrices, each corresponding to a non-terminal of the grammar. For example, in the matrix A[k], the entry A[k][i, j] is 1 if and only if there is a path from node i to node j whose edge labels form a word derivable from the non-terminal k of the CFG.

Additional Details

A new structure has been added to represent a rule of the context-free grammar in Weak Chomsky Normal Form.

For a full description of the algorithm, please refer to the original document.

DrTimothyAldenDavis and others added 30 commits July 21, 2023 14:01
Build can fail due to missing mallopt function in musl. Upstreaming the fix would eliminate the patch from the LAGraph JLL package build ([see pull request](JuliaPackaging/Yggdrasil#7089))
`#ifdef __GLIBC__` for musl compatibility
@DrTimothyAldenDavis
Copy link
Member

Thanks for the contribution!

The stable branch is one we rarely change though -- only after it undergoes a deeper review and documentation, version change, and so on. Can you move the pull request to the v1.2 branch?

Copy link
Member

@DrTimothyAldenDavis DrTimothyAldenDavis left a comment

Choose a reason for hiding this comment

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

Looks great!

@homka122 homka122 changed the base branch from stable to v1.2 February 16, 2025 13:41
@homka122
Copy link
Contributor Author

@DrTimothyAldenDavis Ready!

@DrTimothyAldenDavis
Copy link
Member

I see a lot of minor conflicts with the v1.2 branch though. Can you resolve those first? It looks like most of them should stay unmodified in the v1.2 branch. Sorry for the hassle.

@homka122
Copy link
Contributor Author

@DrTimothyAldenDavis Sure!

@homka122
Copy link
Contributor Author

@DrTimothyAldenDavis Hi! I resolved all conflicts.

@DrTimothyAldenDavis DrTimothyAldenDavis merged commit b2e38b9 into GraphBLAS:v1.2 Feb 20, 2025
0 of 4 checks passed
@DrTimothyAldenDavis
Copy link
Member

I've been working on getting LAGraph v1.2 version polished, with the goal of a stable version release. I have the test coverage up to nearly 100%, but there are a few lines in the CFL method that aren't tested by the tests in test_CFL_reachability.c. I've tagged the untested lines of code in LAGraph_CFL_reachability.c with FIXMEs. Can you take a look?

@homka122
Copy link
Contributor Author

homka122 commented Apr 30, 2025

I've been working on getting LAGraph v1.2 version polished, with the goal of a stable version release. I have the test coverage up to nearly 100%, but there are a few lines in the CFL method that aren't tested by the tests in test_CFL_reachability.c. I've tagged the untested lines of code in LAGraph_CFL_reachability.c with FIXMEs. Can you take a look?

Hi @DrTimothyAldenDavis. I’ve updated the code and test coverage is now at 100%!
You can check out the new pull request here: #291

image

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.

6 participants