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.
- Host: GitHub
- URL: https://github.com/0exp/meta_struct
- Owner: 0exp
- License: mit
- Created: 2020-10-07T22:15:33.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2021-02-26T08:49:32.000Z (over 4 years ago)
- Last Synced: 2025-03-18T20:54:23.092Z (3 months ago)
- Topics: metastruct, ruby-graph
- Language: Ruby
- Homepage: https://github.com/0exp/meta_struct
- Size: 102 KB
- Stars: 3
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
- Code of conduct: CODE_OF_CONDUCT.md
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)