terrain-graph 1.0.1

A Simple Graph Library for Rust
Documentation
  • Coverage
  • 91.49%
    43 out of 47 items documented0 out of 42 items with examples
  • Size
  • Source code size: 18.89 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 2.55 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • TadaTeruki

terrain-graph

A simple graph library for Rust based on adjacency lists.

This is a subproject for the fastlem.

This library contains the following structures:

  • DirectedGraph
  • UndirectedGraph
  • EdgeAttributedDirectedGraph
  • EdgeAttributedUndirectedGraph

Usage

[dependencies]
terrain-graph = "1.0.1"

This is a basic example of how to use the UndirectedGraph and DirectedGraph:

use terrain_graph::*;

// Create an undirected graph
let mut undirected_graph = UndirectedGraph::new(5);
undirected_graph.add_edge(0, 1);
undirected_graph.add_edge(0, 2);
println!("{}", undirected_graph.has_edge(1, 0)); // Outputs: true
println!("{}", undirected_graph.degree(0)); // Outputs: 2

// Create a directed graph
let mut directed_graph = DirectedGraph::new(5);
directed_graph.add_edge(0, 1);
directed_graph.add_edge(0, 2);
println!("{}", directed_graph.has_edge(1, 0)); // Outputs: false
println!("{}", directed_graph.outdegree(0)); // Outputs: 2
println!("{}", directed_graph.indegree(1)); // Outputs: 1