An open API service indexing awesome lists of open source software.

https://github.com/0exp/meta_struct

MetaStruct - a collection of strongly business-oriented variants of commonly used data structures such as graphs, lists and etc.
https://github.com/0exp/meta_struct

metastruct ruby-graph

Last synced: about 1 month ago
JSON representation

MetaStruct - a collection of strongly business-oriented variants of commonly used data structures such as graphs, lists and etc.

Awesome Lists containing this project

README

        

# MetaStruct

MetaStruct - a collection of strongly business-oriented variants of commonly used data structures such as graphs, lists and etc.

---

## Table of usage

- [MetaStruct::Graph](#metastructgraph) (immutable directed acyclic graph)
- [Graph Invariants](#graph-invariants)
- [Graph Creation](#graph-creation)
- [Contributing](#contributing)
- [License](#license)
- [Authors](#authors)

---

## MetaStruct::Graph

`MetaStruct::Graph` - directed acyclic graph. Realized as a representational data structure (without mutation interfaces).

- [Graph Invariants](#graph-invariants)
- [Graph Creation](#graph-creation)

---

### Graph Invariants:

- has only one root node;
- has no non-connected nodes;
- has no cycles (in development);
- has exit (at least one);

---

### Graph Creation

- create node `MetaStruct::Graph::Node`:

```ruby
MetaStruct::Graph::Node.create(
uuid: _your_uuid_, # autogenerated via SecureRandom.uuid by default
labels: _your_labels_, # [] by default
properties: _your_properties_ # {} by default
)
```

- create edge `MetaStruct::Graph::Edge`:

```ruby
MetaStruct::Graph::Edge.create(
left_node: _your_left_node_, # an instance of MetaStruct::Graph::Node
right_node: _your_right_node_, # an instance of MetaStruct::Graph::Node
labels: _your_labels_, # [] by default
properties: _your_properties_, # {} by default
weight: _your_weight_ # 0 by default
)
```

- build graph `MetaStruct::Graph`:
- fails on duplicated nodes (nodes with duplicated `uuid`s);
- fails on duplicated edges (duplicated edge objects wich have identical left and right nodes);
- fails on situation, when node has no edge entity (presented in edge list);
- fails on situation, when edge has node which is not presented in node list;

```ruby
MetaStruct::Graph.create(
nodes: _your_array_of_nodes_, # [] by default
edges: _your_array_of_edges # [] by default
)
```

---

## Contributing

- Fork it ( https://github.com/0exp/meta_struct/fork )
- Create your feature branch (`git checkout -b feature/my-new-feature`)
- Commit your changes (`git commit -am '[my-new-featre] Add some feature'`)
- Push to the branch (`git push origin feature/my-new-feature`)
- Create new Pull Request

## License

Released under MIT License.

## Authors

[Rustam Ibragimov](https://github.com/0exp)