A fast library for graph/network manipulation inspired by networkx.
Add this to your application's shard.yml
:
dependencies:
sodium:
github: EddyShure/sodium
require "sodium"
You can create a graph with nodes of any type. For example, if you want to create a
graph with nodes of the type Int32
:
graph = Sodium::Graph(Int32).new()
Manipulating the graph is straightforward:
# Add individual nodes
graph.add_node(1)
graph.add_node(2)
graph.add_node(3, {weight: 232})
# Add multiple nodes
graph.add_nodes_from([31, 32, 33])
# Add an edge
graph.add_edge(1, 2)
graph.add_edge(66, 88)
# Add multiple edge
graph.add_edges_from([{2, 3}, {4, 5}, {6, 7}])
# Remove a node
graph.remove_node(1)
For more information, please check out the documentation.
-
Graph
-
DiGraph
-
MultiGraph
-
MultiDiGraph
- Fork it
- Create your feature branch (git checkout -b my-new-feature)
- Commit your changes (git commit -am 'Add some feature')
- Push to the branch (git push origin my-new-feature)
- Create a new Pull Request
- EddyShure Eddy Shure - creator, maintainer