Skip to content

A crate that serves as the baseline for constructing powerful graph algorithms in CSR

Notifications You must be signed in to change notification settings

TiagoMAntunes/graph_csr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

graph_csr

This crate has the objective of serving as the baseline for powerful graph algorithms built in Rust. It leverages memory-maps by using the easy_mmap crate, and thus can easily manipulate graphs that exceed the available system memory.

Usage

At this point, graph_csr supports reading directly from binary and txt files. However, such files require to be sorted by source, due to the nature of the CSR graph. Let us exemplify with a simple example file graph.txt:

0 1
0 2
1 5
1 2
4 7

This graph contains 8 nodes (0 - 7) and 5 edges.

use graph_csr;

fn main() {
    let filename = "./graph.txt";
    let output_folder = "./output";
    let file = std::fs::File::open(filename).unwrap();

    let graph = graph_csr::Graph::<u32>::from_txt_adjacency_list(file, output_folder).unwrap();

    for (node, edges) in graph.iter().enumerate() {
        println!("{:?} -> {:?}", node, edges);
    }
}

And we can see the following output:

0 -> [1, 2]
1 -> [5, 2]
2 -> []
3 -> []
4 -> [7]
5 -> []
6 -> []
7 -> []

You can now inspect the folder output:

> ls output
edge.csr  vertex.csr

The graph is now saved for future use, and there is no need of parsing it again (as it can be time consuming).

For examples on how to compute algorithms, check the examples folder. You can use a default parser from txt to parse your SORTED graph. If you're looking for an example graph, kindly check the LiveJournal dataset which is already sorted (but you're required to remove any comment lines from it).

About

A crate that serves as the baseline for constructing powerful graph algorithms in CSR

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages