| Crates.io | tulna-rs |
| lib.rs | tulna-rs |
| version | 0.1.2 |
| created_at | 2025-11-25 15:20:10.381239+00 |
| updated_at | 2025-11-25 15:41:19.303862+00 |
| description | A Rust library for RDF graph isomorphism and semantic query equivalence checking using an efficient hash-based grounding algorithm to detect the graph isomorphism. |
| homepage | https://github.com/SolidLabResearch/tulna-rs |
| repository | https://github.com/SolidLabResearch/tulna-rs |
| max_upload_size | |
| id | 1949935 |
| size | 156,023 |
A Rust library for RDF graph isomorphism and semantic query equivalence checking using an efficient hash-based grounding algorithm to detect the graph isomorphism.
Etymology: The name "tulna" is inspired by the Hindi word Tulanā (तुलना), which means "comparison" — reflecting the library's purpose of comparing RDF graphs and semantic queries.
[dependencies]
tulna-rs = "0.1.2"
Compare RDF graphs directly:
use tulna_rs::graph::{GraphIsomorphism, Triple, TripleNode};
let graph1 = vec![
Triple {
subject: TripleNode::Variable("x".to_string()),
predicate: TripleNode::IRI("http://example.org/knows".to_string()),
object: TripleNode::Variable("y".to_string()),
}
];
let graph2 = vec![
Triple {
subject: TripleNode::Variable("person".to_string()),
predicate: TripleNode::IRI("http://example.org/knows".to_string()),
object: TripleNode::Variable("friend".to_string()),
}
];
let result = GraphIsomorphism::are_isomorphic(&graph1, &graph2)?;
assert!(result); // true - same structure, different variable names
Compare SPARQL/RSP-QL/JanusQL queries:
use tulna_rs::query::QueryIsomorphismAPI;
let query1 = "SELECT ?s ?p ?o WHERE { ?s ?p ?o . }";
let query2 = "SELECT ?x ?y ?z WHERE { ?x ?y ?z . }";
let result = QueryIsomorphismAPI::is_isomorphic(query1, query2)?;
assert!(result); // true - semantically equivalent
Uses a hash-based grounding algorithm that:
Run included examples:
# Graph isomorphism examples
cargo run --example graph_isomorphism
# Query isomorphism examples
cargo run --example query_isomorphism
use tulna_rs::graph::{GraphIsomorphism, Triple, TripleNode};
// Check if two graphs are isomorphic
GraphIsomorphism::are_isomorphic(&graph1, &graph2)?;
use tulna_rs::query::{QueryIsomorphismAPI, QueryLanguage};
// Check query isomorphism
QueryIsomorphismAPI::is_isomorphic(query1, query2)?;
// Detect query language
QueryIsomorphismAPI::detect_query_language(query);
// Extract basic graph pattern
QueryIsomorphismAPI::extract_bgp(query)?;
// Compare with details
QueryIsomorphismAPI::compare_queries(query1, query2)?;
# Run all tests
cargo test
# Run with output
cargo test -- --nocapture
# Generate documentation
cargo doc --open
Graph Isomorphism:
Query Isomorphism:
cargo doc --openexamples/ directorytests/ directoryregex - Query parsingmurmur3 - Hash function for the grounding algorithmCopyright by Ghent University - imec
Released under the MIT License
Algorithm based on:
Before submitting a pull request, ensure:
cargo testcargo fmtcargo doc --no-deps